summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-23 11:25:07 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-23 14:38:45 +0200
commitdf1bb0ff49b0f52f61da8d19c46cdbfa4ef6cfeb (patch)
tree52a603c17f4d11c2cc31ae00d4f6bd20a3752674 /Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
parente31f696ee631f8dac610f8011d859098f439ea33 (diff)
downloadserenity-df1bb0ff49b0f52f61da8d19c46cdbfa4ef6cfeb.zip
LibWeb: Make HTMLCollection faster when it only cares about children
Some of the live HTMLCollection only ever contain children of their root node. When we know that's the case, we can avoid doing a full subtree traversal of all descendants and only visit children. This cuts the ECMA262 spec loading time by over 10 seconds. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
index 8f8a3281c3..41b20d8cb0 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
@@ -264,7 +264,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::t_bodies()
// The tBodies attribute must return an HTMLCollection rooted at the table node,
// whose filter matches only tbody elements that are children of the table element.
if (!m_t_bodies) {
- m_t_bodies = DOM::HTMLCollection::create(*this, [](DOM::Element const& element) {
+ m_t_bodies = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Children, [](DOM::Element const& element) {
return element.local_name() == TagNames::tbody;
}).release_value_but_fixme_should_propagate_errors();
}
@@ -307,7 +307,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::rows()
// How do you sort HTMLCollection?
if (!m_rows) {
- m_rows = DOM::HTMLCollection::create(*this, [table_node](DOM::Element const& element) {
+ m_rows = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Descendants, [table_node](DOM::Element const& element) {
// Only match TR elements which are:
// * children of the table element
// * children of the thead, tbody, or tfoot elements that are themselves children of the table element