REGRESSION (r172424): Extra menu header in combined telephone number menu when no...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:42:41 +0000 (22:42 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:42:41 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135854
<rdar://problem/17996339>

Reviewed by Enrica Casucci.

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::setupServicesMenu):
Get all the menu items ahead of time, and only add the shared header
if there are any telephone number menu items.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm

index 7fe25656a9a1f2fab2d94b6e2300c7a655b26ab5..35c39f21ddf665924350226650aad38f887c5bb2 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-12  Tim Horton  <timothy_horton@apple.com>
+
+        REGRESSION (r172424): Extra menu header in combined telephone number menu when no phone paired
+        https://bugs.webkit.org/show_bug.cgi?id=135854
+        <rdar://problem/17996339>
+
+        Reviewed by Enrica Casucci.
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::setupServicesMenu):
+        Get all the menu items ahead of time, and only add the shared header
+        if there are any telephone number menu items.
+
 2014-08-12  Enrica Casucci  <enrica@apple.com>
 
         Crash at com.apple.WebKit.WebContent at com.apple.WebKit: WebKit::expandForGap
index 0c7ddab85d3ace3ce29ad07e7a29ed87a2a07f84..b20f96e5db2ed3fcfc30a9a8d23ca1f5e2c26ae2 100644 (file)
@@ -405,7 +405,15 @@ void WebContextMenuProxyMac::setupServicesMenu(const ContextMenuContextData& con
 
     // Explicitly add a menu item for each telephone number that is in the selection.
     const Vector<String>& selectedTelephoneNumbers = context.selectedTelephoneNumbers();
-    if (!selectedTelephoneNumbers.isEmpty()) {
+    Vector<RetainPtr<NSMenuItem>> telephoneNumberMenuItems;
+    for (auto& telephoneNumber : selectedTelephoneNumbers) {
+        if (NSMenuItem *item = menuItemForTelephoneNumber(telephoneNumber)) {
+            [item setIndentationLevel:1];
+            telephoneNumberMenuItems.append(item);
+        }
+    }
+
+    if (!telephoneNumberMenuItems.isEmpty()) {
         if (m_servicesMenu)
             [m_servicesMenu insertItem:[NSMenuItem separatorItem] atIndex:0];
         else
@@ -414,12 +422,8 @@ void WebContextMenuProxyMac::setupServicesMenu(const ContextMenuContextData& con
         NSMenuItem *groupEntry = [[NSMenuItem alloc] initWithTitle:menuItemTitleForTelephoneNumberGroup() action:nil keyEquivalent:@""];
         [groupEntry setEnabled:NO];
         [m_servicesMenu insertItem:groupEntry atIndex:itemPosition++];
-        for (auto& telephoneNumber : selectedTelephoneNumbers) {
-            if (NSMenuItem *item = menuItemForTelephoneNumber(telephoneNumber)) {
-                [item setIndentationLevel:1];
-                [m_servicesMenu insertItem:item atIndex:itemPosition++];
-            }
-        }
+        for (auto& menuItem : telephoneNumberMenuItems)
+            [m_servicesMenu insertItem:menuItem.get() atIndex:itemPosition++];
     }
 
     // If there is no services menu, then the existing services on the system have changed, so refresh that list of services.