From c74fc4c171ecedce14eedd504358dd1930fdffa3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 28 Feb 2024 11:57:52 +0100 Subject: [PATCH] LibWeb: Clean previous border radii clips in refresh_clip_state() The list of border radii clips needs to be reset before being populated with new clips that have refreshed positions. Besides fixing painting, this also improves performance because the number of sample/blit commands does not increase as we scroll. --- .../Ref/corner-clip-inside-scrollable.html | 38 +++++++++++++++++++ .../corner-clip-inside-scrollable-ref.html | 27 +++++++++++++ .../Libraries/LibWeb/Painting/ClipFrame.h | 1 + .../LibWeb/Painting/ViewportPaintable.cpp | 1 + 4 files changed, 67 insertions(+) create mode 100644 Tests/LibWeb/Ref/corner-clip-inside-scrollable.html create mode 100644 Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html diff --git a/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html b/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html new file mode 100644 index 0000000000..1cb355961b --- /dev/null +++ b/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html @@ -0,0 +1,38 @@ + + + +
+
+
+
+
+ diff --git a/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html b/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html new file mode 100644 index 0000000000..864eb34af3 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html @@ -0,0 +1,27 @@ + + +
+
+
+
diff --git a/Userland/Libraries/LibWeb/Painting/ClipFrame.h b/Userland/Libraries/LibWeb/Painting/ClipFrame.h index 43e34b70b1..38aa3a5e3f 100644 --- a/Userland/Libraries/LibWeb/Painting/ClipFrame.h +++ b/Userland/Libraries/LibWeb/Painting/ClipFrame.h @@ -28,6 +28,7 @@ struct ClipFrame : public RefCounted { } m_border_radii_clips.append(border_radii_clip); } + void clear_border_radii_clips() { m_border_radii_clips.clear(); } CSSPixelRect rect() const { return m_rect; } void set_rect(CSSPixelRect rect) { m_rect = rect; } diff --git a/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp b/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp index b0e3056bc9..7f92c60376 100644 --- a/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp @@ -143,6 +143,7 @@ void ViewportPaintable::refresh_clip_state() // Start from CSS clip property if it exists. Optional clip_rect = paintable_box.get_clip_rect(); + clip_frame.clear_border_radii_clips(); if (overflow_x != CSS::Overflow::Visible && overflow_y != CSS::Overflow::Visible) { auto overflow_clip_rect = paintable_box.compute_absolute_padding_rect_with_css_transform_applied(); for (auto const* block = &paintable_box.layout_box(); !block->is_viewport(); block = block->containing_block()) {