/src/serenity/Userland/Libraries/LibWeb/SVG/SVGElement.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/DOM/Document.h> |
10 | | #include <LibWeb/DOM/Element.h> |
11 | | #include <LibWeb/SVG/SVGAnimatedString.h> |
12 | | |
13 | | namespace Web::SVG { |
14 | | |
15 | | class SVGElement |
16 | | : public DOM::Element |
17 | | , public HTML::GlobalEventHandlers { |
18 | | WEB_PLATFORM_OBJECT(SVGElement, DOM::Element); |
19 | | |
20 | | public: |
21 | 0 | virtual bool requires_svg_container() const override { return true; } |
22 | | |
23 | | virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override; |
24 | | |
25 | | virtual void children_changed() override; |
26 | | virtual void inserted() override; |
27 | | virtual void removed_from(Node*) override; |
28 | | |
29 | | [[nodiscard]] JS::NonnullGCPtr<HTML::DOMStringMap> dataset(); |
30 | | |
31 | | void focus(); |
32 | | void blur(); |
33 | | |
34 | | JS::NonnullGCPtr<SVGAnimatedString> class_name(); |
35 | | JS::GCPtr<SVGSVGElement> owner_svg_element(); |
36 | | |
37 | | protected: |
38 | | SVGElement(DOM::Document&, DOM::QualifiedName); |
39 | | |
40 | | virtual void initialize(JS::Realm&) override; |
41 | | virtual void visit_edges(Cell::Visitor&) override; |
42 | | |
43 | | void update_use_elements_that_reference_this(); |
44 | | void remove_from_use_element_that_reference_this(); |
45 | | |
46 | | JS::GCPtr<HTML::DOMStringMap> m_dataset; |
47 | | |
48 | | JS::NonnullGCPtr<SVGAnimatedLength> svg_animated_length_for_property(CSS::PropertyID) const; |
49 | | |
50 | | private: |
51 | | // ^HTML::GlobalEventHandlers |
52 | 0 | virtual JS::GCPtr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; } |
53 | | |
54 | 0 | virtual bool is_svg_element() const final { return true; } |
55 | | |
56 | | JS::GCPtr<SVGAnimatedString> m_class_name_animated_string; |
57 | | }; |
58 | | |
59 | | } |
60 | | |
61 | | namespace Web::DOM { |
62 | | |
63 | | template<> |
64 | 0 | inline bool Node::fast_is<SVG::SVGElement>() const { return is_svg_element(); } |
65 | | |
66 | | } |