From 2447b27d973deb7f5b66f853afe176a3ff8d5da3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 14 Oct 2021 23:49:15 +0200 Subject: [PATCH] LibWeb: Implement position:fixed painting at the stacking context level This makes everything within the stacking context stick show up in the correct position. --- Userland/Libraries/LibWeb/Layout/Box.cpp | 4 ---- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index 62a205207b..fd6da0d5b6 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/Userland/Libraries/LibWeb/Layout/Box.cpp @@ -24,10 +24,6 @@ void Box::paint(PaintContext& context, PaintPhase phase) if (!is_visible()) return; - Gfx::PainterStateSaver saver(context.painter()); - if (is_fixed_position()) - context.painter().translate(context.scroll_offset()); - if (phase == PaintPhase::Background) { paint_background(context); paint_box_shadow(context); diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 2a4f59cf71..9a99ff06aa 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -107,6 +107,11 @@ void StackingContext::paint_internal(PaintContext& context) void StackingContext::paint(PaintContext& context) { + Gfx::PainterStateSaver saver(context.painter()); + if (m_box.is_fixed_position()) { + context.painter().translate(context.scroll_offset()); + } + auto opacity = m_box.computed_values().opacity(); if (opacity.has_value() && opacity.value() == 0.0f) return;