/* * Copyright (c) 2020, Matthew Olsson * Copyright (c) 2023, Preston Taylor <95388976+PrestonLTaylor@users.noreply.github.com> * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include namespace Web::SVG { SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_name) : Element(document, move(qualified_name)) { } JS::ThrowCompletionOr SVGElement::initialize(JS::Realm& realm) { MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "SVGElement")); m_dataset = TRY(Bindings::throw_dom_exception_if_needed(realm.vm(), [&]() { return HTML::DOMStringMap::create(*this); })); return {}; } void SVGElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_dataset); } void SVGElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { Base::parse_attribute(name, value); update_use_elements_that_reference_this(); } void SVGElement::inserted() { Base::inserted(); update_use_elements_that_reference_this(); } void SVGElement::children_changed() { Base::children_changed(); update_use_elements_that_reference_this(); } void SVGElement::update_use_elements_that_reference_this() { if (is(this)) { return; } document().for_each_in_subtree_of_type([this](SVGUseElement& use_element) { use_element.svg_element_changed(*this); return IterationDecision::Continue; }); } void SVGElement::removed_from(Node* parent) { Base::removed_from(parent); remove_from_use_element_that_reference_this(); } void SVGElement::remove_from_use_element_that_reference_this() { if (is(this)) { return; } document().for_each_in_subtree_of_type([this](SVGUseElement& use_element) { use_element.svg_element_removed(*this); return IterationDecision::Continue; }); } }