From d43dbe2842603460c9d0a6b3776b3af667315920 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 6 Feb 2024 11:14:32 +0100 Subject: [PATCH] LibWeb: Shift SVG paintable clip rectangle by scroll offset Rectangles should be recorded using absolute coordinates, including the scroll offset. --- .../svg-inside-scroll-container-ref.html | 15 +++++++++ .../Ref/svg-inside-scroll-container.html | 32 +++++++++++++++++++ .../LibWeb/Painting/SVGSVGPaintable.cpp | 4 ++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Ref/reference/svg-inside-scroll-container-ref.html create mode 100644 Tests/LibWeb/Ref/svg-inside-scroll-container.html diff --git a/Tests/LibWeb/Ref/reference/svg-inside-scroll-container-ref.html b/Tests/LibWeb/Ref/reference/svg-inside-scroll-container-ref.html new file mode 100644 index 0000000000..54288b73f6 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/svg-inside-scroll-container-ref.html @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/Tests/LibWeb/Ref/svg-inside-scroll-container.html b/Tests/LibWeb/Ref/svg-inside-scroll-container.html new file mode 100644 index 0000000000..7eb86cd434 --- /dev/null +++ b/Tests/LibWeb/Ref/svg-inside-scroll-container.html @@ -0,0 +1,32 @@ + + + +
+ + + + + + + + + + + + + + + +
+ diff --git a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp index c7354a630c..08dbd6d990 100644 --- a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp @@ -30,7 +30,9 @@ void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase ph if (phase != PaintPhase::Foreground) return; context.recording_painter().save(); - context.recording_painter().add_clip_rect(context.enclosing_device_rect(absolute_rect()).to_type()); + auto clip_rect = absolute_rect(); + clip_rect.translate_by(enclosing_scroll_frame_offset().value_or({})); + context.recording_painter().add_clip_rect(context.enclosing_device_rect(clip_rect).to_type()); } void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase phase) const