⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 175966 in webkit


Ignore:
Timestamp:
Nov 11, 2014, 12:12:02 PM (12 years ago)
Author:
timothy_horton@apple.com
Message:

DataDetectors' menu items aren't presented in the telephone number menu
https://bugs.webkit.org/show_bug.cgi?id=138602
<rdar://problem/18866308>

Reviewed by Beth Dakin.

We currently round-trip the DataDetectors telephone number NSMenuItems
through the very-lossy WebContextMenuItemData, for no real reason.
We should avoid this so that DataDetectors' actual NSMenuItems are
presented in the final menu, so that they can adjust their items after
providing them to us.

  • Platform/mac/MenuUtilities.h:
  • Platform/mac/MenuUtilities.mm:

(WebKit::menuItemTitleForTelephoneNumber): Deleted.
Stop adjusting the menu item titles, as they come correct now.

(WebKit::menuItemsForTelephoneNumber): Deleted.
(WebKit::menuForTelephoneNumber):
Return a fully-formed menu for the single telephone number case.

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::showTelephoneNumberMenu):
Present the fully-formed menu, without round-tripping through
WebContextMenuItemData, because we do not need to hand the items to
the context menu client (and indeed, were not), and because this
allows us to use the exact items returned by DataDetectors, so they
can keep ahold of the items that we actually present.

  • UIProcess/PageClient.h:
  • UIProcess/mac/PageClientImpl.h:
  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::showPlatformContextMenu):
Add a Mac-only PageClient function for presenting a NSMenu at a
WKView-relative point.

  • English.lproj/Localizable.strings:

