From 1c62ee93961f30c73e25e4a1e59863ab53b16ecc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 2 Nov 2023 14:56:48 +0100 Subject: [PATCH] LibWeb: Cache the "id" attribute value on DOM::Element as FlyString This will allow us to do O(1) checks against the element ID when matching selectors, etc. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 7 ++++++- Userland/Libraries/LibWeb/DOM/Element.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 410ce18413..2de561ba6e 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -478,7 +478,12 @@ void Element::attribute_changed(FlyString const& name, Optional const& id() const { return m_id; } + protected: Element(Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; @@ -411,6 +413,8 @@ private: Vector m_classes; Optional m_dir; + Optional m_id; + Array, to_underlying(CSS::Selector::PseudoElement::PseudoElementCount)> m_pseudo_element_nodes; // https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reaction-queue