diff --git a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp index 457588bb366..9f197028fdd 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp +++ b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, Aliaksandr Kalenik + * Copyright (c) 2023-2025, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ @@ -275,16 +275,19 @@ void DisplayListRecorder::translate(Gfx::IntPoint delta) void DisplayListRecorder::save() { + ++m_save_nesting_level; append(Save {}); } void DisplayListRecorder::save_layer() { + ++m_save_nesting_level; append(SaveLayer {}); } void DisplayListRecorder::restore() { + --m_save_nesting_level; append(Restore {}); } @@ -419,6 +422,8 @@ void DisplayListRecorder::apply_opacity(float opacity) void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) { + // Implementation of this item does saveLayer(), so we need to increment the nesting level. + m_save_nesting_level++; append(ApplyCompositeAndBlendingOperator { .compositing_and_blending_operator = compositing_and_blending_operator }); } diff --git a/Libraries/LibWeb/Painting/DisplayListRecorder.h b/Libraries/LibWeb/Painting/DisplayListRecorder.h index 9a68a22c321..c74b276ece1 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecorder.h +++ b/Libraries/LibWeb/Painting/DisplayListRecorder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, Aliaksandr Kalenik + * Copyright (c) 2023-2025, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ @@ -161,6 +161,8 @@ public: void append(Command&& command); + int m_save_nesting_level { 0 }; + private: Vector> m_scroll_frame_id_stack; DisplayList& m_command_list; diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index 199f1149915..60db19762b5 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -1,13 +1,14 @@ /* * Copyright (c) 2020-2022, Andreas Kling * Copyright (c) 2022, Sam Atkins - * Copyright (c) 2024, Aliaksandr Kalenik + * Copyright (c) 2024-2025, Aliaksandr Kalenik * Copyright (c) 2025, Jelle Raaijmakers * * SPDX-License-Identifier: BSD-2-Clause */ #include +#include #include #include #include @@ -24,9 +25,13 @@ namespace Web::Painting { static void paint_node(Paintable const& paintable, PaintContext& context, PaintPhase phase) { + TemporaryChange save_nesting_level(context.display_list_recorder().m_save_nesting_level, 0); + paintable.before_paint(context, phase); paintable.paint(context, phase); paintable.after_paint(context, phase); + + VERIFY(context.display_list_recorder().m_save_nesting_level == 0); } StackingContext::StackingContext(PaintableBox& paintable, StackingContext* parent, size_t index_in_tree_order)