Title: [195769] trunk/Source
Revision
195769
Author
[email protected]
Date
2016-01-28 11:40:36 -0800 (Thu, 28 Jan 2016)

Log Message

Should avoid navigation for some data detector urls.
https://bugs.webkit.org/show_bug.cgi?id=153600

Reviewed by Tim Horton.

Source/WebCore:

Adding helper function to decide whether the default action should be performed.

* editing/cocoa/DataDetection.h:
* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::shouldCancelDefaultAction):

Source/WebKit2:

When a tap is commited, we normally generate a synthetic click if
the node responds to click events.
This patch adds the logic to prevent that from happening if the node
is a data detector link with certain characteristics (calendar event, telephone, etc.).
If this is the case, we compute the interaction information as position, send it
over to the UI process and notify that we did not handle the tap.
The page client is now also notified of this event and can show the data detector sheet if
appropriate.

* UIProcess/PageClient.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::toolTipChanged):
(WebKit::PageClientImpl::didNotHandleTapAsClick):
(WebKit::PageClientImpl::decidePolicyForGeolocationPermissionRequest):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView clearSelection]):
(-[WKContentView _didNotHandleTapAsClick:]):
(-[WKContentView _positionInformationDidChange:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didNotHandleTapAsClick):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::commitPotentialTap):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (195768 => 195769)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 19:40:36 UTC (rev 195769)
@@ -1,3 +1,16 @@
+2016-01-28  Enrica Casucci  <[email protected]>
+
+        Should avoid navigation for some data detector urls.
+        https://bugs.webkit.org/show_bug.cgi?id=153600
+
+        Reviewed by Tim Horton.
+
+        Adding helper function to decide whether the default action should be performed.
+
+        * editing/cocoa/DataDetection.h:
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::shouldCancelDefaultAction):
+
 2016-01-28  Dave Hyatt  <[email protected]>
 
         Roll out r194555, as it introduced some bad regressions and was not

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.h (195768 => 195769)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.h	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.h	2016-01-28 19:40:36 UTC (rev 195769)
@@ -59,6 +59,7 @@
     WEBCORE_EXPORT static NSArray *detectContentInRange(RefPtr<Range>& contextRange, DataDetectorTypes);
     WEBCORE_EXPORT static bool isDataDetectorLink(Element*);
     WEBCORE_EXPORT static String dataDetectorIdentifier(Element*);
+    WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element*);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (195768 => 195769)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2016-01-28 19:40:36 UTC (rev 195769)
@@ -61,8 +61,26 @@
     return element->getAttribute(dataDetectorsAttributeResultKey);
 }
 
+bool DataDetection::shouldCancelDefaultAction(Element* element)
+{
 #if PLATFORM(MAC)
+    UNUSED_PARAM(element);
+    return false;
+#else
+    // FIXME: We should also compute the DDResultRef and check the result category.
+    if (!is<HTMLAnchorElement>(*element))
+        return false;
+    if (element->getAttribute(dataDetectorsURLScheme) != "true")
+        return false;
+    String type = element->getAttribute(dataDetectorsAttributeTypeKey);
+    if (type == "misc" || type == "calendar-event" || type == "telephone")
+        return true;
+    return false;
+#endif
+}
 
