/* * Copyright (c) 2023, Preston Taylor <95388976+PrestonLTaylor@users.noreply.github.com> * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::SVG { class SVGUseElement final : public SVGGraphicsElement , public SVGURIReferenceMixin { WEB_PLATFORM_OBJECT(SVGUseElement, SVGGraphicsElement); GC_DECLARE_ALLOCATOR(SVGUseElement); public: static constexpr bool OVERRIDES_FINALIZE = true; virtual ~SVGUseElement() override = default; virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; void svg_element_changed(SVGElement&); void svg_element_changed_before_document_complete(SVGElement&); void svg_element_removed(SVGElement&); GC::Ref x() const; GC::Ref y() const; GC::Ref width() const; GC::Ref height() const; GC::Ptr instance_root() const; GC::Ptr animated_instance_root() const; virtual Gfx::AffineTransform element_transform() const override; private: SVGUseElement(DOM::Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void finalize() override; virtual void adopted_from(DOM::Document&) override; virtual void inserted() override; virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root) override; virtual void moved_from(IsSubtreeRoot, GC::Ptr old_ancestor) override; virtual bool is_svg_use_element() const override { return true; } virtual RefPtr create_layout_node(CSS::ComputedProperties const&) override; void process_the_url(Optional const& href); static Optional parse_id_from_href(StringView); GC::Ptr referenced_element() const; void fetch_the_document(URL::URL const& url); bool is_referenced_element_same_document() const; void clone_element_tree_as_our_shadow_tree(Element* to_clone); bool is_valid_reference_element(Element const& reference_element) const; bool would_create_circular_reference(Element const& target) const; bool would_create_circular_reference_impl(Element const& target, GC::HeapHashTable>& visited) const; void register_for_referenced_element_changes(); void unregister_for_referenced_element_changes(); Optional m_x; Optional m_y; bool m_needs_document_complete_reclone { false }; Optional m_href; GC::Ptr m_document_observer; GC::Ptr m_resource_request; Optional m_load_event_delayer; IntrusiveListNode m_list_node; public: using DocumentUseElementList = IntrusiveList<&SVGUseElement::m_list_node>; }; } namespace Web::DOM { template<> inline bool Node::fast_is() const { return is_svg_use_element(); } }