From 54c3053bc3b0d5719fd928cee8e648d78d54b0eb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 26 Mar 2022 12:33:34 +0100 Subject: [PATCH] LibWeb: Preserve paint state when painting stacking contexts indirectly For layers that require indirect painting (due to opacity, transform, etc.) we create a nested PaintContext. Until now, that PaintContext was created fresh without transferring all the state from the parent PaintContext. --- Userland/Libraries/LibWeb/Painting/PaintContext.h | 10 ++++++++++ Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/PaintContext.h b/Userland/Libraries/LibWeb/Painting/PaintContext.h index 2ca9329c3e..7acbcbc276 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintContext.h +++ b/Userland/Libraries/LibWeb/Painting/PaintContext.h @@ -37,6 +37,16 @@ public: bool has_focus() const { return m_focus; } void set_has_focus(bool focus) { m_focus = focus; } + PaintContext clone() const + { + auto clone = PaintContext(m_painter, m_palette, m_scroll_offset); + clone.m_viewport_rect = m_viewport_rect; + clone.m_should_show_line_box_borders = m_should_show_line_box_borders; + clone.m_focus = m_focus; + clone.m_svg_context = m_svg_context; + return clone; + } + private: Gfx::Painter& m_painter; Palette m_palette; diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 98e42a4556..92151efc7c 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -262,7 +262,7 @@ void StackingContext::paint(PaintContext& context) const return; auto bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); Gfx::Painter painter(bitmap); - PaintContext paint_context(painter, context.palette(), context.scroll_offset()); + auto paint_context = context.clone(); paint_internal(paint_context); auto transform_origin = this->transform_origin();