Title: [261457] trunk/Source
Revision
261457
Author
timothy_hor...@apple.com
Date
2020-05-10 12:28:11 -0700 (Sun, 10 May 2020)

Log Message

Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it
https://bugs.webkit.org/show_bug.cgi?id=211686
<rdar://problem/57941589>

Reviewed by Wenson Hsieh.

Source/WebCore:

* dom/MouseRelatedEvent.h:
* editing/cocoa/DataDetection.h:
* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::canPresentDataDetectorsUIForElement):
(WebCore::DataDetection::shouldCancelDefaultAction): Deleted.
Rename shouldCancelDefaultAction to canPresentDataDetectorsUIForElement.
This bit indicates whether a given element should invoke DD UI instead of
doing its default action, so either name is OK, but it feels better to
have it in the affirmative direction.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):
Determine if tapping on an anchor should invoke DataDetectors UI instead
of performing the default action, and short-circuit if that is possible.

* loader/EmptyClients.h:
* page/ChromeClient.h:

Source/WebKit:

Previously, iOS WebKit had code in handleTap, handleTwoFingerTapAtPoint, and commitPotentialTap,
which introspected the hit element /before/ dispatching the tap (or synthetic click) to the DOM,
short circuiting all normal event handling machinery in order to prevent the default action
and present the Data Detectors UI for the given link.

There's one immediate problem with this, which is that there is no similar code in the direct
click event handler path, which we now use for trackpad/mouse input on iPad. There's also a
secondary problem (which we have not seen in practice), which is that pages cannot preventDefault
to avoid launching the Data Detectors UI on a link, like they could to prevent an ordinary
link from being followed.

In order to resolve both issues and reduce duplication of logic, move the code that introspects
the element and invokes Data Detectors UI from high-level WebKit event dispatch code (where it
doesn't really belong) down to WebCore's default click event handler for anchors, right next to
the code that would ordinarily cause a navigation. This way, no matter how we get here, whether
by synthetic click or real click, we'll invoke the Data Detectors UI.

One alternative considered at length: we could actually let the navigation happen, and instead
handle the switch in navigation policy code, but there are a few reasons that did not seem ideal:
1) We'd need to plumb platform-specific data structures through a ton of FrameLoader code.
2) Clients often block non-HTTP(S) navigations, so in order to keep the feature functional,
   we'd have to disregard the client's policy decision, defeating much of the purpose of making
   use of the navigation mechanism in the first place.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::showDataDetectorsUIForPositionInformation):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::showDataDetectorsUIForPositionInformation):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::showDataDetectorsUIForElement):
Plumb showDataDetectorsUIForPositionInformation from iOS WebKit's ChromeClient
implementation all the way to WKContentView.

* UIProcess/ios/WKActionSheetAssistant.h:
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showDataDetectorsUIForPositionInformation:]):
(-[WKActionSheetAssistant contextMenuInteraction:configurationForMenuAtLocation:]):
(-[WKActionSheetAssistant contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]):
(-[WKActionSheetAssistant showDataDetectorsSheet]): Deleted.
Make it possible to push InteractionInformationAtPosition into WKActionSheetAssistant,
instead of having it always pull a fresh one upon invocation, so that we can use the
position information passed along with the showDataDetectorsUIForPositionInformation message.

(-[WKActionSheetAssistant _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
(-[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:]):
Fix an existing bug where Data Detectors context menus would show extra default actions,
by moving our implementation of the -_contextMenuInteraction:overrideSuggestedActionsForConfiguration:
delegate here, sharing it with WKContentViewInteraction.

In a future patch, we should reconsider having three separate UIContextMenuInteractions.

Also, remove the contextMenuPresentationLocationForActionSheetAssistant: delegate,
since it will be wrong in the case of pushed-in position information, and instead
use the position information's original hit test point.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showDataDetectorsUI]):
(-[WKContentView _showDataDetectorsUIForPositionInformation:]):
(-[WKContentView _actionForLongPressFromPositionInformation:]):
(-[WKContentView _didNotHandleTapAsClick:]):
(-[WKContentView dataDetectionContextForPositionInformation:]):
(-[WKContentView dataDetectionContextForActionSheetAssistant:positionInformation:]):
(-[WKContentView _showDataDetectorsSheet]): Deleted.
(-[WKContentView currentPositionInformation]): Deleted.
(-[WKContentView dataDetectionContextForActionSheetAssistant:]): Deleted.
Instead of exposing an unnecessary -currentPositionInformation getter on WKActionSheetAssistant,
provide it as an argument to the WKActionSheetAssistantDelegate methods that actually need it.

(-[WKContentView contextMenuPresentationLocationForActionSheetAssistant:]): Deleted.
(-[WKContentView _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
Adopt WKActionSheetAssistant's suggestedActions mechanism so we can share code.

* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]):
(-[WKPDFView dataDetectionContextForActionSheetAssistant:positionInformation:]):
(-[WKPDFView dataDetectionContextForActionSheetAssistant:]): Deleted.
Adapt to some WKActionSheetAssistantDelegate changes.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleTap):
(WebKit::WebPage::handleTwoFingerTapAtPoint):
(WebKit::WebPage::commitPotentialTap):
Remove the aforementioned short-circuiting paths for Data Detectors links.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261456 => 261457)


