LibWeb: Maintain a mapping for fast lookup in getElementById()

With this change we maintain a data structure that maps ids to
corresponding elements. This allows us to avoid tree traversal in
getElementById() in all cases except ones when lookup happens for
unconnected elements.
This commit is contained in:
Aliaksandr Kalenik 2025-03-25 17:30:52 +00:00 committed by Andreas Kling
commit 8cae20af1b
Notes: github-actions[bot] 2025-03-26 08:37:18 +00:00
15 changed files with 157 additions and 51 deletions

View file

@ -7,7 +7,6 @@
#pragma once
#include <LibGfx/Bitmap.h>
#include <LibWeb/DOM/NonElementParentNode.h>
#include <LibWeb/Geometry/DOMMatrix.h>
#include <LibWeb/Geometry/DOMPoint.h>
#include <LibWeb/SVG/AttributeParser.h>
@ -22,9 +21,7 @@
namespace Web::SVG {
class SVGSVGElement final : public SVGGraphicsElement
, public SVGViewport
// SVGSVGElement is not strictly a NonElementParentNode, but it implements the same get_element_by_id() method.
, public DOM::NonElementParentNode<SVGSVGElement> {
, public SVGViewport {
WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement);
GC_DECLARE_ALLOCATOR(SVGSVGElement);