From 349b17cc7aaba8c6cce3aaef26d14a0127f43ff1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 24 Aug 2024 13:56:06 +0200 Subject: [PATCH] LibWeb: Don't paint text fragments with CSS visibility:hidden We *could* even skip creating a paintable for hidden nodes, but that means that dynamic updates to the CSS visibility property would require mutating the paint tree, so let's keep it simple for now. --- Tests/LibWeb/Ref/inline-visibility-hidden.html | 2 ++ Tests/LibWeb/Ref/reference/inline-visibility-hidden-ref.html | 1 + Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 Tests/LibWeb/Ref/inline-visibility-hidden.html create mode 100644 Tests/LibWeb/Ref/reference/inline-visibility-hidden-ref.html diff --git a/Tests/LibWeb/Ref/inline-visibility-hidden.html b/Tests/LibWeb/Ref/inline-visibility-hidden.html new file mode 100644 index 00000000000..6691a724c26 --- /dev/null +++ b/Tests/LibWeb/Ref/inline-visibility-hidden.html @@ -0,0 +1,2 @@ + +hello friends and enemies diff --git a/Tests/LibWeb/Ref/reference/inline-visibility-hidden-ref.html b/Tests/LibWeb/Ref/reference/inline-visibility-hidden-ref.html new file mode 100644 index 00000000000..60a090765ab --- /dev/null +++ b/Tests/LibWeb/Ref/reference/inline-visibility-hidden-ref.html @@ -0,0 +1 @@ +hello friends diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index dcb6f8854e6..67fa0211904 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -605,6 +605,9 @@ void paint_text_decoration(PaintContext& context, TextPaintable const& paintable void paint_text_fragment(PaintContext& context, TextPaintable const& paintable, PaintableFragment const& fragment, PaintPhase phase) { + if (!paintable.is_visible()) + return; + auto& painter = context.display_list_recorder(); if (phase == PaintPhase::Foreground) {