Changeset 278330 in webkit
- Timestamp:
- Jun 1, 2021, 3:36:13 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/spi/cocoa/RevealSPI.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/mac/MenuUtilities.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/PAL/ChangeLog
r278253 r278330 1 2021-06-01 Dana Estra <destra@apple.com> 2 3 Adopt Reveal for phone numbers 4 https://bugs.webkit.org/show_bug.cgi?id=226383 5 rdar://78482517 6 7 Reviewed by Tim Horton. 8 9 Add declaration for RVItem method initWithURL. 10 11 * pal/spi/cocoa/RevealSPI.h: 12 1 13 2021-05-30 Darin Adler <darin@apple.com> 2 14 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h
r278190 r278330 50 50 - (instancetype)initWithText:(NSString *)text selectedRange:(NSRange)selectedRange NS_DESIGNATED_INITIALIZER; 51 51 - (instancetype)initWithDDResult:(DDScannerResult *)result NS_DESIGNATED_INITIALIZER; 52 - (instancetype)initWithURL:(NSURL *)url rangeInContext:(NSRange)rangeInContext; 52 53 @property (readonly, nonatomic) NSRange highlightRange; 53 54 @end -
trunk/Source/WebKit/ChangeLog
r278320 r278330 1 2021-06-01 Dana Estra <destra@apple.com> 2 3 Adopt Reveal for phone numbers 4 https://bugs.webkit.org/show_bug.cgi?id=226383 5 rdar://78482517 6 7 Reviewed by Tim Horton. 8 9 Manually tested by selecting text containing phone numbers in Safari and viewing dropdown menu. 10 11 Switch to Reveal framework to show a dropdown menu for telephone numbers with more options. 12 13 * Platform/mac/MenuUtilities.mm: 14 (-[WKEmptyPresenterHighlightDelegate revealContext:rectsForItem:]): 15 (WebKit::menuForTelephoneNumber): 16 1 17 2021-06-01 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebKit/Platform/mac/MenuUtilities.mm
r274380 r278330 26 26 #import "config.h" 27 27 #import "MenuUtilities.h" 28 #import <pal/cocoa/RevealSoftLink.h> 28 29 29 30 #if PLATFORM(MAC) … … 40 41 SOFT_LINK_CLASS(TelephonyUtilities, TUCall) 41 42 #endif 43 44 @interface WKEmptyPresenterHighlightDelegate : NSObject <RVPresenterHighlightDelegate> 45 @end 46 47 @implementation WKEmptyPresenterHighlightDelegate 48 49 - (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item 50 { 51 return @[ ]; 52 } 53 54 @end 42 55 43 56 namespace WebKit { … … 95 108 RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber) 96 109 { 97 if (! DataDetectorsLibrary())110 if (!PAL::isRevealFrameworkAvailable() || !PAL::isRevealCoreFrameworkAvailable()) 98 111 return nil; 99 112 100 113 RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]); 101 NSMutableArray *faceTimeItems = [NSMutableArray array]; 102 NSMenuItem *dialItem = nil; 103 104 RetainPtr<DDActionContext> actionContext = adoptNS([allocDDActionContextInstance() init]); 105 [actionContext setAllowedActionUTIs:@[ @"com.apple.dial", @"com.apple.facetime", @"com.apple.facetimeaudio" ]]; 106 107 NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()]; 108 for (NSMenuItem *item in proposedMenuItems) { 109 auto action = actionForMenuItem(item); 110 if ([action.actionUTI hasPrefix:@"com.apple.dial"]) 111 dialItem = item; 112 else if ([action.actionUTI hasPrefix:@"com.apple.facetime"]) 113 [faceTimeItems addObject:item]; 114 } 115 116 if (dialItem) 117 [menu addItem:dialItem]; 118 119 if (faceTimeItems.count) { 120 if ([menu numberOfItems]) 121 [menu addItem:[NSMenuItem separatorItem]]; 122 for (NSMenuItem *item in faceTimeItems) 123 [menu addItem:item]; 124 } 114 auto viewForPresenter = adoptNS([[NSView alloc] init]); 115 auto urlComponents = adoptNS([[NSURLComponents alloc] init]); 116 [urlComponents setScheme:@"tel"]; 117 [urlComponents setPath:telephoneNumber]; 118 auto item = adoptNS([PAL::allocRVItemInstance() initWithURL:[urlComponents URL] rangeInContext:NSMakeRange(0, telephoneNumber.length())]); 119 auto presenter = adoptNS([PAL::allocRVPresenterInstance() init]); 120 auto delegate = adoptNS([[WKEmptyPresenterHighlightDelegate alloc] init]); 121 auto context = adoptNS([PAL::allocRVPresentingContextInstance() initWithPointerLocationInView:NSZeroPoint inView:viewForPresenter.get() highlightDelegate:delegate.get()]); 122 NSArray *proposedMenuItems = [presenter menuItemsForItem:item.get() documentContext:nil presentingContext:context.get() options:nil]; 123 124 [menu setItemArray:proposedMenuItems]; 125 125 126 126 return menu;
Note:
See TracChangeset
for help on using the changeset viewer.