summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-24 05:41:55 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-24 06:43:21 +0200
commitdd19f615381fb887f44cceaf6a85281e64565689 (patch)
tree9b60a01f39cabb760466a3071a6dc5741428171b
parent8177ecb17f245d159ac4b2e9bde4c2221fcdc38b (diff)
downloadserenity-dd19f615381fb887f44cceaf6a85281e64565689.zip
LibWeb: Add fast way to check if a DOM node is an SVG element
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.h1
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGElement.h10
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h
index c1abd5ea0d..96392c2d66 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.h
+++ b/Userland/Libraries/LibWeb/DOM/Node.h
@@ -73,6 +73,7 @@ public:
virtual bool requires_svg_container() const { return false; }
virtual bool is_svg_container() const { return false; }
+ virtual bool is_svg_element() const { return false; }
virtual bool is_svg_svg_element() const { return false; }
bool in_a_document_tree() const;
diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGElement.h
index e3ce0535c2..1329d86814 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGElement.h
+++ b/Userland/Libraries/LibWeb/SVG/SVGElement.h
@@ -26,6 +26,16 @@ protected:
virtual void visit_edges(Cell::Visitor&) override;
JS::GCPtr<HTML::DOMStringMap> m_dataset;
+
+private:
+ virtual bool is_svg_element() const final { return true; }
};
}
+
+namespace Web::DOM {
+
+template<>
+inline bool Node::fast_is<SVG::SVGElement>() const { return is_svg_element(); }
+
+}