Cancel DataDetectors menu earlier if we know it can't be presented
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2014 22:16:55 +0000 (22:16 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2014 22:16:55 +0000 (22:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138922
<rdar://problem/18950441>

Reviewed by Beth Dakin.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController willOpenMenu:withEvent:]):
If we end up with a menu with no items, don't change selection or anything.

(-[WKActionMenuController menuNeedsUpdate:]):
Move our call to shouldUseActionsWithContext earlier, to menuNeedsUpdate,
and use a bigger hammer (removeAllItems).

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController prepareForMenu:withEvent:]):
Move our call to shouldUseActionsWithContext earlier, to menuNeedsUpdate,
and use a bigger hammer (removeAllItems).

(-[WebActionMenuController willOpenMenu:withEvent:]):
If we end up with a menu with no items, don't change selection or anything.

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebActionMenuController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

index ad49fa1f863610ccd6c0d2ea48f393a2d4b4c6d7..b48671550327b95466854c9611897835f2da9cb5 100644 (file)
@@ -1,3 +1,19 @@
+2014-11-20  Tim Horton  <timothy_horton@apple.com>
+
+        Cancel DataDetectors menu earlier if we know it can't be presented
+        https://bugs.webkit.org/show_bug.cgi?id=138922
+        <rdar://problem/18950441>
+
+        Reviewed by Beth Dakin.
+
+        * WebView/WebActionMenuController.mm:
+        (-[WebActionMenuController prepareForMenu:withEvent:]):
+        Move our call to shouldUseActionsWithContext earlier, to menuNeedsUpdate,
+        and use a bigger hammer (removeAllItems).
+
+        (-[WebActionMenuController willOpenMenu:withEvent:]):
+        If we end up with a menu with no items, don't change selection or anything.
+
 2014-11-20  Beth Dakin  <bdakin@apple.com>
 
         Invalid message WebPageProxy.DidPerformDictionaryLookup on Google stocks result
index 7850e7cebd0777587dacfd6a27109569ea0cffe8..d1534d89d2407d5d06b56cb5e0daa5d106d79a8d 100644 (file)
@@ -150,6 +150,11 @@ struct DictionaryPopupInfo {
 
     for (NSMenuItem *item in menuItems)
         [actionMenu addItem:item];
+
+    if (_type == WebActionMenuDataDetectedItem && _currentActionContext && ![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
+        [menu cancelTracking];
+        [menu removeAllItems];
+    }
 }
 
 - (BOOL)isMenuForTextContent
@@ -182,12 +187,10 @@ struct DictionaryPopupInfo {
     if (menu != _webView.actionMenu)
         return;
 
-    if (_type == WebActionMenuDataDetectedItem) {
-        if (![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
-            [menu cancelTracking];
-            return;
-        }
+    if (!menu.numberOfItems)
+        return;
 
+    if (_type == WebActionMenuDataDetectedItem) {
         if (menu.numberOfItems == 1)
             [[_webView _selectedOrMainFrame] _clearSelection];
         else
index 676f46d796726a5861c46e6375ce1ae1c760bd24..49bc3191835c62ca4adc9dcc168f46192c3be89d 100644 (file)
@@ -1,3 +1,19 @@
+2014-11-20  Tim Horton  <timothy_horton@apple.com>
+
+        Cancel DataDetectors menu earlier if we know it can't be presented
+        https://bugs.webkit.org/show_bug.cgi?id=138922
+        <rdar://problem/18950441>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/mac/WKActionMenuController.mm:
+        (-[WKActionMenuController willOpenMenu:withEvent:]):
+        If we end up with a menu with no items, don't change selection or anything.
+
+        (-[WKActionMenuController menuNeedsUpdate:]):
+        Move our call to shouldUseActionsWithContext earlier, to menuNeedsUpdate,
+        and use a bigger hammer (removeAllItems).
+
 2014-11-20  Tim Horton  <timothy_horton@apple.com>
 
         Don't use a TextIndicator BounceAndCrossfade transition if the selection highlight is never shown
index 8b622f5cfea3b28254f26f5d094a6776ecf600f8..893c08235e77590427f5b141dffd7f5fa235bb64 100644 (file)
@@ -192,11 +192,10 @@ using namespace WebKit;
     if (menu != _wkView.actionMenu)
         return;
 
+    if (!menu.numberOfItems)
+        return;
+
     if (_type == kWKActionMenuDataDetectedItem) {
-        if (_currentActionContext && ![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
-            [menu cancelTracking];
-            return;
-        }
         if (menu.numberOfItems == 1)
             _page->clearSelection();
         else
@@ -726,6 +725,11 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
 
     if (_state != ActionMenuState::Ready)
         [self _updateActionMenuItems];
+
+    if (_type == kWKActionMenuDataDetectedItem && _currentActionContext && ![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
+        [menu cancelTracking];
+        [menu removeAllItems];
+    }
 }
 
 - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item