diff options
author | Simon Wülker <simon.wuelker@arcor.de> | 2025-03-11 00:11:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-10 23:11:20 +0000 |
commit | fd0e2125c60506fea5408b34a0c2021b8ca7bf00 (patch) | |
tree | 7e8dac6454c4a52857e727420fdd8b3361b2c7c2 /components/script/dom/node.rs | |
parent | 0419a7818dc051aef9f0bb9022ee89aaa4183b99 (diff) | |
download | servo-fd0e2125c60506fea5408b34a0c2021b8ca7bf00.tar.gz servo-fd0e2125c60506fea5408b34a0c2021b8ca7bf00.zip |
Keep a list of slot descendants on each shadow root (#35802)
This makes it much faster to traverse over the slot descendants of
a shadow root, which is a fairly costly part of "assign slottables to a tree".
This reduces the time it takes for the results to load on wpt.fyi from
over 3 minutes to about 5 seconds.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index d4e404dc030..4a4c9f53462 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1362,7 +1362,11 @@ impl Node { // NOTE: This method traverses all descendants of the node and is potentially very // expensive. If the node is not a shadow root then assigning slottables to it won't // have any effect, so we take a fast path out. - if !self.is::<ShadowRoot>() { + let Some(shadow_root) = self.downcast::<ShadowRoot>() else { + return; + }; + + if !shadow_root.has_slot_descendants() { return; } |