1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

LibWeb: Add fast_is<T> for form, embed, image, and object elements

These are used by Window::supported_property_names(), which can get
very hot.
This commit is contained in:
Andreas Kling 2023-12-24 14:41:33 +01:00
parent 70779e43ed
commit 75d5429d66
5 changed files with 31 additions and 0 deletions

View file

@ -103,6 +103,10 @@ public:
virtual bool is_html_br_element() const { return false; }
virtual bool is_html_button_element() const { return false; }
virtual bool is_html_slot_element() const { return false; }
virtual bool is_html_embed_element() const { return false; }
virtual bool is_html_object_element() const { return false; }
virtual bool is_html_form_element() const { return false; }
virtual bool is_html_image_element() const { return false; }
virtual bool is_navigable_container() const { return false; }
virtual bool is_lazy_loading() const { return false; }

View file

@ -20,7 +20,13 @@ public:
private:
HTMLEmbedElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_embed_element() const override { return true; }
virtual void initialize(JS::Realm&) override;
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLEmbedElement>() const { return is_html_embed_element(); }
}

View file

@ -90,6 +90,8 @@ public:
private:
HTMLFormElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_form_element() const override { return true; }
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -122,3 +124,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLFormElement>() const { return is_html_form_element(); }
}

View file

@ -96,6 +96,8 @@ public:
private:
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_image_element() const override { return true; }
virtual void initialize(JS::Realm&) override;
virtual void finalize() override;
@ -137,3 +139,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLImageElement>() const { return is_html_image_element(); }
}

View file

@ -51,6 +51,8 @@ public:
private:
HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_object_element() const override { return true; }
virtual void initialize(JS::Realm&) override;
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
@ -87,3 +89,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLObjectElement>() const { return is_html_object_element(); }
}