From 2b55ccf6e5a305d2ae527d455c668668ac474fba Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 9 Dec 2022 19:04:55 +0000 Subject: [PATCH] LibWeb: Actually hit-test child stacking contents with z-index of 0 Discord modals/pop-outs are in a "layerContainer"
with `z-index: 1002`, which then has an immediate child
called "positionLayer" with `z-index: 0`. We only ever hit test child stacking contexts with z-index set to anything but 0 (step 7 and step 1 of the hit test), but not for exactly 0 (step 6). This made it impossible to hit any element inside positionLayer, making pop-ups such as the emojis and GIFs unusable. --- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index b4c0444599..cfcc141be3 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -500,6 +500,16 @@ Optional StackingContext::hit_test(Gfx::FloatPoint position, HitT if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; + // "child stacking contexts with stack level 0" is first in the step, so last here to match reverse order. + for (ssize_t i = m_children.size() - 1; i >= 0; --i) { + auto const& child = *m_children[i]; + if (child.m_box.computed_values().z_index().value_or(0) != 0) + break; + auto result = child.hit_test(transformed_position, type); + if (result.has_value() && result->paintable->visible_for_hit_testing()) + return result; + } + // 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks. if (m_box.children_are_inline() && is(m_box)) { auto result = paintable().hit_test(transformed_position, type);