summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-02 15:14:38 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-02 17:40:18 +0100
commitad9f3f7ae6b472eb119cb9c9715d5c36aa1587b7 (patch)
tree0f4e600f395c7529163c37f79bf9d26b06c9554c /Userland
parent65b38f26236f62b40b2b3c6d81d0c23a025494cd (diff)
downloadserenity-ad9f3f7ae6b472eb119cb9c9715d5c36aa1587b7.zip
LibWeb: Add fast_is<T> for HTML::HTMLAnchorElement
We were spending 20% of style computation time on the HTML spec on deciding whether DOM nodes were HTML anchor (a) tags or not.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.h1
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h7
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h
index ca1da26ab4..59992fa52f 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.h
+++ b/Userland/Libraries/LibWeb/DOM/Node.h
@@ -84,6 +84,7 @@ public:
virtual bool is_editable() const;
virtual bool is_html_html_element() const { return false; }
+ virtual bool is_html_anchor_element() const { return false; }
virtual bool is_html_template_element() const { return false; }
virtual bool is_browsing_context_container() const { return false; }
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h
index 0d35bae7e7..8fc77c2ada 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h
@@ -24,6 +24,8 @@ public:
virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
+ virtual bool is_html_anchor_element() const override { return true; }
+
private:
// ^DOM::Element
virtual void parse_attribute(FlyString const& name, String const& value) override;
@@ -35,3 +37,8 @@ private:
};
}
+
+namespace Web::DOM {
+template<>
+inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); }
+}