If the action menu hit test times out, a menu with a single separator appears
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2014 23:59:18 +0000 (23:59 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2014 23:59:18 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139320
<rdar://problem/19158331>

Reviewed by Beth Dakin.

* UIProcess/mac/WKActionMenuController.h:
* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController menuNeedsUpdate:]):
(-[WKActionMenuController _defaultMenuItems]):
Add a new "TimedOut" state, which we get into if the sync wait for
didPerformActionMenuHitTest times out. In this case, we'll drop the
separator item and give up on the menu. This way, the menu will never
have just a single separator item at the end of menuNeedsUpdate:.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKActionMenuController.h
Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

index 09a3313..e576b4c 100644 (file)
@@ -1,3 +1,20 @@
+2014-12-05  Tim Horton  <timothy_horton@apple.com>
+
+        If the action menu hit test times out, a menu with a single separator appears
+        https://bugs.webkit.org/show_bug.cgi?id=139320
+        <rdar://problem/19158331>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/mac/WKActionMenuController.h:
+        * UIProcess/mac/WKActionMenuController.mm:
+        (-[WKActionMenuController menuNeedsUpdate:]):
+        (-[WKActionMenuController _defaultMenuItems]):
+        Add a new "TimedOut" state, which we get into if the sync wait for
+        didPerformActionMenuHitTest times out. In this case, we'll drop the
+        separator item and give up on the menu. This way, the menu will never
+        have just a single separator item at the end of menuNeedsUpdate:.
+
 2014-12-05  Mark Lam  <mark.lam@apple.com>
 
         Gardening: speculative build fix for GTK builds.
index 39ef95d..d8ba4ec 100644 (file)
@@ -40,6 +40,7 @@ class WebPageProxy;
 enum class ActionMenuState {
     None = 0,
     Pending,
+    TimedOut,
     Ready
 };
 }
index be9e4ac..d36d13d 100644 (file)
@@ -889,8 +889,11 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
     // FIXME: We need to be able to cancel this if the menu goes away.
     // FIXME: Connection can be null if the process is closed; we should clean up better in that case.
     if (_state == ActionMenuState::Pending) {
-        if (auto* connection = _page->process().connection())
-            connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidPerformActionMenuHitTest>(_page->pageID(), std::chrono::milliseconds(500));
+        if (auto* connection = _page->process().connection()) {
+            bool receivedReply = connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidPerformActionMenuHitTest>(_page->pageID(), std::chrono::milliseconds(500));
+            if (!receivedReply)
+                _state = ActionMenuState::TimedOut;
+        }
     }
 
     if (_state != ActionMenuState::Ready)
@@ -1093,7 +1096,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
     RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
     if (!hitTestResult) {
         _type = kWKActionMenuNone;
-        return _state != ActionMenuState::Ready ? @[ [NSMenuItem separatorItem] ] : @[ ];
+        return _state == ActionMenuState::Pending ? @[ [NSMenuItem separatorItem] ] : @[ ];
     }
 
     String absoluteLinkURL = hitTestResult->absoluteLinkURL();
@@ -1164,7 +1167,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
     }
 
     _type = kWKActionMenuNone;
-    return _state != ActionMenuState::Ready ? @[ [NSMenuItem separatorItem] ] : @[ ];
+    return _state == ActionMenuState::Pending ? @[ [NSMenuItem separatorItem] ] : @[ ];
 }
 
 - (void)_updateActionMenuItems