LibWeb: Add fast_is<T>() for various types stood out in a profile

This commit is contained in:
Andreas Kling 2023-03-10 21:16:18 +01:00
parent f6426cdcd4
commit 1cf5737e9e
Notes: sideshowbarker 2024-07-16 23:05:13 +09:00
8 changed files with 48 additions and 0 deletions

View file

@ -618,4 +618,7 @@ private:
JS::GCPtr<HTML::HTMLBaseElement const> m_first_base_element_with_href_in_tree_order;
};
template<>
inline bool Node::fast_is<Document>() const { return is_document(); }
}

View file

@ -85,6 +85,9 @@ public:
virtual bool is_html_html_element() const { return false; }
virtual bool is_html_anchor_element() const { return false; }
virtual bool is_html_base_element() const { return false; }
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_template_element() const { return false; }
virtual bool is_browsing_context_container() const { return false; }

View file

@ -29,6 +29,9 @@ public:
private:
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);
// ^DOM::Node
virtual bool is_html_body_element() const override { return true; }
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
// ^HTML::GlobalEventHandlers
@ -41,3 +44,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLBodyElement>() const { return is_html_body_element(); }
}

View file

@ -125,6 +125,9 @@ public:
private:
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
// ^DOM::Node
virtual bool is_html_input_element() const final { return true; }
// ^DOM::EventTarget
virtual void did_receive_focus() override;
virtual void legacy_pre_activation_behavior() override;
@ -166,3 +169,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLInputElement>() const { return is_html_input_element(); }
}

View file

@ -39,6 +39,9 @@ public:
private:
HTMLProgressElement(DOM::Document&, DOM::QualifiedName);
// ^DOM::Node
virtual bool is_html_input_element() const final { return true; }
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
void progress_position_updated();
@ -47,3 +50,8 @@ private:
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLProgressElement>() const { return is_html_progress_element(); }
}

View file

@ -25,9 +25,13 @@ public:
void set_marker(JS::GCPtr<ListItemMarkerBox>);
private:
virtual bool is_list_item_box() const override { return true; }
virtual void visit_edges(Cell::Visitor&) override;
JS::GCPtr<ListItemMarkerBox> m_marker;
};
template<>
inline bool Node::fast_is<ListItemBox>() const { return is_list_item_box(); }
}

View file

@ -89,11 +89,14 @@ public:
virtual bool is_viewport() const { return false; }
virtual bool is_svg_box() const { return false; }
virtual bool is_svg_geometry_box() const { return false; }
virtual bool is_svg_svg_box() const { return false; }
virtual bool is_label() const { return false; }
virtual bool is_replaced_box() const { return false; }
virtual bool is_list_item_box() const { return false; }
virtual bool is_list_item_marker_box() const { return false; }
virtual bool is_table_wrapper() const { return false; }
virtual bool is_table() const { return false; }
virtual bool is_node_with_style_and_box_model_metrics() const { return false; }
template<typename T>
bool fast_is() const = delete;
@ -219,9 +222,14 @@ protected:
}
private:
virtual bool is_node_with_style_and_box_model_metrics() const final { return true; }
BoxModelMetrics m_box_model;
};
template<>
inline bool Node::fast_is<NodeWithStyleAndBoxModelMetrics>() const { return is_node_with_style_and_box_model_metrics(); }
inline Gfx::Font const& Node::font() const
{
if (m_has_style)

View file

@ -25,6 +25,12 @@ public:
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
virtual void prepare_for_replaced_layout() override;
private:
virtual bool is_svg_svg_box() const final { return true; }
};
template<>
inline bool Node::fast_is<SVGSVGBox>() const { return is_svg_svg_box(); }
}