From 66e424a08432c1df03131a80ac28a3fb2d1d174a Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 20 Oct 2022 01:43:31 +0300 Subject: [PATCH] LibWeb: Fix pointer-events check in hit_test --- Userland/Libraries/LibWeb/Painting/Paintable.h | 2 ++ .../LibWeb/Painting/StackingContext.cpp | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index b9ff0ce360..cb931abe39 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -117,6 +117,8 @@ public: auto const& computed_values() const { return m_layout_node.computed_values(); } + bool visible_for_hit_testing() const { return computed_values().pointer_events() != CSS::PointerEvents::None; } + HTML::BrowsingContext const& browsing_context() const { return m_layout_node.browsing_context(); } HTML::BrowsingContext& browsing_context() { return layout_node().browsing_context(); } diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index d07271d1c2..0dccc21b21 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -379,10 +379,6 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio return {}; } - if (paintable().computed_values().pointer_events() == CSS::PointerEvents::None) { - return {}; - } - // NOTE: Hit testing basically happens in reverse painting order. // https://www.w3.org/TR/CSS22/visuren.html#z-index @@ -393,7 +389,7 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio 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()) + if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; } @@ -413,13 +409,13 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio } return TraversalDecision::Continue; }); - if (result.has_value()) + 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); - if (result.has_value()) + if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; } @@ -438,7 +434,7 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio } return TraversalDecision::Continue; }); - if (result.has_value()) + if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; // 3. the in-flow, non-inline-level, non-positioned descendants. @@ -457,7 +453,7 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio } return TraversalDecision::Continue; }); - if (result.has_value()) + if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; } @@ -468,7 +464,7 @@ Optional StackingContext::hit_test(Gfx::FloatPoint const& positio 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()) + if (result.has_value() && result->paintable->visible_for_hit_testing()) return result; }