--- trunk/Source/WebCore/ChangeLog	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/ChangeLog	2020-05-10 19:28:11 UTC (rev 261457)
@@ -1,3 +1,29 @@
+2020-05-10  Tim Horton  <timothy_hor...@apple.com>
+
+        Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it
+        https://bugs.webkit.org/show_bug.cgi?id=211686
+        <rdar://problem/57941589>
+
+        Reviewed by Wenson Hsieh.
+
+        * dom/MouseRelatedEvent.h:
+        * editing/cocoa/DataDetection.h:
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::canPresentDataDetectorsUIForElement):
+        (WebCore::DataDetection::shouldCancelDefaultAction): Deleted.
+        Rename shouldCancelDefaultAction to canPresentDataDetectorsUIForElement.
+        This bit indicates whether a given element should invoke DD UI instead of
+        doing its default action, so either name is OK, but it feels better to
+        have it in the affirmative direction.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+        Determine if tapping on an anchor should invoke DataDetectors UI instead
+        of performing the default action, and short-circuit if that is possible.
+
+        * loader/EmptyClients.h:
+        * page/ChromeClient.h:
+
 2020-05-09  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Search field on mayoclinic.org/forms/us-resident-appointment clips the submit button

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.h (261456 => 261457)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -61,7 +61,7 @@
     void setIsSimulated(bool value) { m_isSimulated = value; }
     int pageX() const final;
     int pageY() const final;
-    FloatPoint locationInRootViewCoordinates() const;
+    WEBCORE_EXPORT FloatPoint locationInRootViewCoordinates() const;
     virtual const LayoutPoint& pageLocation() const;
     WEBCORE_EXPORT int x() const;
     WEBCORE_EXPORT int y() const;

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.h (261456 => 261457)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -67,7 +67,7 @@
     WEBCORE_EXPORT static bool canBePresentedByDataDetectors(const URL&);
     WEBCORE_EXPORT static bool isDataDetectorLink(Element&);
     WEBCORE_EXPORT static String dataDetectorIdentifier(Element&);
-    WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element&);
+    WEBCORE_EXPORT static bool canPresentDataDetectorsUIForElement(Element&);
     WEBCORE_EXPORT static bool requiresExtendedContext(Element&);
 #endif
 

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (261456 => 261457)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -183,7 +183,7 @@
     return element.attributeWithoutSynchronization(x_apple_data_detectors_resultAttr);
 }
 
-bool DataDetection::shouldCancelDefaultAction(Element& element)
+bool DataDetection::canPresentDataDetectorsUIForElement(Element& element)
 {
     if (!isDataDetectorLink(element))
         return false;

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (261456 => 261457)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2020-05-10 19:28:11 UTC (rev 261457)
@@ -25,6 +25,8 @@
 #include "HTMLAnchorElement.h"
 
 #include "AdClickAttribution.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "DOMTokenList.h"
 #include "ElementIterator.h"
 #include "EventHandler.h"
@@ -57,6 +59,10 @@
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/StringConcatenateNumbers.h>
 
+#if PLATFORM(COCOA)
+#include "DataDetection.h"
+#endif
+
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLAnchorElement);
@@ -466,6 +472,15 @@
     appendServerMapMousePosition(url, event);
     URL completedURL = document().completeURL(url.toString());
 
+#if ENABLE(DATA_DETECTION) && PLATFORM(IOS_FAMILY)
+    if (DataDetection::isDataDetectorLink(*this) && DataDetection::canPresentDataDetectorsUIForElement(*this)) {
+        if (auto* page = document().page()) {
+            if (page->chrome().client().showDataDetectorsUIForElement(*this, event))
+                return;
+        }
+    }
+#endif
+
     String downloadAttribute;
 #if ENABLE(DOWNLOAD_ATTRIBUTE)
     if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled()) {

Modified: trunk/Source/WebCore/loader/EmptyClients.h (261456 => 261457)


--- trunk/Source/WebCore/loader/EmptyClients.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -178,8 +178,10 @@
     void addOrUpdateScrollingLayer(Node*, PlatformLayer*, PlatformLayer*, const IntSize&, bool, bool) final { }
     void removeScrollingLayer(Node*, PlatformLayer*, PlatformLayer*) final { }
 
-    void webAppOrientationsUpdated() final { };
-    void showPlaybackTargetPicker(bool, RouteSharingPolicy, const String&) final { };
+    void webAppOrientationsUpdated() final { }
+    void showPlaybackTargetPicker(bool, RouteSharingPolicy, const String&) final { }
+
+    bool showDataDetectorsUIForElement(const Element&, const Event&) final { return false; }
 #endif // PLATFORM(IOS_FAMILY)
 
 #if ENABLE(ORIENTATION_EVENTS)

Modified: trunk/Source/WebCore/page/ChromeClient.h (261456 => 261457)


--- trunk/Source/WebCore/page/ChromeClient.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebCore/page/ChromeClient.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -272,6 +272,8 @@
 
     virtual void webAppOrientationsUpdated() = 0;
     virtual void showPlaybackTargetPicker(bool hasVideo, RouteSharingPolicy, const String&) = 0;
+
+    virtual bool showDataDetectorsUIForElement(const Element&, const Event&) = 0;
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)

Modified: trunk/Source/WebKit/ChangeLog (261456 => 261457)


--- trunk/Source/WebKit/ChangeLog	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/ChangeLog	2020-05-10 19:28:11 UTC (rev 261457)
@@ -1,3 +1,101 @@
+2020-05-10  Tim Horton  <timothy_hor...@apple.com>
+
+        Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it
+        https://bugs.webkit.org/show_bug.cgi?id=211686
+        <rdar://problem/57941589>
+
+        Reviewed by Wenson Hsieh.
+
+        Previously, iOS WebKit had code in handleTap, handleTwoFingerTapAtPoint, and commitPotentialTap,
+        which introspected the hit element /before/ dispatching the tap (or synthetic click) to the DOM,
+        short circuiting all normal event handling machinery in order to prevent the default action
+        and present the Data Detectors UI for the given link.
+
+        There's one immediate problem with this, which is that there is no similar code in the direct
+        click event handler path, which we now use for trackpad/mouse input on iPad. There's also a
+        secondary problem (which we have not seen in practice), which is that pages cannot preventDefault
+        to avoid launching the Data Detectors UI on a link, like they could to prevent an ordinary
+        link from being followed.
+
+        In order to resolve both issues and reduce duplication of logic, move the code that introspects
+        the element and invokes Data Detectors UI from high-level WebKit event dispatch code (where it
+        doesn't really belong) down to WebCore's default click event handler for anchors, right next to
+        the code that would ordinarily cause a navigation. This way, no matter how we get here, whether
+        by synthetic click or real click, we'll invoke the Data Detectors UI.
+
+        One alternative considered at length: we could actually let the navigation happen, and instead
+        handle the switch in navigation policy code, but there are a few reasons that did not seem ideal:
+        1) We'd need to plumb platform-specific data structures through a ton of FrameLoader code.
+        2) Clients often block non-HTTP(S) navigations, so in order to keep the feature functional,
+           we'd have to disregard the client's policy decision, defeating much of the purpose of making
+           use of the navigation mechanism in the first place.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::showDataDetectorsUIForPositionInformation):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::showDataDetectorsUIForPositionInformation):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        (WebKit::WebChromeClient::showDataDetectorsUIForElement):
+        Plumb showDataDetectorsUIForPositionInformation from iOS WebKit's ChromeClient
+        implementation all the way to WKContentView.
+
+        * UIProcess/ios/WKActionSheetAssistant.h:
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant showDataDetectorsUIForPositionInformation:]):
+        (-[WKActionSheetAssistant contextMenuInteraction:configurationForMenuAtLocation:]):
+        (-[WKActionSheetAssistant contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]):
+        (-[WKActionSheetAssistant showDataDetectorsSheet]): Deleted.
+        Make it possible to push InteractionInformationAtPosition into WKActionSheetAssistant,
+        instead of having it always pull a fresh one upon invocation, so that we can use the
+        position information passed along with the showDataDetectorsUIForPositionInformation message.
+
+        (-[WKActionSheetAssistant _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
+        (-[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:]):
+        Fix an existing bug where Data Detectors context menus would show extra default actions,
+        by moving our implementation of the -_contextMenuInteraction:overrideSuggestedActionsForConfiguration:
+        delegate here, sharing it with WKContentViewInteraction.
+
+        In a future patch, we should reconsider having three separate UIContextMenuInteractions.
+
+        Also, remove the contextMenuPresentationLocationForActionSheetAssistant: delegate,
+        since it will be wrong in the case of pushed-in position information, and instead
+        use the position information's original hit test point.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _showDataDetectorsUI]):
+        (-[WKContentView _showDataDetectorsUIForPositionInformation:]):
+        (-[WKContentView _actionForLongPressFromPositionInformation:]):
+        (-[WKContentView _didNotHandleTapAsClick:]):
+        (-[WKContentView dataDetectionContextForPositionInformation:]):
+        (-[WKContentView dataDetectionContextForActionSheetAssistant:positionInformation:]):
+        (-[WKContentView _showDataDetectorsSheet]): Deleted.
+        (-[WKContentView currentPositionInformation]): Deleted.
+        (-[WKContentView dataDetectionContextForActionSheetAssistant:]): Deleted.
+        Instead of exposing an unnecessary -currentPositionInformation getter on WKActionSheetAssistant,
+        provide it as an argument to the WKActionSheetAssistantDelegate methods that actually need it.
+
+        (-[WKContentView contextMenuPresentationLocationForActionSheetAssistant:]): Deleted.
+        (-[WKContentView _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
+        Adopt WKActionSheetAssistant's suggestedActions mechanism so we can share code.
+
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]):
+        (-[WKPDFView dataDetectionContextForActionSheetAssistant:positionInformation:]):
+        (-[WKPDFView dataDetectionContextForActionSheetAssistant:]): Deleted.
+        Adapt to some WKActionSheetAssistantDelegate changes.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleTap):
+        (WebKit::WebPage::handleTwoFingerTapAtPoint):
+        (WebKit::WebPage::commitPotentialTap):
+        Remove the aforementioned short-circuiting paths for Data Detectors links.
 2020-05-09  David Kilzer  <ddkil...@apple.com>
 
         Attempt #2 to fix internal iOS build

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -412,6 +412,7 @@
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;
     virtual void saveImageToLibrary(Ref<WebCore::SharedBuffer>&&) = 0;
     virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) = 0;
