Include non-shadowdom children of shadow hosts in style calculation#34298
Merged
simonwuelker merged 2 commits intoservo:mainfrom Nov 20, 2024
Merged
Include non-shadowdom children of shadow hosts in style calculation#34298simonwuelker merged 2 commits intoservo:mainfrom
simonwuelker merged 2 commits intoservo:mainfrom
Conversation
Member
I'm actually putting together a PR for that right now. |
|
🔨 Triggering try run (#11928284988) for Linux WPT |
|
Test results for linux-wpt-layout-2020 from try job (#11928284988): Flaky unexpected result (28)
Stable unexpected results that are known to be intermittent (10)
|
|
✨ Try run (#11928284988) succeeded. |
This was previously causing crashes because the layout nodes of those children would never be assigned style data by stylo. Signed-off-by: Simon Wülker <[email protected]>
25add83 to
6c99579
Compare
Contributor
Author
|
Seems like many tests ran into this crash 👀 |
Contributor
Author
|
Apologies, I should have done a full try run. |
Signed-off-by: Simon Wülker <[email protected]>
6c99579 to
4db470e
Compare
Closed
simonwuelker
added a commit
to simonwuelker/servo
that referenced
this pull request
Jan 28, 2025
There is some interesting history to this change: * servo#33495: Servo crashes on Cloudflare's turnstile, because we didn't compute style for elements inside shadow trees * servo#34298: Resolves the issue by computing style for children of a potential shadow root, in addition to the children of an element * servo#34701: Changes layout of elements with shadow roots such that only the contents of the shadow root are laid out Now, we compute style for both the children of the element and a potential shadow root, but only lay out the contents of the shadow tree (if there is one). This behaviour is not technically incorrect, since regular children are not included in layout their style doesn't matter. However, it is inefficient: the only case where we need to compute style for a child of a shadow host is when that child is an assigned slottable in a slot somewhere else. This part 1/n of upstreaming the changes necessary to lay out <slot> contents. Note that trying to compute style for <slot> contents *and* children of shadow hosts will crash in stylo, since it expects to see each element only once. Signed-off-by: Simon Wülker <[email protected]>
4 tasks
simonwuelker
added a commit
to simonwuelker/servo
that referenced
this pull request
Jan 28, 2025
There is some interesting history to this change: * servo#33495: Servo crashes on Cloudflare's turnstile, because we didn't compute style for elements inside shadow trees * servo#34298: Resolves the issue by computing style for children of a potential shadow root, in addition to the children of an element * servo#34701: Changes layout of elements with shadow roots such that only the contents of the shadow root are laid out Now, we compute style for both the children of the element and a potential shadow root, but only lay out the contents of the shadow tree (if there is one). This behaviour is not technically incorrect, since regular children are not included in layout their style doesn't matter. However, it is inefficient: the only case where we need to compute style for a child of a shadow host is when that child is an assigned slottable in a slot somewhere else. This part 1/n of upstreaming the changes necessary to lay out <slot> contents. Note that trying to compute style for <slot> contents *and* children of shadow hosts will crash in stylo, since it expects to see each element only once. Signed-off-by: Simon Wülker <[email protected]>
simonwuelker
added a commit
to simonwuelker/servo
that referenced
this pull request
Jan 28, 2025
There is some interesting history to this change: * servo#33495: Servo crashes on Cloudflare's turnstile, because we didn't compute style for elements inside shadow trees * servo#34298: Resolves the issue by computing style for children of a potential shadow root, in addition to the children of an element * servo#34701: Changes layout of elements with shadow roots such that only the contents of the shadow root are laid out Now, we compute style for both the children of the element and a potential shadow root, but only lay out the contents of the shadow tree (if there is one). This behaviour is not technically incorrect, since regular children are not included in layout their style doesn't matter. However, it is inefficient: the only case where we need to compute style for a child of a shadow host is when that child is an assigned slottable in a slot somewhere else. This part 1/n of upstreaming the changes necessary to lay out `<slot>` contents. Note that trying to compute style for `<slot>` contents *and* children of shadow hosts will crash in stylo, since it expects to see each element only once. Signed-off-by: Simon Wülker <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 28, 2025
There is some interesting history to this change: * #33495: Servo crashes on Cloudflare's turnstile, because we didn't compute style for elements inside shadow trees * #34298: Resolves the issue by computing style for children of a potential shadow root, in addition to the children of an element * #34701: Changes layout of elements with shadow roots such that only the contents of the shadow root are laid out Now, we compute style for both the children of the element and a potential shadow root, but only lay out the contents of the shadow tree (if there is one). This behaviour is not technically incorrect, since regular children are not included in layout their style doesn't matter. However, it is inefficient: the only case where we need to compute style for a child of a shadow host is when that child is an assigned slottable in a slot somewhere else. This part 1/n of upstreaming the changes necessary to lay out `<slot>` contents. Note that trying to compute style for `<slot>` contents *and* children of shadow hosts will crash in stylo, since it expects to see each element only once. Signed-off-by: Simon Wülker <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently
ServoLayoutElement::traversal_childrenfails to account for children outside the shadow DOM if the element is a shadow host:servo/components/script/layout_dom/element.rs
Lines 151 to 157 in c73e4ba
Stylo doesn't know about those children, so they are never assigned a style. Trying to access the style data causes crashes as seen in #33495.
There are no tests for these changes, because we don't run
shadow-domweb platform tests. Perhaps we should consider changing that?try run
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors