mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-20 06:36:16 +00:00
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:
committed by
Andreas Kling
parent
003c045589
commit
adc25af8e2
@@ -8,6 +8,7 @@
|
||||
#include <LibWeb/Bindings/HTMLSlotElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/HTMLSlotElement.h>
|
||||
|
||||
@@ -147,4 +148,21 @@ void HTMLSlotElement::attribute_changed(FlyString const& local_name, Optional<St
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLSlotElement::inserted()
|
||||
{
|
||||
Base::inserted();
|
||||
auto& root = this->root();
|
||||
if (!root.is_shadow_root())
|
||||
return;
|
||||
static_cast<DOM::ShadowRoot&>(root).increment_slot_count();
|
||||
}
|
||||
|
||||
void HTMLSlotElement::removed_from(Node* old_parent, Node& old_root)
|
||||
{
|
||||
Base::removed_from(old_parent, old_root);
|
||||
if (!old_root.is_shadow_root())
|
||||
return;
|
||||
static_cast<DOM::ShadowRoot&>(old_root).decrement_slot_count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user