From 8bf0e71c0c0d67d1296e88967724808931381339 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 23 Oct 2022 20:56:42 +0200 Subject: [PATCH] LibWeb: Paint non-positioned stacking contexts with z-index 0 or auto As I understand it, these have to be painted interleaved with positioned descendants in the same z-index category, in tree order. --- .../Libraries/LibWeb/Painting/StackingContext.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 8d50b2183c..9774519316 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -155,17 +155,19 @@ void StackingContext::paint_internal(PaintContext& context) const paint_descendants(context, m_box, StackingContextPaintPhase::Foreground); // Draw positioned descendants with z-index `0` or `auto` in tree order. (step 8) + // NOTE: Non-positioned descendants that establish stacking contexts with z-index `0` or `auto` are also painted here. // FIXME: There's more to this step that we have yet to understand and implement. m_box.paint_box()->for_each_in_subtree_of_type([&](PaintableBox const& paint_box) { - if (!paint_box.layout_box().is_positioned()) - return TraversalDecision::Continue; auto const& z_index = paint_box.computed_values().z_index(); - if (z_index.has_value() && z_index.value() != 0) - return TraversalDecision::Continue; if (auto* child = paint_box.stacking_context()) { - paint_child(child); + if (!z_index.has_value() || z_index.value() == 0) + paint_child(child); return TraversalDecision::SkipChildrenAndContinue; } + if (z_index.has_value() && z_index.value() != 0) + return TraversalDecision::Continue; + if (!paint_box.layout_box().is_positioned()) + return TraversalDecision::Continue; // At this point, `paint_box` is a positioned descendant with z-index: auto // but no stacking context of its own. // FIXME: This is basically duplicating logic found elsewhere in this same function. Find a way to make this more elegant.