mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:27:35 +00:00
LibWeb: Add fast_is<T>() for various types stood out in a profile
This commit is contained in:
parent
f6426cdcd4
commit
1cf5737e9e
8 changed files with 48 additions and 0 deletions
|
@ -618,4 +618,7 @@ private:
|
||||||
JS::GCPtr<HTML::HTMLBaseElement const> m_first_base_element_with_href_in_tree_order;
|
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(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,9 @@ public:
|
||||||
virtual bool is_html_html_element() const { return false; }
|
virtual bool is_html_html_element() const { return false; }
|
||||||
virtual bool is_html_anchor_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_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_html_template_element() const { return false; }
|
||||||
virtual bool is_browsing_context_container() const { return false; }
|
virtual bool is_browsing_context_container() const { return false; }
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);
|
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;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
|
|
||||||
// ^HTML::GlobalEventHandlers
|
// ^HTML::GlobalEventHandlers
|
||||||
|
@ -41,3 +44,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLBodyElement>() const { return is_html_body_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -125,6 +125,9 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
|
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
// ^DOM::Node
|
||||||
|
virtual bool is_html_input_element() const final { return true; }
|
||||||
|
|
||||||
// ^DOM::EventTarget
|
// ^DOM::EventTarget
|
||||||
virtual void did_receive_focus() override;
|
virtual void did_receive_focus() override;
|
||||||
virtual void legacy_pre_activation_behavior() 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(); }
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLProgressElement(DOM::Document&, DOM::QualifiedName);
|
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;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
|
|
||||||
void progress_position_updated();
|
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(); }
|
||||||
|
}
|
||||||
|
|
|
@ -25,9 +25,13 @@ public:
|
||||||
void set_marker(JS::GCPtr<ListItemMarkerBox>);
|
void set_marker(JS::GCPtr<ListItemMarkerBox>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual bool is_list_item_box() const override { return true; }
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
JS::GCPtr<ListItemMarkerBox> m_marker;
|
JS::GCPtr<ListItemMarkerBox> m_marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<ListItemBox>() const { return is_list_item_box(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,11 +89,14 @@ public:
|
||||||
virtual bool is_viewport() const { return false; }
|
virtual bool is_viewport() const { return false; }
|
||||||
virtual bool is_svg_box() const { return false; }
|
virtual bool is_svg_box() const { return false; }
|
||||||
virtual bool is_svg_geometry_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_label() const { return false; }
|
||||||
virtual bool is_replaced_box() 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_list_item_marker_box() const { return false; }
|
||||||
virtual bool is_table_wrapper() const { return false; }
|
virtual bool is_table_wrapper() const { return false; }
|
||||||
virtual bool is_table() 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>
|
template<typename T>
|
||||||
bool fast_is() const = delete;
|
bool fast_is() const = delete;
|
||||||
|
@ -219,9 +222,14 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual bool is_node_with_style_and_box_model_metrics() const final { return true; }
|
||||||
|
|
||||||
BoxModelMetrics m_box_model;
|
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
|
inline Gfx::Font const& Node::font() const
|
||||||
{
|
{
|
||||||
if (m_has_style)
|
if (m_has_style)
|
||||||
|
|
|
@ -25,6 +25,12 @@ public:
|
||||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||||
|
|
||||||
virtual void prepare_for_replaced_layout() 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(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue