summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-07 07:43:21 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-07 10:47:30 +0200
commit4637d020c3bed24565e2d10b7267ef738e48d966 (patch)
tree99cd9b09a04161276eb474a859dc812c16a39d3a /Userland/Libraries
parent97f0106eddb5254ce8c8abdfed3de75ddc6287b1 (diff)
downloadserenity-4637d020c3bed24565e2d10b7267ef738e48d966.zip
LibWeb: Add fast_is<T>() helper for HTMLScriptElement
This makes loading Google Groups quite a bit faster, as 20% of runtime while loading was spent asking if DOM nodes are HTMLScriptElement.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.h1
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLScriptElement.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 6fe2a5c2de..f0b3f486ba 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.h
+++ b/Userland/Libraries/LibWeb/DOM/Node.h
@@ -89,6 +89,7 @@ public:
virtual bool is_html_body_element() const { return false; }
virtual bool is_html_input_element() const { return false; }
virtual bool is_html_progress_element() const { return false; }
+ virtual bool is_html_script_element() const { return false; }
virtual bool is_html_template_element() const { return false; }
virtual bool is_navigable_container() const { return false; }
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
index 5b7a5e1fee..00ef528324 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
@@ -58,6 +58,8 @@ public:
private:
HTMLScriptElement(DOM::Document&, DOM::QualifiedName);
+ virtual bool is_html_script_element() const override { return true; }
+
virtual void resource_did_load() override;
virtual void resource_did_fail() override;
@@ -124,3 +126,8 @@ private:
};
}
+
+namespace Web::DOM {
+template<>
+inline bool Node::fast_is<HTML::HTMLScriptElement>() const { return is_html_script_element(); }
+}