+    virtual void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&) = 0;
     virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0;
     virtual void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel) = 0;
     virtual double minimumZoomScale() const = 0;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -819,6 +819,7 @@
     void updateSelectionWithDelta(int64_t locationDelta, int64_t lengthDelta, CompletionHandler<void()>&&);
     void requestDocumentEditingContext(WebKit::DocumentEditingContextRequest, CompletionHandler<void(WebKit::DocumentEditingContext)>&&);
     void generateSyntheticEditingCommand(SyntheticEditingCommandType);
+    void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&);
 #if ENABLE(DRAG_SUPPORT)
     void didHandleDragStartRequest(bool started);
     void didHandleAdditionalDragItemsRequest(bool added);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-05-10 19:28:11 UTC (rev 261457)
@@ -426,6 +426,8 @@
 
     UpdateStringForFind(String findString)
     HandleAutocorrectionContext(struct WebKit::WebAutocorrectionContext context)
+
+    ShowDataDetectorsUIForPositionInformation(struct WebKit::InteractionInformationAtPosition information)
 #endif
 
     DidChangeInspectorFrontendCount(uint64_t count)

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -168,6 +168,7 @@
     void positionInformationDidChange(const InteractionInformationAtPosition&) override;
     void saveImageToLibrary(Ref<WebCore::SharedBuffer>&&) override;
     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) override;
+    void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&) override;
 
     bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, const FrameInfoData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
     bool showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override;

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -947,6 +947,11 @@
     notImplemented();
 }
 
+void PageClientImpl::showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition& positionInformation)
+{
+    [m_contentView _showDataDetectorsUIForPositionInformation:positionInformation];
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -36,6 +36,7 @@
 struct InteractionInformationAtPosition;
 }
 
+@class UIMenuElement;
 @class UITargetedPreview;
 @class WKActionSheetAssistant;
 @class _WKActivatedElementInfo;
