layout: Lay out Shadow DOM elements#34701
Merged
mrobinson merged 1 commit intoservo:mainfrom Dec 19, 2024
Merged
Conversation
When an element is a shadow root, lay out the shadow root elements instead of the non-shadow children. This fixes some tests and introduces some failures, due to bugs in the Shadow DOM implementation. In general, this is very low impact as the Shadow DOM is still disabled by default. At least this gets elements rendering when the preference is turned on though. Signed-off-by: Martin Robinson <[email protected]>
|
🔨 Triggering try run (#12413802559) for Linux WPT |
|
Test results for linux-wpt-layout-2020 from try job (#12413802559): Flaky unexpected result (21)
Stable unexpected results that are known to be intermittent (11)
|
|
✨ Try run (#12413802559) succeeded. |
jdm
approved these changes
Dec 19, 2024
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.
When an element is a shadow root, lay out the shadow root elements
instead of the non-shadow children.
This fixes some tests and introduces some failures, due to bugs in the
Shadow DOM implementation. In general, this is very low impact as the
Shadow DOM is still disabled by default. At least this gets elements
rendering when the preference is turned on though.
Signed-off-by: Martin Robinson [email protected]
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors