Cannot invoke action menus anymore
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Mar 2015 22:48:07 +0000 (22:48 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Mar 2015 22:48:07 +0000 (22:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142797
<rdar://problem/20032670>

Reviewed by Beth Dakin.

* UIProcess/API/mac/WKView.mm:
Don't process mouse events that would make an action menu; call super
and let AppKit take care of it. We have to duplicate the macro so that
we can avoid calling super for the internal-only methods.
Also, otherMouseMoved is simply not a thing, so remove it.

* WebView/WebHTMLView.mm:
(-[WebHTMLView otherMouseDown:]):
Don't override otherMouseDown: if the event would make an action menu.

* platform/spi/mac/NSMenuSPI.h:
Add additional NSMenu SPI.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/spi/mac/NSMenuSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm

index 8740a1f..3c49638 100644 (file)
@@ -1,3 +1,14 @@
+2015-03-17  Tim Horton  <timothy_horton@apple.com>
+
+        Cannot invoke action menus anymore
+        https://bugs.webkit.org/show_bug.cgi?id=142797
+        <rdar://problem/20032670>
+
+        Reviewed by Beth Dakin.
+
+        * platform/spi/mac/NSMenuSPI.h:
+        Add additional NSMenu SPI.
+
 2015-03-17  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Split fragments on renderer boundary on the fly.
index cee9eb4..757ea4d 100644 (file)
 
 // FIXME: We should just include the appropriate internal headers.
 
+typedef NS_ENUM(NSInteger, NSMenuType) {
+    NSMenuTypeNone = 0,
+    NSMenuTypeContextMenu,
+    NSMenuTypeActionMenu,
+};
+
+@interface NSMenu (Private)
++ (NSMenuType)menuTypeForEvent:(NSEvent *)event;
+@end
+
 @interface NSMenuItem (Private)
 + (QLPreviewMenuItem *)standardQuickLookMenuItem;
 @end
index 22d6984..cad8b9d 100644 (file)
@@ -1,3 +1,15 @@
+2015-03-17  Tim Horton  <timothy_horton@apple.com>
+
+        Cannot invoke action menus anymore
+        https://bugs.webkit.org/show_bug.cgi?id=142797
+        <rdar://problem/20032670>
+
+        Reviewed by Beth Dakin.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView otherMouseDown:]):
+        Don't override otherMouseDown: if the event would make an action menu.
+
 2015-03-16  Ryosuke Niwa  <rniwa@webkit.org>
 
         Enable ES6 classes by default
index e23d6bd..5cc44df 100644 (file)
 #import <WebCore/LegacyWebArchive.h>
 #import <WebCore/MIMETypeRegistry.h>
 #import <WebCore/MainFrame.h>
+#import <WebCore/NSMenuSPI.h>
 #import <WebCore/NSURLFileTypeMappingsSPI.h>
 #import <WebCore/Page.h>
 #import <WebCore/Range.h>
@@ -5387,10 +5388,12 @@ static BOOL writingDirectionKeyBindingsEnabled()
 #if !PLATFORM(IOS)
 - (void)otherMouseDown:(NSEvent *)event
 {
-    if ([event buttonNumber] == 2)
-        [self mouseDown:event];
-    else
+    if ([event buttonNumber] != 2 || [NSMenu menuTypeForEvent:event] == NSMenuTypeActionMenu) {
         [super otherMouseDown:event];
+        return;
+    }
+
+    [self mouseDown:event];
 }
 
 - (void)otherMouseDragged:(NSEvent *)event
index 35be7b2..908b82c 100644 (file)
@@ -1,3 +1,17 @@
+2015-03-17  Tim Horton  <timothy_horton@apple.com>
+
+        Cannot invoke action menus anymore
+        https://bugs.webkit.org/show_bug.cgi?id=142797
+        <rdar://problem/20032670>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/API/mac/WKView.mm:
+        Don't process mouse events that would make an action menu; call super
+        and let AppKit take care of it. We have to duplicate the macro so that
+        we can avoid calling super for the internal-only methods.
+        Also, otherMouseMoved is simply not a thing, so remove it.
+
 2015-03-17  Beth Dakin  <bdakin@apple.com>
 
         DOM mouse events have weird timing for force clickable elements in Safari 8.0.3 on 
index 3adcd23..d9a6f8a 100644 (file)
@@ -91,6 +91,7 @@
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/LookupSPI.h>
 #import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
+#import <WebCore/NSMenuSPI.h>
 #import <WebCore/NSViewSPI.h>
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PlatformScreen.h>
@@ -1176,6 +1177,29 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
             }]; \
             return; \
         } \
+        if ([NSMenu menuTypeForEvent:theEvent] == NSMenuTypeActionMenu) { \
+            [super Selector:theEvent]; \
+            return; \
+        } \
+        NativeWebMouseEvent webEvent(theEvent, self); \
+        _data->_page->handleMouseEvent(webEvent); \
+    }
+#define NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(Selector) \
+    - (void)Selector:(NSEvent *)theEvent \
+    { \
+        if (_data->_ignoresNonWheelEvents) \
+            return; \
+        if (NSTextInputContext *context = [self inputContext]) { \
+            [context handleEvent:theEvent completionHandler:^(BOOL handled) { \
+                if (handled) \
+                    LOG(TextInput, "%s was handled by text input context", String(#Selector).substring(0, String(#Selector).find("Internal")).ascii().data()); \
+                else { \
+                    NativeWebMouseEvent webEvent(theEvent, self); \
+                    _data->_page->handleMouseEvent(webEvent); \
+                } \
+            }]; \
+            return; \
+        } \
         NativeWebMouseEvent webEvent(theEvent, self); \
         _data->_page->handleMouseEvent(webEvent); \
     }
@@ -1189,6 +1213,22 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
             LOG(TextInput, "%s was handled by text input context", String(#Selector).substring(0, String(#Selector).find("Internal")).ascii().data()); \
             return; \
         } \
+        if ([NSMenu menuTypeForEvent:theEvent] == NSMenuTypeActionMenu) { \
+            [super Selector:theEvent]; \
+            return; \
+        } \
+        NativeWebMouseEvent webEvent(theEvent, self); \
+        _data->_page->handleMouseEvent(webEvent); \
+    }
+#define NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(Selector) \
+    - (void)Selector:(NSEvent *)theEvent \
+    { \
+        if (_data->_ignoresNonWheelEvents) \
+            return; \
+        if ([[self inputContext] handleEvent:theEvent]) { \
+            LOG(TextInput, "%s was handled by text input context", String(#Selector).substring(0, String(#Selector).find("Internal")).ascii().data()); \
+            return; \
+        } \
         NativeWebMouseEvent webEvent(theEvent, self); \
         _data->_page->handleMouseEvent(webEvent); \
     }
@@ -1196,18 +1236,18 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
 
 NATIVE_MOUSE_EVENT_HANDLER(mouseEntered)
 NATIVE_MOUSE_EVENT_HANDLER(mouseExited)
-NATIVE_MOUSE_EVENT_HANDLER(mouseMovedInternal)
-NATIVE_MOUSE_EVENT_HANDLER(mouseDownInternal)
-NATIVE_MOUSE_EVENT_HANDLER(mouseUpInternal)
-NATIVE_MOUSE_EVENT_HANDLER(mouseDraggedInternal)
 NATIVE_MOUSE_EVENT_HANDLER(otherMouseDown)
 NATIVE_MOUSE_EVENT_HANDLER(otherMouseDragged)
-NATIVE_MOUSE_EVENT_HANDLER(otherMouseMoved)
 NATIVE_MOUSE_EVENT_HANDLER(otherMouseUp)
 NATIVE_MOUSE_EVENT_HANDLER(rightMouseDown)
 NATIVE_MOUSE_EVENT_HANDLER(rightMouseDragged)
 NATIVE_MOUSE_EVENT_HANDLER(rightMouseUp)
 
+NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseMovedInternal)
+NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDownInternal)
+NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseUpInternal)
+NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
+
 #undef NATIVE_MOUSE_EVENT_HANDLER
 
 - (void)_ensureGestureController