From 164afdcc59af4e314fb8e2c02a71af44353f043d Mon Sep 17 00:00:00 2001 From: InvalidUsernameException Date: Thu, 29 May 2025 19:57:21 +0200 Subject: [PATCH] LibWeb: Ensure scroll offset is applied to mask-images When recording the display list for a stacking context, the following operations (relevant to this bug) happened: * push a stacking context * as part of that push a None-value to the scroll frame id stack * apply filters * apply masking * paint recursively This meant that mask-images were always recorded without scroll frame id, causing them to be painted without any scroll offset. As a result mask-images would break as soon as the website using them was scrolled. Instead, push to the scroll frame id stack later to solve the problem: * push a stacking context * apply filters * apply masking * push a None-value to the scroll frame id stack * paint recursively --- .../LibWeb/Painting/DisplayListRecorder.cpp | 2 -- Libraries/LibWeb/Painting/StackingContext.cpp | 2 ++ .../mask-image-with-scroll-offset-ref.html | 11 +++++++++++ .../input/mask-image-with-scroll-offset.html | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Ref/expected/mask-image-with-scroll-offset-ref.html create mode 100644 Tests/LibWeb/Ref/input/mask-image-with-scroll-offset.html diff --git a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp index 16e3db62d55..11b225d9d83 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp +++ b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp @@ -310,12 +310,10 @@ void DisplayListRecorder::push_stacking_context(PushStackingContextParams params .matrix = params.transform.matrix, }, .clip_path = params.clip_path }); - m_scroll_frame_id_stack.append({}); } void DisplayListRecorder::pop_stacking_context() { - (void)m_scroll_frame_id_stack.take_last(); append(PopStackingContext {}); } diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index 30ce2dd7909..e89c7085968 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -371,7 +371,9 @@ void StackingContext::paint(PaintContext& context) const } } + context.display_list_recorder().push_scroll_frame_id({}); paint_internal(context); + context.display_list_recorder().pop_scroll_frame_id(); if (!filter.is_empty()) { context.display_list_recorder().restore(); diff --git a/Tests/LibWeb/Ref/expected/mask-image-with-scroll-offset-ref.html b/Tests/LibWeb/Ref/expected/mask-image-with-scroll-offset-ref.html new file mode 100644 index 00000000000..1669f88646d --- /dev/null +++ b/Tests/LibWeb/Ref/expected/mask-image-with-scroll-offset-ref.html @@ -0,0 +1,11 @@ + + +
diff --git a/Tests/LibWeb/Ref/input/mask-image-with-scroll-offset.html b/Tests/LibWeb/Ref/input/mask-image-with-scroll-offset.html new file mode 100644 index 00000000000..720f798a23a --- /dev/null +++ b/Tests/LibWeb/Ref/input/mask-image-with-scroll-offset.html @@ -0,0 +1,18 @@ + + + +
+
+