diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index a649d6b8bf..69f200d325 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -255,8 +255,11 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig 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_from_platform_event(node->realm(), UIEvents::EventNames::click, offset, client_offset, page_offset, button).release_value_but_fixme_should_propagate_errors()); + if (node.ptr() == m_mousedown_target) { + if (button == GUI::MouseButton::Primary) + run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, offset, client_offset, page_offset, button).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, offset, client_offset, page_offset, button).release_value_but_fixme_should_propagate_errors()); } if (run_activation_behavior) { diff --git a/Userland/Libraries/LibWeb/UIEvents/EventNames.h b/Userland/Libraries/LibWeb/UIEvents/EventNames.h index e789f7956d..bd00dd8fff 100644 --- a/Userland/Libraries/LibWeb/UIEvents/EventNames.h +++ b/Userland/Libraries/LibWeb/UIEvents/EventNames.h @@ -14,21 +14,22 @@ namespace Web::UIEvents::EventNames { // FIXME: This is not all of the events -#define ENUMERATE_UI_EVENTS \ - __ENUMERATE_UI_EVENT(auxclick) \ - __ENUMERATE_UI_EVENT(click) \ - __ENUMERATE_UI_EVENT(dblclick) \ - __ENUMERATE_UI_EVENT(keydown) \ - __ENUMERATE_UI_EVENT(keypress) \ - __ENUMERATE_UI_EVENT(keyup) \ - __ENUMERATE_UI_EVENT(mousedown) \ - __ENUMERATE_UI_EVENT(mouseenter) \ - __ENUMERATE_UI_EVENT(mouseleave) \ - __ENUMERATE_UI_EVENT(mousemove) \ - __ENUMERATE_UI_EVENT(mouseout) \ - __ENUMERATE_UI_EVENT(mouseover) \ - __ENUMERATE_UI_EVENT(mouseup) \ - __ENUMERATE_UI_EVENT(resize) \ +#define ENUMERATE_UI_EVENTS \ + __ENUMERATE_UI_EVENT(auxclick) \ + __ENUMERATE_UI_EVENT(click) \ + __ENUMERATE_UI_EVENT(contextmenu) \ + __ENUMERATE_UI_EVENT(dblclick) \ + __ENUMERATE_UI_EVENT(keydown) \ + __ENUMERATE_UI_EVENT(keypress) \ + __ENUMERATE_UI_EVENT(keyup) \ + __ENUMERATE_UI_EVENT(mousedown) \ + __ENUMERATE_UI_EVENT(mouseenter) \ + __ENUMERATE_UI_EVENT(mouseleave) \ + __ENUMERATE_UI_EVENT(mousemove) \ + __ENUMERATE_UI_EVENT(mouseout) \ + __ENUMERATE_UI_EVENT(mouseover) \ + __ENUMERATE_UI_EVENT(mouseup) \ + __ENUMERATE_UI_EVENT(resize) \ __ENUMERATE_UI_EVENT(wheel) #define __ENUMERATE_UI_EVENT(name) extern FlyString name; diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 6e236c5ed3..592955ca50 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -77,7 +77,7 @@ WebIDL::ExceptionOr> MouseEvent::create_from_platfo void MouseEvent::set_event_characteristics() { - if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click, EventNames::dblclick)) { + if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click, EventNames::dblclick, EventNames::contextmenu)) { set_bubbles(true); set_cancelable(true); set_composed(true);