Don't compute style for children of shadow hosts#35198
Merged
simonwuelker merged 1 commit intoservo:mainfrom Jan 28, 2025
Merged
Don't compute style for children of shadow hosts#35198simonwuelker merged 1 commit intoservo:mainfrom
simonwuelker merged 1 commit intoservo:mainfrom
Conversation
mrobinson
approved these changes
Jan 28, 2025
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]>
bf048b2 to
e92c9e1
Compare
auto-merge was automatically disabled
January 28, 2025 16:24
Pull Request is not mergeable
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]>
e92c9e1 to
9126e81
Compare
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.
There is some interesting history to this change:
Cloudflare's turnstile, because we didn't compute style for
elements inside shadow trees
by computing style for children of a potential shadow root,
in addition to the children of an element
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 contents and children of shadow hosts will crash in stylo, since it expects to see eachelement only once.try run
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors