Don't tell stylo about stylesheets that are not in a browsing context (#35606)

* Don't register stylesheets outside of a browsing context with stylo

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-02-24 21:04:18 +01:00 committed by GitHub
parent be6765447d
commit cdc33b398c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 31 deletions

View file

@ -4413,12 +4413,12 @@ impl Document {
}) })
.cloned(); .cloned();
let cloned_stylesheet = sheet.clone(); if self.has_browsing_context() {
let insertion_point2 = insertion_point.clone(); self.window.layout_mut().add_stylesheet(
self.window.layout_mut().add_stylesheet( sheet.clone(),
cloned_stylesheet, insertion_point.as_ref().map(|s| s.sheet.clone()),
insertion_point2.as_ref().map(|s| s.sheet.clone()), );
); }
DocumentOrShadowRoot::add_stylesheet( DocumentOrShadowRoot::add_stylesheet(
owner, owner,
@ -4439,10 +4439,11 @@ impl Document {
/// Remove a stylesheet owned by `owner` from the list of document sheets. /// Remove a stylesheet owned by `owner` from the list of document sheets.
#[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily.
pub(crate) fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc<Stylesheet>) { pub(crate) fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc<Stylesheet>) {
let cloned_stylesheet = stylesheet.clone(); if self.has_browsing_context() {
self.window self.window
.layout_mut() .layout_mut()
.remove_stylesheet(cloned_stylesheet); .remove_stylesheet(stylesheet.clone());
}
DocumentOrShadowRoot::remove_stylesheet( DocumentOrShadowRoot::remove_stylesheet(
owner, owner,

View file

@ -1,5 +1,4 @@
[slot-element-focusable.tentative.html] [slot-element-focusable.tentative.html]
expected: CRASH
[slot element with display: block should be focusable] [slot element with display: block should be focusable]
expected: FAIL expected: FAIL

View file

@ -1,4 +1,9 @@
[MouseEvent-prototype-offsetX-offsetY.html] [MouseEvent-prototype-offsetX-offsetY.html]
expected: CRASH
[MouseEvent's offsetX and offsetY attributes must be relative to the target.] [MouseEvent's offsetX and offsetY attributes must be relative to the target.]
expected: FAIL expected: FAIL
[MouseEvent's offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree.]
expected: FAIL
[MouseEvent's offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content.]
expected: FAIL

View file

@ -1,25 +1,6 @@
[ShadowRoot-interface.html] [ShadowRoot-interface.html]
expected: CRASH
[ShadowRoot.activeElement must return the focused element of the context object when shadow root is open.] [ShadowRoot.activeElement must return the focused element of the context object when shadow root is open.]
expected: FAIL expected: FAIL
[ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed.] [ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed.]
expected: FAIL expected: FAIL
[ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open.]
expected: FAIL
[ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed.]
expected: FAIL
[ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open.]
expected: FAIL
[ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed.]
expected: FAIL
[ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open.]
expected: FAIL
[ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed.]
expected: FAIL