@@ -60,10 +61,9 @@
 - (CGRect)unoccludedWindowBoundsForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element;
 - (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant;
-- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
+- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation;
 - (NSString *)selectedTextForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant getAlternateURLForImage:(UIImage *)image completion:(void (^)(NSURL *alternateURL, NSDictionary *userInfo))completion;
-- (CGPoint)contextMenuPresentationLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 #if USE(UICONTEXTMENU)
 - (UITargetedPreview *)createTargetedContextMenuHintForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 - (void)removeContextMenuViewIfPossibleForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
@@ -82,7 +82,7 @@
 - (id)initWithView:(UIView *)view;
 - (void)showLinkSheet;
 - (void)showImageSheet;
-- (void)showDataDetectorsSheet;
+- (void)showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation;
 - (void)cleanupSheet;
 - (void)updateSheetPosition;
 - (RetainPtr<NSArray<_WKElementAction *>>)defaultActionsForLinkSheet:(_WKActivatedElementInfo *)elementInfo;
@@ -90,7 +90,7 @@
 - (BOOL)isShowingSheet;
 - (void)interactionDidStartWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)information;
 - (NSArray *)currentAvailableActionTitles;
-- (Optional<WebKit::InteractionInformationAtPosition>)currentPositionInformation;
+- (NSArray<UIMenuElement *> *)suggestedActionsForContextMenuWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation;
 @end
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -660,14 +660,13 @@
 }
 #endif
 
-- (void)showDataDetectorsSheet
+- (void)showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
 #if ENABLE(DATA_DETECTION)
     if (!_delegate)
         return;
 
-    if (![self synchronouslyRetrievePositionInformation])
-        return;
+    _positionInformation = positionInformation;
 
     if (!WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation->url))
         return;
@@ -680,8 +679,8 @@
     NSDictionary *context = nil;
     NSString *textAtSelection = nil;
 
-    if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
-        context = [_delegate dataDetectionContextForActionSheetAssistant:self];
+    if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:positionInformation:)])
+        context = [_delegate dataDetectionContextForActionSheetAssistant:self positionInformation:*_positionInformation];
     if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
         textAtSelection = [_delegate selectedTextForActionSheetAssistant:self];
 
@@ -696,15 +695,10 @@
     if ([dataDetectorsActions count] == 0)
         return;
     
-#if ENABLE(DATA_DETECTION) && USE(UICONTEXTMENU) && HAVE(UICONTEXTMENU_LOCATION)
-    auto delegate = _delegate.get();
-    if ([delegate respondsToSelector:@selector(contextMenuPresentationLocationForActionSheetAssistant:)]) {
-        [self ensureContextMenuInteraction];
-        [_dataDetectorContextMenuInteraction _presentMenuAtLocation:[delegate contextMenuPresentationLocationForActionSheetAssistant:self]];
-        return;
-    }
-#endif
-
+#if USE(UICONTEXTMENU) && HAVE(UICONTEXTMENU_LOCATION)
+    [self ensureContextMenuInteraction];
+    [_dataDetectorContextMenuInteraction _presentMenuAtLocation:_positionInformation->request.point];
+#else
     NSMutableArray *elementActions = [NSMutableArray array];
     for (NSUInteger actionNumber = 0; actionNumber < [dataDetectorsActions count]; actionNumber++) {
         DDAction *action = "" objectAtIndex:actionNumber];
@@ -723,6 +717,7 @@
     if (![_interactionSheet presentSheet:WKActionSheetPresentAtTouchLocation])
         [self cleanupSheet];
 #endif
+#endif // ENABLE(DATA_DETECTION)
 }
 
 #if USE(UICONTEXTMENU) && ENABLE(DATA_DETECTION)
@@ -732,8 +727,8 @@
     NSDictionary *context = nil;
     NSString *textAtSelection = nil;
 
-    if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
-        context = [_delegate dataDetectionContextForActionSheetAssistant:self];
+    if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:positionInformation:)])
+        context = [_delegate dataDetectionContextForActionSheetAssistant:self positionInformation:*_positionInformation];
     if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
         textAtSelection = [_delegate selectedTextForActionSheetAssistant:self];
 
@@ -740,7 +735,6 @@
     NSDictionary *newContext = nil;
     DDResultRef ddResult = [controller resultForURL:_positionInformation->url identifier:_positionInformation->dataDetectorIdentifier selectedText:textAtSelection results:_positionInformation->dataDetectorResults.get() context:context extendedContext:&newContext];
 
-
     CGRect sourceRect;
     if (_positionInformation->isLink)
         sourceRect = _positionInformation->linkIndicator.textBoundingRectInRootViewCoordinates;