Remove a now-unused localized string.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175965 r175966  
     12014-11-11  Tim Horton  <timothy_horton@apple.com>
     2
     3        DataDetectors' menu items aren't presented in the telephone number menu
     4        https://bugs.webkit.org/show_bug.cgi?id=138602
     5        <rdar://problem/18866308>
     6
     7        Reviewed by Beth Dakin.
     8
     9        * English.lproj/Localizable.strings:
     10        Remove a now-unused localized string.
     11
    1122014-11-11  Daniel Bates  <dabates@apple.com>
    213
  • trunk/Source/WebCore/English.lproj/Localizable.strings

    r175962 r175966  
    125125"Call Using iPhone:" = "Call Using iPhone:";
    126126
    127 /* menu item for making a telephone call to a telephone number */
    128 "Call “%@” Using iPhone" = "Call “%@” Using iPhone";
    129 
    130127/* File Upload alert sheet button string to cancel */
    131128"Cancel (file upload action sheet)" = "Cancel";
  • trunk/Source/WebKit2/ChangeLog

    r175964 r175966  
     12014-11-11  Tim Horton  <timothy_horton@apple.com>
     2
     3        DataDetectors' menu items aren't presented in the telephone number menu
     4        https://bugs.webkit.org/show_bug.cgi?id=138602
     5        <rdar://problem/18866308>
     6
     7        Reviewed by Beth Dakin.
     8
     9        We currently round-trip the DataDetectors telephone number NSMenuItems
     10        through the very-lossy WebContextMenuItemData, for no real reason.
     11        We should avoid this so that DataDetectors' actual NSMenuItems are
     12        presented in the final menu, so that they can adjust their items after
     13        providing them to us.
     14
     15        * Platform/mac/MenuUtilities.h:
     16        * Platform/mac/MenuUtilities.mm:
     17        (WebKit::menuItemTitleForTelephoneNumber): Deleted.
     18        Stop adjusting the menu item titles, as they come correct now.
     19
     20        (WebKit::menuItemsForTelephoneNumber): Deleted.
     21        (WebKit::menuForTelephoneNumber):
     22        Return a fully-formed menu for the single telephone number case.
     23
     24        * UIProcess/mac/WebPageProxyMac.mm:
     25        (WebKit::WebPageProxy::showTelephoneNumberMenu):
     26        Present the fully-formed menu, without round-tripping through
     27        WebContextMenuItemData, because we do not need to hand the items to
     28        the context menu client (and indeed, were not), and because this
     29        allows us to use the exact items returned by DataDetectors, so they
     30        can keep ahold of the items that we actually present.
     31
     32        * UIProcess/PageClient.h:
     33        * UIProcess/mac/PageClientImpl.h:
     34        * UIProcess/mac/PageClientImpl.mm:
     35        (WebKit::PageClientImpl::showPlatformContextMenu):
     36        Add a Mac-only PageClient function for presenting a NSMenu at a
     37        WKView-relative point.
     38
    1392014-11-11  Tim Horton  <timothy_horton@apple.com>
    240
  • trunk/Source/WebKit2/Platform/mac/MenuUtilities.h

    r172424 r175966  
    3333
    3434#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    35 NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumberString);
    36 NSArray *menuItemsForTelephoneNumber(const String& telephoneNumber);
     35NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber);
     36RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber);
    3737NSString *menuItemTitleForTelephoneNumberGroup();
    3838#endif
  • trunk/Source/WebKit2/Platform/mac/MenuUtilities.mm

    r172424 r175966  
    5454#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    5555
    56 static NSString *menuItemTitleForTelephoneNumber(const String& telephoneNumber)
    57 {
    58     return [NSString stringWithFormat:WEB_UI_STRING("Call “%@” Using iPhone", "menu item for making a telephone call to a telephone number"), formattedPhoneNumberString(telephoneNumber)];
    59 }
    60 
    6156NSString *menuItemTitleForTelephoneNumberGroup()
    6257{
     
    8580}
    8681
    87 NSArray *menuItemsForTelephoneNumber(const String& telephoneNumber)
     82RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber)
    8883{
    89     NSMutableArray *items = [NSMutableArray array];
     84    RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]);
    9085    NSMutableArray *faceTimeItems = [NSMutableArray array];
    9186    NSMenuItem *dialItem = nil;
     
    10297
    10398        if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) {
    104             item.title = menuItemTitleForTelephoneNumber(telephoneNumber);
    10599            dialItem = item;
    106100            continue;
     
    112106
    113107    if (dialItem)
    114         [items addObject:dialItem];
     108        [menu addItem:dialItem];
    115109
    116110    if (faceTimeItems.count) {
    117         if (items.count)
    118             [items addObject:[NSMenuItem separatorItem]];
    119         [items addObjectsFromArray:faceTimeItems];
     111        if ([menu numberOfItems])
     112            [menu addItem:[NSMenuItem separatorItem]];
     113        for (NSMenuItem *item in faceTimeItems)
     114            [menu addItem:item];
    120115    }
    121116
    122     return items.count ? items : nil;
     117    return menu;
    123118}
    124119#endif
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r175756 r175966  
    238238    virtual ColorSpaceData colorSpace() = 0;
    239239
     240    virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) = 0;
     241
    240242#if USE(APPKIT)
    241243    virtual WKView* wkView() const = 0;
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r175756 r175966  
    189189
    190190    virtual void didPerformActionMenuHitTest(const ActionMenuHitTestResult&, API::Object*) override;
     191    virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
    191192
    192193    WKView *m_wkView;
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r175757 r175966  
    767767}
    768768
     769void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
     770{
     771    [menu popUpMenuPositioningItem:nil atLocation:location inView:m_wkView];
     772}
     773
     774
    769775} // namespace WebKit
    770776
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r175376 r175966  
    644644void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point)
    645645{
    646     NSArray *menuItems = menuItemsForTelephoneNumber(telephoneNumber);
    647 
    648     Vector<WebContextMenuItemData> items;
    649     for (NSMenuItem *item in menuItems) {
    650         RetainPtr<NSMenuItem> retainedItem = item;
    651         std::function<void()> handler = [retainedItem]() {
    652             NSMenuItem *item = retainedItem.get();
    653             [[item target] performSelector:[item action] withObject:item];
    654         };
    655        
    656         items.append(WebContextMenuItemData(ContextMenuItem(item), handler));
    657     }
    658    
    659     ContextMenuContextData contextData(TelephoneNumberContext);
    660     internalShowContextMenu(point, contextData, items, ContextMenuClientEligibility::NotEligibleForClient, nullptr);
     646    RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber);
     647    m_pageClient.showPlatformContextMenu(menu.get(), point);
    661648}
    662649#endif
Note: See TracChangeset for help on using the changeset viewer.