/src/serenity/Userland/Libraries/LibWeb/SVG/SVGUseElement.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, Preston Taylor <95388976+PrestonLTaylor@users.noreply.github.com> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/FlyString.h> |
10 | | #include <LibGfx/Path.h> |
11 | | #include <LibWeb/DOM/DocumentObserver.h> |
12 | | #include <LibWeb/SVG/SVGAnimatedLength.h> |
13 | | #include <LibWeb/SVG/SVGGraphicsElement.h> |
14 | | #include <LibWeb/SVG/SVGURIReference.h> |
15 | | |
16 | | namespace Web::SVG { |
17 | | |
18 | | class SVGUseElement final |
19 | | : public SVGGraphicsElement |
20 | | , public SVGURIReferenceMixin<SupportsXLinkHref::Yes> { |
21 | | WEB_PLATFORM_OBJECT(SVGUseElement, SVGGraphicsElement); |
22 | | JS_DECLARE_ALLOCATOR(SVGUseElement); |
23 | | |
24 | | public: |
25 | 0 | virtual ~SVGUseElement() override = default; |
26 | | |
27 | | virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override; |
28 | | |
29 | | virtual void inserted() override; |
30 | | |
31 | | void svg_element_changed(SVGElement&); |
32 | | void svg_element_removed(SVGElement&); |
33 | | |
34 | | JS::NonnullGCPtr<SVGAnimatedLength> x() const; |
35 | | JS::NonnullGCPtr<SVGAnimatedLength> y() const; |
36 | | JS::NonnullGCPtr<SVGAnimatedLength> width() const; |
37 | | JS::NonnullGCPtr<SVGAnimatedLength> height() const; |
38 | | |
39 | | JS::GCPtr<SVGElement> instance_root() const; |
40 | | JS::GCPtr<SVGElement> animated_instance_root() const; |
41 | | |
42 | | virtual Gfx::AffineTransform element_transform() const override; |
43 | | |
44 | | private: |
45 | | SVGUseElement(DOM::Document&, DOM::QualifiedName); |
46 | | |
47 | | virtual void initialize(JS::Realm&) override; |
48 | | virtual void visit_edges(Cell::Visitor&) override; |
49 | | |
50 | 0 | virtual bool is_svg_use_element() const override { return true; } |
51 | | |
52 | | virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; |
53 | | |
54 | | void process_the_url(Optional<String> const& href); |
55 | | |
56 | | static Optional<FlyString> parse_id_from_href(StringView); |
57 | | |
58 | | JS::GCPtr<DOM::Element> referenced_element(); |
59 | | |
60 | | void fetch_the_document(URL::URL const& url); |
61 | | bool is_referrenced_element_same_document() const; |
62 | | |
63 | | void clone_element_tree_as_our_shadow_tree(Element* to_clone); |
64 | | bool is_valid_reference_element(Element const& reference_element) const; |
65 | | |
66 | | Optional<float> m_x; |
67 | | Optional<float> m_y; |
68 | | |
69 | | URL::URL m_href; |
70 | | |
71 | | JS::GCPtr<DOM::DocumentObserver> m_document_observer; |
72 | | JS::GCPtr<HTML::SharedResourceRequest> m_resource_request; |
73 | | Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer; |
74 | | }; |
75 | | |
76 | | } |
77 | | |
78 | | namespace Web::DOM { |
79 | | |
80 | | template<> |
81 | 0 | inline bool Node::fast_is<SVG::SVGUseElement>() const { return is_svg_use_element(); } |
82 | | |
83 | | } |