@@ -758,13 +752,11 @@
 - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration
 {
     auto delegate = _delegate.get();
-    CGPoint center = CGPointZero;
+    CGPoint center = _positionInformation->request.point;
     
     if ([delegate respondsToSelector:@selector(createTargetedContextMenuHintForActionSheetAssistant:)])
         return [delegate createTargetedContextMenuHintForActionSheetAssistant:self];
     
-    if ([delegate respondsToSelector:@selector(contextMenuPresentationLocationForActionSheetAssistant:)])
-        center = [delegate contextMenuPresentationLocationForActionSheetAssistant:self];
     RetainPtr<UIPreviewParameters> unusedPreviewParameters = adoptNS([[UIPreviewParameters alloc] init]);
     RetainPtr<UIPreviewTarget> previewTarget = adoptNS([[UIPreviewTarget alloc] initWithContainer:_view.getAutoreleased() center:center]);
     RetainPtr<UITargetedPreview> preview = adoptNS([[UITargetedPreview alloc] initWithView:_view.getAutoreleased() parameters:unusedPreviewParameters.get() target:previewTarget.get()]);
@@ -784,6 +776,34 @@
         [self removeContextMenuInteraction];
     }];
 }
+
+static NSArray<UIMenuElement *> *menuElementsFromDefaultActions(RetainPtr<NSArray> defaultElementActions, RetainPtr<_WKActivatedElementInfo> elementInfo)
+{
+    if (![defaultElementActions count])
+        return nil;
+
+    auto actions = [NSMutableArray arrayWithCapacity:[defaultElementActions count]];
+    for (_WKElementAction *elementAction in defaultElementActions.get())
+        [actions addObject:[elementAction uiActionForElementInfo:elementInfo.get()]];
+
+    return actions;
+}
+
+- (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
+{
+    if (!_positionInformation)
+        return nil;
+    return [self suggestedActionsForContextMenuWithPositionInformation:*_positionInformation];
+}
+
+- (NSArray<UIMenuElement *> *)suggestedActionsForContextMenuWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
+{
+    auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithInteractionInformationAtPosition:positionInformation userInfo:nil]);
+    RetainPtr<NSArray<_WKElementAction *>> defaultActionsFromAssistant = positionInformation.isLink ? [self defaultActionsForLinkSheet:elementInfo.get()] : [self defaultActionsForImageSheet:elementInfo.get()];
+    return menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo);
+
+}
+
 #endif
 
 - (void)cleanupSheet

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -530,7 +530,8 @@
 - (void)_accessibilityClearSelection;
 - (WKFormInputSession *)_formInputSession;
 - (void)_didChangeWebViewEditability;
-- (NSDictionary *)dataDetectionContextForPositionInformation:(WebKit::InteractionInformationAtPosition)positionInformation;
+- (NSDictionary *)dataDetectionContextForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation;
+- (void)_showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation;
 
 - (void)willFinishIgnoringCalloutBarFadeAfterPerformingAction;
 
@@ -549,7 +550,6 @@
 
 - (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect originIdentifier:(const String&)originIdentifier completionHandler:(CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&)completionHandler;
 
-@property (nonatomic, readonly) WebKit::InteractionInformationAtPosition currentPositionInformation;
 - (void)doAfterPositionInformationUpdate:(void (^)(WebKit::InteractionInformationAtPosition))action forRequest:(WebKit::InteractionInformationRequest)request;
 - (BOOL)ensurePositionInformationIsUpToDate:(WebKit::InteractionInformationRequest)request;
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -2148,11 +2148,16 @@
     [_actionSheetAssistant showLinkSheet];
 }
 
-- (void)_showDataDetectorsSheet
+- (void)_showDataDetectorsUI
 {
-    [_actionSheetAssistant showDataDetectorsSheet];
+    [self _showDataDetectorsUIForPositionInformation:_positionInformation];
 }
 
+- (void)_showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
+{
+    [_actionSheetAssistant showDataDetectorsUIForPositionInformation:positionInformation];
+}
+
 - (SEL)_actionForLongPressFromPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
     if (!self.webView.configuration._longPressActionsEnabled)
@@ -2167,7 +2172,7 @@
     if (positionInformation.isLink) {
 #if ENABLE(DATA_DETECTION)
         if (WebCore::DataDetection::canBePresentedByDataDetectors(positionInformation.url))
-            return @selector(_showDataDetectorsSheet);
+            return @selector(_showDataDetectorsUI);
 #endif
         return @selector(_showLinkSheet);
     }
@@ -2182,11 +2187,6 @@
     return [self _actionForLongPressFromPositionInformation:_positionInformation];
 }
 
