瀏覽代碼

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.
Timothy Flynn 1 年之前
父節點
當前提交
c4750f6eec
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      Userland/Libraries/LibWeb/Page/EventHandler.cpp

+ 8 - 3
Userland/Libraries/LibWeb/Page/EventHandler.cpp

@@ -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) {