macCatalyst: Should dispatch contextmenu event on right click
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 00:55:02 +0000 (00:55 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 00:55:02 +0000 (00:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203316
<rdar://problem/54617376>

Reviewed by Wenson Hsieh.

Source/WebCore:

macCatalyst does not have ENABLE(CONTEXT_MENUS), because it uses the
iOS-style platform-driven context menu API, but should still dispatch
the contextmenu event on right click, for pages that depend on that.

Separate ENABLE(CONTEXT_MENU_EVENT) out from ENABLE(CONTEXT_MENUS).

In the future, calling preventDefault on the contextmenu event should
block the platform context menu from appearing, but currently they
use entirely different gestures.

* page/EventHandler.cpp:
* page/EventHandler.h:
* replay/UserInputBridge.cpp:
* replay/UserInputBridge.h:

Source/WebKit:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::isContextClick):
(WebKit::handleContextMenuEvent):
(WebKit::WebPage::contextMenuForKeyEvent):
(WebKit::handleMouseEvent):
* WebProcess/WebPage/WebPage.h:

Source/WTF:

* wtf/FeatureDefines.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251517 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/replay/UserInputBridge.cpp
Source/WebCore/replay/UserInputBridge.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h

index cfcd260..72237ab 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-23  Tim Horton  <timothy_horton@apple.com>
+
+        macCatalyst: Should dispatch contextmenu event on right click
+        https://bugs.webkit.org/show_bug.cgi?id=203316
+        <rdar://problem/54617376>
+
+        Reviewed by Wenson Hsieh.
+
+        * wtf/FeatureDefines.h:
+
 2019-10-23  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r251261.
index f9dbd4b..beb643b 100644 (file)
 #define ENABLE_CONTEXT_MENUS 0
 #endif
 
+#if !defined(ENABLE_CONTEXT_MENU_EVENT)
+#if !PLATFORM(MACCATALYST)
+#define ENABLE_CONTEXT_MENU_EVENT 0
+#endif
+#endif
+
 #if !defined(ENABLE_CURSOR_SUPPORT)
 #define ENABLE_CURSOR_SUPPORT 0
 #endif
@@ -422,6 +428,10 @@ the public iOS SDK. See <https://webkit.org/b/179167>. */
 #define ENABLE_CONTEXT_MENUS 1
 #endif
 
+#if !defined(ENABLE_CONTEXT_MENU_EVENT)
+#define ENABLE_CONTEXT_MENU_EVENT 1
+#endif
+
 #if !defined(ENABLE_CSS3_TEXT)
 #define ENABLE_CSS3_TEXT 0
 #endif
index 70e5c0e..25f68cf 100644 (file)
@@ -1,3 +1,26 @@
+2019-10-23  Tim Horton  <timothy_horton@apple.com>
+
+        macCatalyst: Should dispatch contextmenu event on right click
+        https://bugs.webkit.org/show_bug.cgi?id=203316
+        <rdar://problem/54617376>
+
+        Reviewed by Wenson Hsieh.
+
+        macCatalyst does not have ENABLE(CONTEXT_MENUS), because it uses the
+        iOS-style platform-driven context menu API, but should still dispatch
+        the contextmenu event on right click, for pages that depend on that.
+
+        Separate ENABLE(CONTEXT_MENU_EVENT) out from ENABLE(CONTEXT_MENUS).
+
+        In the future, calling preventDefault on the contextmenu event should
+        block the platform context menu from appearing, but currently they
+        use entirely different gestures.
+
+        * page/EventHandler.cpp:
+        * page/EventHandler.h:
+        * replay/UserInputBridge.cpp:
+        * replay/UserInputBridge.h:
+
 2019-10-23  Russell Epstein  <repstein@apple.com>
 
         Unreviewed, rolling out r251469.
index 21cb1f8..09f2f7a 100644 (file)
@@ -2937,7 +2937,7 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent& wheelEv
 #endif
 }
 
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
 {
     Ref<Frame> protectedFrame(m_frame);
@@ -3052,7 +3052,7 @@ bool EventHandler::sendContextMenuEventForKey()
 
     return sendContextMenuEvent(platformMouseEvent);
 }