-- (WebKit::InteractionInformationAtPosition)currentPositionInformation
-{
-    return _positionInformation;
-}
-
 - (void)doAfterPositionInformationUpdate:(void (^)(WebKit::InteractionInformationAtPosition))action forRequest:(WebKit::InteractionInformationRequest)request
 {
     if ([self _currentPositionInformationIsValidForRequest:request]) {
@@ -2723,15 +2723,6 @@
 {
     [self _resetInputViewDeferral];
 
-    // FIXME: we should also take into account whether or not the UI delegate
-    // has handled this notification.
-#if ENABLE(DATA_DETECTION)
-    if (_hasValidPositionInformation && point == _positionInformation.request.point && _positionInformation.isDataDetectorLink) {
-        [self _showDataDetectorsSheet];
-        return;
-    }
-#endif
-
     if (!_isDoubleTapPending)
         return;
 
@@ -6904,7 +6895,7 @@
     _page->stopInteraction();
 }
 
-- (NSDictionary *)dataDetectionContextForPositionInformation:(WebKit::InteractionInformationAtPosition)positionInformation
+- (NSDictionary *)dataDetectionContextForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
     RetainPtr<NSMutableDictionary> context;
     id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
@@ -6933,9 +6924,9 @@
 #endif
 }
 
-- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
+- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
-    return [self dataDetectionContextForPositionInformation:assistant.currentPositionInformation.valueOr(_positionInformation)];
+    return [self dataDetectionContextForPositionInformation:positionInformation];
 }
 
 - (NSString *)selectedTextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
@@ -6954,11 +6945,6 @@
         completion(nil, nil);
 }
 
-- (CGPoint)contextMenuPresentationLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
-{
-    return [self lastInteractionLocation];
-}
-
 #if USE(UICONTEXTMENU)
 
 - (UITargetedPreview *)createTargetedContextMenuHintForActionSheetAssistant:(WKActionSheetAssistant *)assistant
@@ -9211,13 +9197,11 @@
 
 - (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
 {
-    if (_contextMenuActionProviderDelegateNeedsOverride) {
-        auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithInteractionInformationAtPosition:_positionInformation userInfo:nil]);
-        RetainPtr<NSArray<_WKElementAction *>> defaultActionsFromAssistant = _positionInformation.isLink ? [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()] : [_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()];
-        return menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo);
-    }
     // If we're here we're in the legacy path, which ignores the suggested actions anyway.
-    return nil;
+    if (!_contextMenuActionProviderDelegateNeedsOverride)
+        return nil;
+
+    return [_actionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:_positionInformation];
 }
 
 - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration

Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -485,12 +485,15 @@
     positionInformation.url = ""
 
     _positionInformation = WTFMove(positionInformation);
+
 #if ENABLE(DATA_DETECTION)
-    if (WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation.url))
-        [_actionSheetAssistant showDataDetectorsSheet];
-    else
+    if (WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation.url)) {
+        [_actionSheetAssistant showDataDetectorsUIForPositionInformation:positionInformation];
+        return;
+    }
 #endif
-        [_actionSheetAssistant showLinkSheet];
+
+    [_actionSheetAssistant showLinkSheet];
 }
 
 - (void)pdfHostViewController:(PDFHostViewController *)controller didLongPressURL:(NSURL *)url atLocation:(CGPoint)location withAnnotationRect:(CGRect)annotationRect
@@ -582,7 +585,7 @@
     return page->uiClient().actionsForElement(element, WTFMove(defaultActions));
 }
 
-- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
+- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
     auto webView = _webView.getAutoreleased();
     if (!webView)

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (261456 => 261457)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -1621,6 +1621,12 @@
     WebCore::setDeviceHasAGXCompilerServiceForTesting();
 }
 
+void WebPageProxy::showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition& positionInfo)
+{
+    pageClient().showDataDetectorsUIForPositionInformation(positionInfo);
+}
+
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (261456 => 261457)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -185,6 +185,8 @@
     void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
 
     bool shouldUseMouseEventForSelection(const WebCore::PlatformMouseEvent&) final;
+
+    bool showDataDetectorsUIForElement(const WebCore::Element&, const WebCore::Event&) final;
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (261456 => 261457)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -30,6 +30,8 @@
 
 #import "DrawingArea.h"
 #import "EditableImageControllerMessages.h"
+#import "InteractionInformationAtPosition.h"
+#import "InteractionInformationRequest.h"
 #import "UIKitSPI.h"
 #import "WebCoreArgumentCoders.h"
 #import "WebFrame.h"
@@ -39,6 +41,7 @@
 #import <WebCore/AudioSession.h>
 #import <WebCore/ContentChangeObserver.h>
 #import <WebCore/Icon.h>
+#import <WebCore/MouseEvent.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/PlatformMouseEvent.h>
 #import <wtf/RefPtr.h>
