LibWeb: Make "assign slottables for a tree" fast when there are no slots

We achieve this by keeping track of the number of HTMLSlotElements
inside each ShadowRoot (do via ad-hoc insertion and removal steps.)

This allows slottables assignment to skip over entire shadow roots when
we know they have no slots anyway.

Massive speedup on https://wpt.fyi/ which no longer takes minutes/hours
to load, but instead a "mere" 19 seconds. :^)
This commit is contained in:
Andreas Kling 2025-01-23 17:41:53 +01:00 committed by Andreas Kling
parent 003c045589
commit adc25af8e2
Notes: github-actions[bot] 2025-01-23 20:40:06 +00:00
4 changed files with 49 additions and 11 deletions

View file

@ -45,6 +45,9 @@ private:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;
virtual void inserted() override;
virtual void removed_from(Node* old_parent, Node& old_root) override;
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
// https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes