From dbe5af3c6f9300d3fbd1d6e269c8330abade9ac6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 5 Feb 2022 19:02:00 +0100 Subject: [PATCH] LibWeb: Keep tree order of sibling stacking contexts with same z-index --- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index bc7945bfa7..1cc1ab4b75 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -22,9 +22,12 @@ StackingContext::StackingContext(Box& box, StackingContext* parent) m_parent->m_children.append(this); // FIXME: Don't sort on every append.. - // FIXME: Apparently this also breaks tree order inside layers quick_sort(m_parent->m_children, [](auto& a, auto& b) { - return a->m_box.computed_values().z_index().value_or(0) < b->m_box.computed_values().z_index().value_or(0); + auto a_z_index = a->m_box.computed_values().z_index().value_or(0); + auto b_z_index = b->m_box.computed_values().z_index().value_or(0); + if (a_z_index == b_z_index) + return a->m_box.is_before(b->m_box); + return a_z_index < b_z_index; }); } }