-#endif // ENABLE(CONTEXT_MENUS)
+#endif // ENABLE(CONTEXT_MENU_EVENT)
 
 void EventHandler::scheduleHoverStateUpdate()
 {
index afb4010..d7c445f 100644 (file)
@@ -248,7 +248,7 @@ public:
     WEBCORE_EXPORT void dispatchSyntheticMouseMove(const PlatformMouseEvent&);
 #endif
 
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
     WEBCORE_EXPORT bool sendContextMenuEvent(const PlatformMouseEvent&);
     WEBCORE_EXPORT bool sendContextMenuEventForKey();
 #endif
index 66e4517..679f8ef 100644 (file)
@@ -45,7 +45,7 @@ UserInputBridge::UserInputBridge(Page& page)
 {
 }
 
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
 bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, Frame& frame, InputSource)
 {
     return frame.eventHandler().sendContextMenuEvent(mouseEvent);
index b9c72eb..7c7594a 100644 (file)
@@ -55,7 +55,7 @@ public:
     UserInputBridge(Page&);
 
     // User input APIs.
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
     WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, Frame&, InputSource = InputSource::User);
 #endif
     WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&, InputSource source = InputSource::User);
index 6291fca..1ff1e47 100644 (file)
@@ -1,3 +1,18 @@
+2019-10-23  Tim Horton  <timothy_horton@apple.com>
+
+        macCatalyst: Should dispatch contextmenu event on right click
+        https://bugs.webkit.org/show_bug.cgi?id=203316
+        <rdar://problem/54617376>
+
+        Reviewed by Wenson Hsieh.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::isContextClick):
+        (WebKit::handleContextMenuEvent):
+        (WebKit::WebPage::contextMenuForKeyEvent):
+        (WebKit::handleMouseEvent):
+        * WebProcess/WebPage/WebPage.h:
+
 2019-10-23  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, a speculative build fix after r251498
index 6f5e73f..d5ecf20 100644 (file)
@@ -2604,10 +2604,10 @@ private:
     const WebEvent* m_previousCurrentEvent;
 };
 
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
 static bool isContextClick(const PlatformMouseEvent& event)
 {
-#if PLATFORM(COCOA)
+#if USE(APPKIT)
     return WebEventFactory::shouldBeHandledAsContextClick(event);
 #else
     return event.button() == WebCore::RightButton;
@@ -2624,20 +2624,27 @@ static bool handleContextMenuEvent(const PlatformMouseEvent& platformMouseEvent,
         frame = result.innerNonSharedNode()->document().frame();
 
     bool handled = page->corePage()->userInputBridge().handleContextMenuEvent(platformMouseEvent, *frame);
+#if ENABLE(CONTEXT_MENUS)
     if (handled)
         page->contextMenu()->show();
-
+#endif
     return handled;
 }
 
 void WebPage::contextMenuForKeyEvent()
 {
+#if ENABLE(CONTEXT_MENUS)
     corePage()->contextMenuController().clearContextMenu();
+#endif
 
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     bool handled = frame.eventHandler().sendContextMenuEventForKey();
+#if ENABLE(CONTEXT_MENUS)
     if (handled)
         contextMenu()->show();
+#else
+    UNUSED_PARAM(handled);
+#endif
 }
 #endif
 
@@ -2657,7 +2664,7 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page)
 #endif
 
             bool handled = page->corePage()->userInputBridge().handleMousePressEvent(platformMouseEvent);
-#if ENABLE(CONTEXT_MENUS)
+#if ENABLE(CONTEXT_MENU_EVENT)
             if (isContextClick(platformMouseEvent))
                 handled = handleContextMenuEvent(platformMouseEvent, page);
 #endif
index 9468d31..e683ec9 100644 (file)
@@ -1367,6 +1367,8 @@ private:
 
 #if ENABLE(CONTEXT_MENUS)
     void contextMenuHidden() { m_isShowingContextMenu = false; }
+#endif
+#if ENABLE(CONTEXT_MENU_EVENT)
     void contextMenuForKeyEvent();
 #endif