LibWeb: Skip anchor activation behavior if the click event was cancelled

This commit is contained in:
Igor Pissolati 2022-04-08 21:48:00 -03:00 committed by Andreas Kling
parent cc411b328c
commit a2bc97a9c2
Notes: sideshowbarker 2024-07-17 21:11:12 +09:00

View file

@ -194,6 +194,12 @@ bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button
node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mouseup, offset.x(), offset.y(), position.x(), position.y())); node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mouseup, offset.x(), offset.y(), position.x(), position.y()));
handled_event = true; handled_event = true;
bool run_activation_behavior = true;
if (node.ptr() == m_mousedown_target && button == GUI::MouseButton::Primary) {
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::click, offset.x(), offset.y(), position.x(), position.y()));
}
if (run_activation_behavior) {
// FIXME: This is ad-hoc and incorrect. The reason this exists is // FIXME: This is ad-hoc and incorrect. The reason this exists is
// because we are missing browsing context navigation: // because we are missing browsing context navigation:
// //
@ -241,9 +247,6 @@ bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button
page->client().page_did_request_context_menu(m_browsing_context.to_top_level_position(position)); page->client().page_did_request_context_menu(m_browsing_context.to_top_level_position(position));
} }
} }
if (node.ptr() == m_mousedown_target && button == GUI::MouseButton::Primary) {
node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::click, offset.x(), offset.y(), position.x(), position.y()));
} }
} }
} }