Title: [233589] trunk/Source/WebKit
Revision
233589
Author
[email protected]
Date
2018-07-06 13:13:22 -0700 (Fri, 06 Jul 2018)

Log Message

[iOS] WKPDFView should show the Data Detectors sheet when long-pressing a URL that Data Detectors can handle
https://bugs.webkit.org/show_bug.cgi?id=187396
<rdar://problem/41786980>

Reviewed by Dan Bernstein.

If a URL can be presented by Data Detectors, show the Data Detectors sheet instead
of the link sheet. Also implement the optional WKActionSheetAssistantDelegate
method that asks the UI delegate for its data detection context.

* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]):
(-[WKPDFView dataDetectionContextForActionSheetAssistant:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233588 => 233589)


--- trunk/Source/WebKit/ChangeLog	2018-07-06 19:39:42 UTC (rev 233588)
+++ trunk/Source/WebKit/ChangeLog	2018-07-06 20:13:22 UTC (rev 233589)
@@ -1,3 +1,19 @@
+2018-07-06  Andy Estes  <[email protected]>
+
+        [iOS] WKPDFView should show the Data Detectors sheet when long-pressing a URL that Data Detectors can handle
+        https://bugs.webkit.org/show_bug.cgi?id=187396
+        <rdar://problem/41786980>
+
+        Reviewed by Dan Bernstein.
+
+        If a URL can be presented by Data Detectors, show the Data Detectors sheet instead
+        of the link sheet. Also implement the optional WKActionSheetAssistantDelegate
+        method that asks the UI delegate for its data detection context.
+
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]):
+        (-[WKPDFView dataDetectionContextForActionSheetAssistant:]):
+
 2018-07-06  Chris Dumez  <[email protected]>
 
         WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler() should take in a CompletionHandler

Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (233588 => 233589)


--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2018-07-06 19:39:42 UTC (rev 233588)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2018-07-06 20:13:22 UTC (rev 233589)
@@ -32,10 +32,12 @@
 #import "FindClient.h"
 #import "PDFKitSPI.h"
 #import "WKActionSheetAssistant.h"
+#import "WKUIDelegatePrivate.h"
 #import "WKWebViewInternal.h"
 #import "WebPageProxy.h"
 #import "_WKWebViewPrintFormatterInternal.h"
 #import <MobileCoreServices/MobileCoreServices.h>
+#import <WebCore/DataDetection.h>
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/MainThread.h>
@@ -439,7 +441,12 @@
     positionInformation.url = ""
 
     _positionInformation = WTFMove(positionInformation);
-    [_actionSheetAssistant showLinkSheet];
+#if ENABLE(DATA_DETECTION)
+    if (WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation.url))
+        [_actionSheetAssistant showDataDetectorsSheet];
+    else
+#endif
+        [_actionSheetAssistant showLinkSheet];
 }
 
 - (void)pdfHostViewController:(PDFHostViewController *)controller didLongPressURL:(NSURL *)url atLocation:(CGPoint)location withAnnotationRect:(CGRect)annotationRect
@@ -513,6 +520,19 @@
     return page->uiClient().actionsForElement(element, WTFMove(defaultActions));
 }
 
+- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
+{
+    auto webView = _webView.getAutoreleased();
+    if (!webView)
+        return nil;
+
+    id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>(webView.UIDelegate);
+    if (![uiDelegate respondsToSelector:@selector(_dataDetectionContextForWebView:)])
+        return nil;
+
+    return [uiDelegate _dataDetectionContextForWebView:webView];
+}
+
 @end
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to