@@ -193,6 +196,18 @@
 #endif
 }
 
+bool WebChromeClient::showDataDetectorsUIForElement(const Element& element, const Event& event)
+{
+    if (!event.isMouseEvent())
+        return false;
+
+    // FIXME: Ideally, we would be able to generate InteractionInformationAtPosition without re-hit-testing the element.
+    auto& mouseEvent = downcast<MouseEvent>(event);
+    auto positionInformation = m_page.positionInformation(InteractionInformationRequest { roundedIntPoint(mouseEvent.locationInRootViewCoordinates()) });
+    m_page.send(Messages::WebPageProxy::ShowDataDetectorsUIForPositionInformation(positionInformation));
+    return true;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (261456 => 261457)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -1292,6 +1292,9 @@
     // These include layout overflow for overflow:visible elements, but exclude borders.
     static WebCore::IntRect absoluteInteractionBoundsForElement(const WebCore::Element&);
     static WebCore::IntRect rootViewInteractionBoundsForElement(const WebCore::Element&);
+
+    InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&);
+    
 #endif // PLATFORM(IOS_FAMILY)
 
 #if USE(QUICK_LOOK)
@@ -1368,7 +1371,6 @@
     void dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch, const WebCore::IntPoint&);
 
     void sendPositionInformation(InteractionInformationAtPosition&&);
-    InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&);
     RefPtr<ShareableBitmap> shareableBitmapSnapshotForNode(WebCore::Element&);
     WebAutocorrectionContext autocorrectionContext();
     bool applyAutocorrectionInternal(const String& correction, const String& originalText);

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (261456 => 261457)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-10 19:28:11 UTC (rev 261457)
@@ -869,13 +869,6 @@
 
     if (!frameRespondingToClick || lastLayerTreeTransactionId < WebFrame::fromCoreFrame(*frameRespondingToClick)->firstLayerTreeTransactionIDAfterDidCommitLoad())
         send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
-#if ENABLE(DATA_DETECTION)
-    else if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
-        InteractionInformationRequest request(adjustedIntPoint);
-        requestPositionInformation(request);
-        send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
-    }
-#endif
     else
         handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers);
 }
@@ -1077,14 +1070,7 @@
         return;
     }
     sendTapHighlightForNodeIfNecessary(requestID, nodeRespondingToClick);
-#if ENABLE(DATA_DETECTION)
-    if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
-        InteractionInformationRequest request(roundedIntPoint(adjustedPoint));
-        requestPositionInformation(request);
-        send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(adjustedPoint)));
-    } else
-#endif
-        completeSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap);
+    completeSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap);
 }
 
 void WebPage::handleStylusSingleTapAtPoint(const WebCore::IntPoint& point, uint64_t requestID)
@@ -1168,16 +1154,9 @@
         return;
     }
 
-    if (m_potentialTapNode == nodeRespondingToClick) {
-#if ENABLE(DATA_DETECTION)
-        if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
-            InteractionInformationRequest request(roundedIntPoint(m_potentialTapLocation));
-            requestPositionInformation(request);
-            commitPotentialTapFailed();
-        } else
-#endif
-            handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, pointerId);
-    } else
+    if (m_potentialTapNode == nodeRespondingToClick)
+        handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, pointerId);
+    else
         commitPotentialTapFailed();
 
     m_potentialTapNode = nullptr;

Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (261456 => 261457)


--- trunk/Source/WebKitLegacy/ios/ChangeLog	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog	2020-05-10 19:28:11 UTC (rev 261457)
@@ -1,3 +1,13 @@
+2020-05-10  Tim Horton  <timothy_hor...@apple.com>
+
+        Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it
+        https://bugs.webkit.org/show_bug.cgi?id=211686
+        <rdar://problem/57941589>
+
+        Reviewed by Wenson Hsieh.
+
+        * WebCoreSupport/WebChromeClientIOS.h:
+
 2020-04-11  Darin Adler  <da...@apple.com>
 
         Stop using live ranges in functions that return range of the selection

Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h (261456 => 261457)


--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h	2020-05-10 10:17:33 UTC (rev 261456)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h	2020-05-10 19:28:11 UTC (rev 261457)
@@ -97,6 +97,8 @@
     void showPlaybackTargetPicker(bool hasVideo, WebCore::RouteSharingPolicy, const String&) final;
     RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final;
 
+    bool showDataDetectorsUIForElement(const WebCore::Element&, const WebCore::Event&) final { return false; }
+
 #if ENABLE(ORIENTATION_EVENTS)
     int deviceOrientation() const final;
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to