From 2be47c3d7aa279da273fabafcde86882bb04bad1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 18 Mar 2024 10:25:07 +0100 Subject: [PATCH] LibWeb: Add fast_is() --- Userland/Libraries/LibWeb/Painting/Paintable.h | 4 ++++ Userland/Libraries/LibWeb/Painting/TextPaintable.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index f62cf1dea35..667cb5ededc 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -200,6 +200,7 @@ public: [[nodiscard]] virtual bool is_paintable_with_lines() const { return false; } [[nodiscard]] virtual bool is_inline_paintable() const { return false; } [[nodiscard]] virtual bool is_svg_paintable() const { return false; } + [[nodiscard]] virtual bool is_text_paintable() const { return false; } DOM::Document const& document() const { return layout_node().document(); } DOM::Document& document() { return layout_node().document(); } @@ -256,4 +257,7 @@ inline bool Paintable::fast_is() const { return is_paintable_box() template<> inline bool Paintable::fast_is() const { return is_paintable_with_lines(); } +template<> +inline bool Paintable::fast_is() const { return is_text_paintable(); } + } diff --git a/Userland/Libraries/LibWeb/Painting/TextPaintable.h b/Userland/Libraries/LibWeb/Painting/TextPaintable.h index d67da894ab6..61d20aff2ea 100644 --- a/Userland/Libraries/LibWeb/Painting/TextPaintable.h +++ b/Userland/Libraries/LibWeb/Painting/TextPaintable.h @@ -28,6 +28,8 @@ public: CSSPixels text_decoration_thickness() const { return m_text_decoration_thickness; } private: + virtual bool is_text_paintable() const override { return true; } + explicit TextPaintable(Layout::TextNode const&); CSSPixels m_text_decoration_thickness { 0 };