Title: [278330] trunk/Source
- Revision
- 278330
- Author
- [email protected]
- Date
- 2021-06-01 15:36:13 -0700 (Tue, 01 Jun 2021)
Log Message
Adopt Reveal for phone numbers
https://bugs.webkit.org/show_bug.cgi?id=226383
rdar://78482517
Source/WebCore/PAL:
Patch by Dana Estra <[email protected]> on 2021-06-01
Reviewed by Tim Horton.
Add declaration for RVItem method initWithURL.
* pal/spi/cocoa/RevealSPI.h:
Source/WebKit:
Patch by Dana Estra <[email protected]> on 2021-06-01
Reviewed by Tim Horton.
Manually tested by selecting text containing phone numbers in Safari and viewing dropdown menu.
Switch to Reveal framework to show a dropdown menu for telephone numbers with more options.
* Platform/mac/MenuUtilities.mm:
(-[WKEmptyPresenterHighlightDelegate revealContext:rectsForItem:]):
(WebKit::menuForTelephoneNumber):
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (278329 => 278330)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-06-01 22:03:35 UTC (rev 278329)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-06-01 22:36:13 UTC (rev 278330)
@@ -1,3 +1,15 @@
+2021-06-01 Dana Estra <[email protected]>
+
+ Adopt Reveal for phone numbers
+ https://bugs.webkit.org/show_bug.cgi?id=226383
+ rdar://78482517
+
+ Reviewed by Tim Horton.
+
+ Add declaration for RVItem method initWithURL.
+
+ * pal/spi/cocoa/RevealSPI.h:
+
2021-05-30 Darin Adler <[email protected]>
Remove WTF::Optional synonym for std::optional, using that class template directly instead
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h (278329 => 278330)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h 2021-06-01 22:03:35 UTC (rev 278329)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h 2021-06-01 22:36:13 UTC (rev 278330)
@@ -49,6 +49,7 @@
@interface RVItem : NSObject <NSSecureCoding>
- (instancetype)initWithText:(NSString *)text selectedRange:(NSRange)selectedRange NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithDDResult:(DDScannerResult *)result NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithURL:(NSURL *)url rangeInContext:(NSRange)rangeInContext;
@property (readonly, nonatomic) NSRange highlightRange;
@end
Modified: trunk/Source/WebKit/ChangeLog (278329 => 278330)
--- trunk/Source/WebKit/ChangeLog 2021-06-01 22:03:35 UTC (rev 278329)
+++ trunk/Source/WebKit/ChangeLog 2021-06-01 22:36:13 UTC (rev 278330)
@@ -1,3 +1,19 @@
+2021-06-01 Dana Estra <[email protected]>
+
+ Adopt Reveal for phone numbers
+ https://bugs.webkit.org/show_bug.cgi?id=226383
+ rdar://78482517
+
+ Reviewed by Tim Horton.
+
+ Manually tested by selecting text containing phone numbers in Safari and viewing dropdown menu.
+
+ Switch to Reveal framework to show a dropdown menu for telephone numbers with more options.
+
+ * Platform/mac/MenuUtilities.mm:
+ (-[WKEmptyPresenterHighlightDelegate revealContext:rectsForItem:]):
+ (WebKit::menuForTelephoneNumber):
+
2021-06-01 Chris Dumez <[email protected]>
Unreviewed build fix after r278253.
Modified: trunk/Source/WebKit/Platform/mac/MenuUtilities.mm (278329 => 278330)
--- trunk/Source/WebKit/Platform/mac/MenuUtilities.mm 2021-06-01 22:03:35 UTC (rev 278329)
+++ trunk/Source/WebKit/Platform/mac/MenuUtilities.mm 2021-06-01 22:36:13 UTC (rev 278330)
@@ -25,6 +25,7 @@
#import "config.h"
#import "MenuUtilities.h"
+#import <pal/cocoa/RevealSoftLink.h>
#if PLATFORM(MAC)
@@ -40,6 +41,18 @@
SOFT_LINK_CLASS(TelephonyUtilities, TUCall)
#endif
+@interface WKEmptyPresenterHighlightDelegate : NSObject <RVPresenterHighlightDelegate>
+@end
+
+@implementation WKEmptyPresenterHighlightDelegate
+
+- (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item
+{
+ return @[ ];
+}
+
+@end
+
namespace WebKit {
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
@@ -94,35 +107,22 @@
RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber)
{
- if (!DataDetectorsLibrary())
+ if (!PAL::isRevealFrameworkAvailable() || !PAL::isRevealCoreFrameworkAvailable())
return nil;
RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]);
- NSMutableArray *faceTimeItems = [NSMutableArray array];
- NSMenuItem *dialItem = nil;
+ auto viewForPresenter = adoptNS([[NSView alloc] init]);
+ auto urlComponents = adoptNS([[NSURLComponents alloc] init]);
+ [urlComponents setScheme:@"tel"];
+ [urlComponents setPath:telephoneNumber];
+ auto item = adoptNS([PAL::allocRVItemInstance() initWithURL:[urlComponents URL] rangeInContext:NSMakeRange(0, telephoneNumber.length())]);
+ auto presenter = adoptNS([PAL::allocRVPresenterInstance() init]);
+ auto delegate = adoptNS([[WKEmptyPresenterHighlightDelegate alloc] init]);
+ auto context = adoptNS([PAL::allocRVPresentingContextInstance() initWithPointerLocationInView:NSZeroPoint inView:viewForPresenter.get() highlightDelegate:delegate.get()]);
+ NSArray *proposedMenuItems = [presenter menuItemsForItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
+
+ [menu setItemArray:proposedMenuItems];
- RetainPtr<DDActionContext> actionContext = adoptNS([allocDDActionContextInstance() init]);
- [actionContext setAllowedActionUTIs:@[ @"com.apple.dial", @"com.apple.facetime", @"com.apple.facetimeaudio" ]];
-
- NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()];
- for (NSMenuItem *item in proposedMenuItems) {
- auto action = ""
- if ([action.actionUTI hasPrefix:@"com.apple.dial"])
- dialItem = item;
- else if ([action.actionUTI hasPrefix:@"com.apple.facetime"])
- [faceTimeItems addObject:item];
- }
-
- if (dialItem)
- [menu addItem:dialItem];
-
- if (faceTimeItems.count) {
- if ([menu numberOfItems])
- [menu addItem:[NSMenuItem separatorItem]];
- for (NSMenuItem *item in faceTimeItems)
- [menu addItem:item];
- }
-
return menu;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes