From a401a0f8fe9901487bc5df611f207cc265d1cec3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 18 Aug 2021 11:44:05 +0200 Subject: [PATCH] LibWeb: Add fast_is This is used by Layout::Node::containing_block() which is fairly hot. --- Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.h | 5 +++++ Userland/Libraries/LibWeb/Layout/Node.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.h b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.h index e32d283da4a..a85637f4805 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.h +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.h @@ -31,7 +31,12 @@ public: void recompute_selection_states(); private: + virtual bool is_initial_containing_block_box() const override { return true; } + LayoutRange m_selection; }; +template<> +inline bool Node::fast_is() const { return is_initial_containing_block_box(); } + } diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 0dc6edeb7dc..3f0f27a1e60 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -100,6 +100,7 @@ public: virtual bool is_box() const { return false; } virtual bool is_block_box() const { return false; } virtual bool is_text_node() const { return false; } + virtual bool is_initial_containing_block_box() const { return false; } template bool fast_is() const = delete;