From 994bbcaa7541a3adfcec3d283c6fba5009294f22 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 3 Jul 2025 10:53:01 +0100 Subject: [PATCH] LibWeb/Painting: Don't paint invisible paintables This check technically isn't necessary in `SVGForeignObjectPaintable::paint()` because `PaintableWithLines::paint(context, phase);` does the check already, but I've added it there anyway to save some debugging time if someone does add more code there. :^) --- Libraries/LibWeb/Painting/MarkerPaintable.cpp | 3 +++ .../Painting/SVGForeignObjectPaintable.cpp | 3 +++ .../css/hidden-list-item-markers-ref.html | 2 ++ .../input/css/hidden-list-item-markers.html | 25 +++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 Tests/LibWeb/Ref/expected/css/hidden-list-item-markers-ref.html create mode 100644 Tests/LibWeb/Ref/input/css/hidden-list-item-markers.html diff --git a/Libraries/LibWeb/Painting/MarkerPaintable.cpp b/Libraries/LibWeb/Painting/MarkerPaintable.cpp index b17053edc46..5eb0680f6ef 100644 --- a/Libraries/LibWeb/Painting/MarkerPaintable.cpp +++ b/Libraries/LibWeb/Painting/MarkerPaintable.cpp @@ -32,6 +32,9 @@ constexpr float sin_60_deg = 0.866025403f; void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const { + if (!is_visible()) + return; + if (phase == PaintPhase::Overlay) PaintableBox::paint(context, phase); if (phase != PaintPhase::Foreground) diff --git a/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp b/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp index 5e92358ac1a..ea0fadf5a69 100644 --- a/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp +++ b/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp @@ -33,6 +33,9 @@ TraversalDecision SVGForeignObjectPaintable::hit_test(CSSPixelPoint position, Hi void SVGForeignObjectPaintable::paint(PaintContext& context, PaintPhase phase) const { + if (!is_visible()) + return; + PaintableWithLines::paint(context, phase); } diff --git a/Tests/LibWeb/Ref/expected/css/hidden-list-item-markers-ref.html b/Tests/LibWeb/Ref/expected/css/hidden-list-item-markers-ref.html new file mode 100644 index 00000000000..6670f1bde1e --- /dev/null +++ b/Tests/LibWeb/Ref/expected/css/hidden-list-item-markers-ref.html @@ -0,0 +1,2 @@ + +There should be nothing visible below. diff --git a/Tests/LibWeb/Ref/input/css/hidden-list-item-markers.html b/Tests/LibWeb/Ref/input/css/hidden-list-item-markers.html new file mode 100644 index 00000000000..97beef174ac --- /dev/null +++ b/Tests/LibWeb/Ref/input/css/hidden-list-item-markers.html @@ -0,0 +1,25 @@ + + + +There should be nothing visible below. + + +