LibWeb: Don't assume we hit a layout node when handling mousedown events

Regression from the introduction of CSS pointer-events in
ec43f7a2b0.
This commit is contained in:
Andreas Kling 2021-10-19 12:53:22 +02:00
parent defe4d50ff
commit fcff6b7160

View file

@ -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<DOM::Node> 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);