mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +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:
parent
003c045589
commit
adc25af8e2
Notes:
github-actions[bot]
2025-01-23 20:40:06 +00:00
Author: https://github.com/awesomekling
Commit: adc25af8e2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3345
Reviewed-by: https://github.com/AtkinsSJ
4 changed files with 49 additions and 11 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue