servo/components/script/layout_dom
Simon Wülker 1188d2b2e7
Never compute style for children of shadow hosts (#35198)
There is some interesting history to this change:

* https://github.com/servo/servo/issues/33495: Servo crashes on
  Cloudflare's turnstile, because we didn't compute style for
  elements inside shadow trees
* https://github.com/servo/servo/pull/34298: Resolves the issue
  by computing style for children of a potential shadow root,
  in addition to the children of an element
* https://github.com/servo/servo/pull/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 <simon.wuelker@arcor.de>
2025-01-28 21:04:32 +00:00
..
document.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
element.rs Never compute style for children of shadow hosts (#35198) 2025-01-28 21:04:32 +00:00
mod.rs Eliminate duplicate Layout DOM wrappers 2023-05-05 17:16:38 +02:00
node.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
shadow_root.rs Elide lifetimes where possible after rustup (#34824) 2025-01-03 18:54:44 +00:00