LibWeb: Run page activation behavior when skipping context menu events

We partially supported this feature, but not enough for the chrome's
context menu to open. We now propagate the event back to the chrome.
This commit is contained in:
Timothy Flynn 2024-04-25 10:04:11 -04:00 committed by Andreas Kling
parent f6407276f7
commit c4750f6eec
Notes: sideshowbarker 2024-07-17 10:08:28 +09:00

View file

@ -270,10 +270,15 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, CSSPixelPoint screen_p
bool run_activation_behavior = false;
if (node.ptr() == m_mousedown_target) {
if (button == GUI::MouseButton::Primary)
if (button == GUI::MouseButton::Primary) {
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, screen_position, page_offset, client_offset, offset, {}, 1, button, modifiers).release_value_but_fixme_should_propagate_errors());
else if (button == GUI::MouseButton::Secondary && !(modifiers & Mod_Shift)) // Allow the user to bypass custom context menus by holding shift, like Firefox.
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::contextmenu, screen_position, page_offset, client_offset, offset, {}, 1, button, modifiers).release_value_but_fixme_should_propagate_errors());
} else if (button == GUI::MouseButton::Secondary) {
// Allow the user to bypass custom context menus by holding shift, like Firefox.
if ((modifiers & Mod_Shift) == 0)
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::contextmenu, screen_position, page_offset, client_offset, offset, {}, 1, button, modifiers).release_value_but_fixme_should_propagate_errors());
else
run_activation_behavior = true;
}
}
if (run_activation_behavior) {