+#if PLATFORM(MAC)
+
 static RetainPtr<DDActionContext> detectItemAtPositionWithRange(VisiblePosition position, RefPtr<Range> contextRange, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
 {
     String fullPlainTextString = plainText(contextRange.get());

Modified: trunk/Source/WebKit2/ChangeLog (195768 => 195769)


--- trunk/Source/WebKit2/ChangeLog	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/ChangeLog	2016-01-28 19:40:36 UTC (rev 195769)
@@ -1,3 +1,35 @@
+2016-01-28  Enrica Casucci  <[email protected]>
+
+        Should avoid navigation for some data detector urls.
+        https://bugs.webkit.org/show_bug.cgi?id=153600
+
+        Reviewed by Tim Horton.
+
+        When a tap is commited, we normally generate a synthetic click if
+        the node responds to click events.
+        This patch adds the logic to prevent that from happening if the node
+        is a data detector link with certain characteristics (calendar event, telephone, etc.).
+        If this is the case, we compute the interaction information as position, send it
+        over to the UI process and notify that we did not handle the tap.
+        The page client is now also notified of this event and can show the data detector sheet if
+        appropriate.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::toolTipChanged):
+        (WebKit::PageClientImpl::didNotHandleTapAsClick):
+        (WebKit::PageClientImpl::decidePolicyForGeolocationPermissionRequest):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView clearSelection]):
+        (-[WKContentView _didNotHandleTapAsClick:]):
+        (-[WKContentView _positionInformationDidChange:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didNotHandleTapAsClick):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::commitPotentialTap):
+
 2016-01-28  Brent Fulgham  <[email protected]>
 
         [iOS] Update Web Process sandbox profile for audiodeviceclock access

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2016-01-28 19:40:36 UTC (rev 195769)
@@ -212,6 +212,7 @@
 #if PLATFORM(IOS)
     virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
     virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
+    virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) = 0;
 #endif
     
     virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) = 0;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2016-01-28 19:40:36 UTC (rev 195769)
@@ -185,6 +185,7 @@
     virtual void didFinishLoadForMainFrame() override;
     virtual void didFailLoadForMainFrame() override;
     virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
+    virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
 
     virtual void didChangeBackgroundColor() override;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2016-01-28 19:40:36 UTC (rev 195769)
@@ -230,6 +230,11 @@
     notImplemented();
 }
 
+void PageClientImpl::didNotHandleTapAsClick(const WebCore::IntPoint& point)
+{
+    [m_contentView _didNotHandleTapAsClick:point];
+}
+
 bool PageClientImpl::decidePolicyForGeolocationPermissionRequest(WebFrameProxy& frame, API::SecurityOrigin& origin, GeolocationPermissionRequestProxy& request)
 {
     [[wrapper(m_webView->_page->process().processPool()) _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:origin.securityOrigin() frame:frame request:request view:m_webView];

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-28 19:40:36 UTC (rev 195769)
@@ -185,6 +185,7 @@
 - (void)_webTouchEvent:(const WebKit::NativeWebTouchEvent&)touchEvent preventsNativeGestures:(BOOL)preventsDefault;
 #endif
 - (void)_commitPotentialTapFailed;
+- (void)_didNotHandleTapAsClick:(const WebCore::IntPoint&)point;
 - (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius;
 
 - (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-28 19:40:36 UTC (rev 195769)
@@ -1402,6 +1402,14 @@
     _page->clearSelection();
 }
 
+- (void)_didNotHandleTapAsClick:(const WebCore::IntPoint&)point
+{
+    // FIXME: we should also take into account whether or not the UI delegate
+    // has handled this notification.
+    if (_hasValidPositionInformation && point == _positionInformation.point && _positionInformation.isDataDetectorLink)
+        [self _showDataDetectorsSheet];
+}
+
 - (void)_positionInformationDidChange:(const InteractionInformationAtPosition&)info
 {
     _positionInformation = info;

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (195768 => 195769)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-01-28 19:40:36 UTC (rev 195769)
@@ -932,6 +932,7 @@
 
 void WebPageProxy::didNotHandleTapAsClick(const WebCore::IntPoint& point)
 {
+    m_pageClient.didNotHandleTapAsClick(point);
     m_uiClient->didNotHandleTapAsClick(point);
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (195768 => 195769)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-01-28 19:34:36 UTC (rev 195768)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-01-28 19:40:36 UTC (rev 195769)
@@ -677,9 +677,13 @@
         return;
     }
 
-    if (m_potentialTapNode == nodeRespondingToClick)
-        handleSyntheticClick(nodeRespondingToClick, adjustedPoint);
-    else
+    if (m_potentialTapNode == nodeRespondingToClick) {
+        if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(&downcast<Element>(*nodeRespondingToClick))) {
+            requestPositionInformation(roundedIntPoint(m_potentialTapLocation));
+            commitPotentialTapFailed();
+        } else
+            handleSyntheticClick(nodeRespondingToClick, adjustedPoint);
+    } else
         commitPotentialTapFailed();
 
     m_potentialTapNode = nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to