From fcff6b716042f1c95dad78c41301c44b2c056279 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 19 Oct 2021 12:53:22 +0200 Subject: [PATCH] LibWeb: Don't assume we hit a layout node when handling mousedown events Regression from the introduction of CSS pointer-events in ec43f7a2b0840a97c6d093066750dd28840d9587. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 2544585ec13..17744f14fb4 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -184,19 +184,18 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } NonnullRefPtr document = *m_frame.active_document(); - - // TODO: Allow selecting element behind if one on top has pointer-events set to none. - auto result = layout_root()->hit_test(position, Layout::HitTestType::Exact); - auto pointer_events = result.layout_node->computed_values().pointer_events(); - if (pointer_events == CSS::PointerEvents::None) - return false; - RefPtr node; { + // TODO: Allow selecting element behind if one on top has pointer-events set to none. + auto result = layout_root()->hit_test(position, Layout::HitTestType::Exact); if (!result.layout_node) return false; + auto pointer_events = result.layout_node->computed_values().pointer_events(); + if (pointer_events == CSS::PointerEvents::None) + return false; + node = result.layout_node->dom_node(); document->set_hovered_node(node);