Changeset 190102 in webkit


Ignore:
Timestamp:
Sep 21, 2015, 9:27:09 PM (10 years ago)
Author:
timothy_horton@apple.com
Message:

Allow DataDetectors to pre-filter telephone number menu items
https://bugs.webkit.org/show_bug.cgi?id=149444
<rdar://problem/19286320>

Reviewed by Sam Weinig.

Source/WebCore:

  • platform/spi/mac/DataDetectorsSPI.h:

Add some SPI.

Source/WebKit2:

  • Platform/mac/MenuUtilities.mm:

(WebKit::menuItemForTelephoneNumber):
(WebKit::menuForTelephoneNumber):
Let DataDetectors know what kind of items we want, so that they can avoid
some unnecessary work in cases where we were just going to throw away the items anyway.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r190099 r190102  
     12015-09-21  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Allow DataDetectors to pre-filter telephone number menu items
     4        https://bugs.webkit.org/show_bug.cgi?id=149444
     5        <rdar://problem/19286320>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * platform/spi/mac/DataDetectorsSPI.h:
     10        Add some SPI.
     11
    1122015-09-21  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h

    r187043 r190102  
    4747@property (assign) BOOL altMode;
    4848@property (assign) BOOL immediate;
     49
     50@property (copy) NSArray *allowedActionUTIs;
    4951
    5052- (DDActionContext *)contextForView:(NSView *)view altMode:(BOOL)altMode interactionStartedHandler:(void (^)(void))interactionStartedHandler interactionChangedHandler:(void (^)(void))interactionChangedHandler interactionStoppedHandler:(void (^)(void))interactionStoppedHandler;
  • trunk/Source/WebKit2/ChangeLog

    r190095 r190102  
     12015-09-21  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Allow DataDetectors to pre-filter telephone number menu items
     4        https://bugs.webkit.org/show_bug.cgi?id=149444
     5        <rdar://problem/19286320>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * Platform/mac/MenuUtilities.mm:
     10        (WebKit::menuItemForTelephoneNumber):
     11        (WebKit::menuForTelephoneNumber):
     12        Let DataDetectors know what kind of items we want, so that they can avoid
     13        some unnecessary work in cases where we were just going to throw away the items anyway.
     14
    1152015-09-21  Gwang Yoon Hwang  <yoon@igalia.com>
    216
  • trunk/Source/WebKit2/Platform/mac/MenuUtilities.mm

    r184058 r190102  
    5151NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber)
    5252{
    53     NSArray *proposedMenu = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:nil];
    54     for (NSMenuItem *item in proposedMenu) {
     53    RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
     54    [actionContext setAllowedActionUTIs:@[ @"com.apple.dial" ]];
     55
     56    NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()];
     57    for (NSMenuItem *item in proposedMenuItems) {
    5558        NSDictionary *representedObject = item.representedObject;
    5659        if (![representedObject isKindOfClass:[NSDictionary class]])
     
    7679    NSMenuItem *dialItem = nil;
    7780
    78     NSArray *proposedMenu = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:nil];
    79     for (NSMenuItem *item in proposedMenu) {
     81    RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
     82    [actionContext setAllowedActionUTIs:@[ @"com.apple.dial", @"com.apple.facetime", @"com.apple.facetimeaudio" ]];
     83
     84    NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()];
     85    for (NSMenuItem *item in proposedMenuItems) {
    8086        NSDictionary *representedObject = item.representedObject;
    8187        if (![representedObject isKindOfClass:[NSDictionary class]])
     
    8692            continue;
    8793
    88         if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) {
     94        if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"])
    8995            dialItem = item;
    90             continue;
    91         }
    92 
    93         if ([actionObject.actionUTI hasPrefix:@"com.apple.facetime"])
     96        else if ([actionObject.actionUTI hasPrefix:@"com.apple.facetime"])
    9497            [faceTimeItems addObject:item];
    9598    }
Note: See TracChangeset for help on using the changeset viewer.