ladybird/Libraries/LibWeb/SVG/SVGStyleElement.cpp
Andreas Kling e330d5b9ab LibWeb: Make Node::is_connected() O(1) via a cached flag
Previously this walked up the parent chain on every call, which shows
up as a 2.5% item in the profile while watching YouTube videos.

Cache an m_is_connected bit on Node instead, maintained by the DOM
insertion and removal steps.
2026-04-16 08:26:34 +02:00

51 lines
1.1 KiB
C++

/*
* Copyright (c) 2023, Preston Taylor <PrestonLeeTaylor@proton.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/SVGStyleElementPrototype.h>
#include <LibWeb/SVG/SVGStyleElement.h>
namespace Web::SVG {
GC_DEFINE_ALLOCATOR(SVGStyleElement);
SVGStyleElement::SVGStyleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, move(qualified_name))
{
}
SVGStyleElement::~SVGStyleElement() = default;
void SVGStyleElement::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGStyleElement);
Base::initialize(realm);
}
void SVGStyleElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visit_style_element_edges(visitor);
}
void SVGStyleElement::children_changed(ChildrenChangedMetadata const& metadata)
{
Base::children_changed(metadata);
update_a_style_block();
}
void SVGStyleElement::inserted()
{
Base::inserted();
update_a_style_block();
}
void SVGStyleElement::removed_from(Node* old_parent, Node& old_root)
{
Base::removed_from(old_parent, old_root);
update_a_style_block();
}
}