From 0fd577084ff6632df8afc78d60c90c699c9caadf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 7 Jan 2021 17:31:26 +0100 Subject: [PATCH] LibWeb: Specialize is() and is() These two show up in profiles, so let's add specializations for them. --- Libraries/LibWeb/DOM/Element.h | 9 +++++++++ Libraries/LibWeb/Layout/Box.h | 11 +++++++++++ Libraries/LibWeb/Layout/Node.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 76a29fc30d..ddefb2ab93 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -116,3 +116,12 @@ private: }; } + +namespace AK { +template<> +inline bool is(const Web::DOM::Node& input) +{ + return input.is_element(); +} + +} diff --git a/Libraries/LibWeb/Layout/Box.h b/Libraries/LibWeb/Layout/Box.h index b43f969fad..7b05b381e3 100644 --- a/Libraries/LibWeb/Layout/Box.h +++ b/Libraries/LibWeb/Layout/Box.h @@ -123,6 +123,8 @@ protected: Vector m_line_boxes; private: + virtual bool is_box() const final { return true; } + Gfx::FloatPoint m_offset; Gfx::FloatSize m_size; @@ -133,3 +135,12 @@ private: }; } + +namespace AK { +template<> +inline bool is(const Web::Layout::Node& input) +{ + return input.is_box(); +} + +} diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h index de7ed3e7bf..c1699924e3 100644 --- a/Libraries/LibWeb/Layout/Node.h +++ b/Libraries/LibWeb/Layout/Node.h @@ -115,6 +115,8 @@ public: virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const { } virtual void after_children_paint(PaintContext&, PaintPhase) {}; + virtual bool is_box() const { return false; } + bool is_floating() const; bool is_positioned() const; bool is_absolutely_positioned() const;