Improve look and feel of combined service menu..
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 01:04:07 +0000 (01:04 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 01:04:07 +0000 (01:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135824
<rdar://problem/17936880>

Reviewed by Tim Horton.
Source/WebCore:

Adding some localizable strings.

* English.lproj/Localizable.strings:

Source/WebKit2:

When showing the combined menu, list the phone numbers first,
grouped under a common header, followed by the entries relative
to the services.

* Platform/mac/MenuUtilities.h:
* Platform/mac/MenuUtilities.mm:
(WebKit::menuItemTitleForTelephoneNumberGroup):
(WebKit::menuItemForTelephoneNumber):
* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::setupServicesMenu):

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

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/mac/MenuUtilities.h
Source/WebKit2/Platform/mac/MenuUtilities.mm
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm

index b4ed872..80438d5 100644 (file)
@@ -1,3 +1,15 @@
+2014-08-11  Enrica Casucci  <enrica@apple.com>
+
+        Improve look and feel of combined service menu..
+        https://bugs.webkit.org/show_bug.cgi?id=135824
+        <rdar://problem/17936880>
+
+        Reviewed by Tim Horton.
+
+        Adding some localizable strings.
+
+        * English.lproj/Localizable.strings:
+
 2014-08-11  Jer Noble  <jer.noble@apple.com>
 
         [iOS] <video> element requests are missing session cookies; sometimes persistant cookies.
index 86e751b..141167e 100644 (file)
 /* Undo action name */
 "Bold (Undo action name)" = "Bold";
 
+/* menu item title for phone number */
+"Call Using iPhone:" = "Call Using iPhone:";
+
 /* menu item for making a telephone call to a telephone number */
 "Call “%@” Using iPhone" = "Call “%@” Using iPhone";
 
index df4cdcc..2dae4a5 100644 (file)
@@ -1,3 +1,22 @@
+2014-08-11  Enrica Casucci  <enrica@apple.com>
+
+        Improve look and feel of combined service menu..
+        https://bugs.webkit.org/show_bug.cgi?id=135824
+        <rdar://problem/17936880>
+
+        Reviewed by Tim Horton.
+        
+        When showing the combined menu, list the phone numbers first,
+        grouped under a common header, followed by the entries relative
+        to the services.
+
+        * Platform/mac/MenuUtilities.h:
+        * Platform/mac/MenuUtilities.mm:
+        (WebKit::menuItemTitleForTelephoneNumberGroup):
+        (WebKit::menuItemForTelephoneNumber):
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::setupServicesMenu):
+
 2014-08-11  Joseph Pecoraro  <pecoraro@apple.com>
 
         Add Private WKPreferences API for developer extras (show inspector)
index 4e3e330..d2d42a7 100644 (file)
@@ -34,6 +34,7 @@ namespace WebKit {
 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumberString);
 NSArray *menuItemsForTelephoneNumber(const String& telephoneNumber);
+NSString *menuItemTitleForTelephoneNumberGroup();
 #endif
 
 } // namespace WebKit
index fc79dbc..3dabc68 100644 (file)
@@ -58,6 +58,11 @@ static NSString *menuItemTitleForTelephoneNumber(const String& telephoneNumber)
     return [NSString stringWithFormat:WEB_UI_STRING("Call “%@” Using iPhone", "menu item for making a telephone call to a telephone number"), formattedPhoneNumberString(telephoneNumber)];
 }
 
+NSString *menuItemTitleForTelephoneNumberGroup()
+{
+    return WEB_UI_STRING("Call Using iPhone:", "menu item title for phone number");
+}
+
 NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber)
 {
     NSArray *proposedMenu = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:nil];
@@ -71,7 +76,7 @@ NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber)
             continue;
 
         if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) {
-            item.title = menuItemTitleForTelephoneNumber(telephoneNumber);
+            item.title = formattedPhoneNumberString(telephoneNumber);
             return item;
         }
     }
index ecc9944..0c7ddab 100644 (file)
@@ -407,12 +407,18 @@ void WebContextMenuProxyMac::setupServicesMenu(const ContextMenuContextData& con
     const Vector<String>& selectedTelephoneNumbers = context.selectedTelephoneNumbers();
     if (!selectedTelephoneNumbers.isEmpty()) {
         if (m_servicesMenu)
-            [m_servicesMenu addItem:[NSMenuItem separatorItem]];
+            [m_servicesMenu insertItem:[NSMenuItem separatorItem] atIndex:0];
         else
             m_servicesMenu = adoptNS([[NSMenu alloc] init]);
+        int itemPosition = 0;
+        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))
-                [m_servicesMenu addItem:item];
+            if (NSMenuItem *item = menuItemForTelephoneNumber(telephoneNumber)) {
+                [item setIndentationLevel:1];
+                [m_servicesMenu insertItem:item atIndex:itemPosition++];
+            }
         }
     }