[ContentChangeObserver] Stop content change observation when the touch event turns...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 16:40:31 +0000 (16:40 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 16:40:31 +0000 (16:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195601
<rdar://problem/48796324>

Reviewed by Wenson Hsieh.

Source/WebCore:

Cancel the ongoing content observation (started at touchStart) when the touch event does not turn into a tap gesture.

Not testable because any subsequent tap would reset the state anyway (though it might be measurable through some code triggering heavy content change).

* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::didRecognizeLongPress):
(WebCore::ContentChangeObserver::willNotProceedWithClick):
* page/ios/ContentChangeObserver.h:

Source/WebKit:

Add didRecognizeLongPress() message to be able to cancel content observation (started at touchStart).

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _longPressRecognized:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didRecognizeLongPress):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::didRecognizeLongPress):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242796 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/ios/ContentChangeObserver.cpp
Source/WebCore/page/ios/ContentChangeObserver.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 9d3a500..9c1d4f2 100644 (file)
@@ -1,3 +1,20 @@
+2019-03-12  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Stop content change observation when the touch event turns into long press
+        https://bugs.webkit.org/show_bug.cgi?id=195601
+        <rdar://problem/48796324>
+
+        Reviewed by Wenson Hsieh.
+
+        Cancel the ongoing content observation (started at touchStart) when the touch event does not turn into a tap gesture.
+
+        Not testable because any subsequent tap would reset the state anyway (though it might be measurable through some code triggering heavy content change).
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::didRecognizeLongPress):
+        (WebCore::ContentChangeObserver::willNotProceedWithClick):
+        * page/ios/ContentChangeObserver.h:
+
 2019-03-12  Antti Koivisto  <antti@apple.com>
 
         Compositing layer that renders two positioned elements should not hit test
index 002a2d9..7c6b2ea 100644 (file)
@@ -44,6 +44,15 @@ ContentChangeObserver::ContentChangeObserver(Document& document)
 {
 }
 
+void ContentChangeObserver::didRecognizeLongPress(Frame& mainframe)
+{
+    LOG(ContentObservation, "didRecognizeLongPress: cancel ongoing content change observing.");
+    for (auto* frame = &mainframe; frame; frame = frame->tree().traverseNext()) {
+        if (auto* document = frame->document())
+            document->contentChangeObserver().willNotProceedWithClick();
+    }
+}
+
 void ContentChangeObserver::startContentObservationForDuration(Seconds duration)
 {
     if (!m_document.settings().contentChangeObserverEnabled())
@@ -92,7 +101,7 @@ void ContentChangeObserver::willNotProceedWithClick()
 {
     LOG(ContentObservation, "willNotProceedWithClick: click will not happen.");
     setIsBetweenTouchEndAndMouseMoved(false);
-    // FIXME: Add support for preventDefault() and long press.
+    // FIXME: Add support for preventDefault().
 }
 
 void ContentChangeObserver::domTimerExecuteDidStart(const DOMTimer& timer)
index 8ee7848..ff21355 100644 (file)
@@ -46,6 +46,7 @@ public:
     void didInstallDOMTimer(const DOMTimer&, Seconds timeout, bool singleShot);
     void didRemoveDOMTimer(const DOMTimer&);
     WEBCORE_EXPORT void willNotProceedWithClick();
+    WEBCORE_EXPORT static void didRecognizeLongPress(Frame& mainframe);
     void didSuspendActiveDOMObjects();
     void willDetachPage();
 
@@ -104,6 +105,8 @@ private:
     void mouseMovedDidStart();
     void mouseMovedDidFinish();
 
+    void didRecognizeLongPress();
+
     void contentVisibilityDidChange();
 
     void setShouldObserveDOMTimerScheduling(bool observe) { m_isObservingDOMTimerScheduling = observe; }
index 6a66e0b..53c3a66 100644 (file)
@@ -1,3 +1,23 @@
+2019-03-12  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Stop content change observation when the touch event turns into long press
+        https://bugs.webkit.org/show_bug.cgi?id=195601
+        <rdar://problem/48796324>
+
+        Reviewed by Wenson Hsieh.
+
+        Add didRecognizeLongPress() message to be able to cancel content observation (started at touchStart).
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _longPressRecognized:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didRecognizeLongPress):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::didRecognizeLongPress):
+
 2019-03-11  Andy Estes  <aestes@apple.com>
 
         [Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
index 55fdb59..add22d6 100644 (file)
@@ -1188,6 +1188,7 @@ public:
     void cancelPotentialTap();
     void tapHighlightAtPosition(const WebCore::FloatPoint&, uint64_t& requestID);
     void handleTap(const WebCore::FloatPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t layerTreeTransactionIdAtLastTouchStart);
+    void didRecognizeLongPress();
 
     void inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint&);
     void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
index 260d491..9cce3cb 100644 (file)
@@ -2175,6 +2175,7 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
     ASSERT(gestureRecognizer == _longPressGestureRecognizer);
     [self _resetIsDoubleTapPending];
     [self _cancelTouchEventGestureRecognizer];
+    _page->didRecognizeLongPress();
 
     _lastInteractionLocation = gestureRecognizer.startPoint;
 
index bc816fd..6e94a60 100644 (file)
@@ -838,6 +838,11 @@ void WebPageProxy::handleTap(const FloatPoint& location, OptionSet<WebEvent::Mod
     process().send(Messages::WebPage::HandleTap(roundedIntPoint(location), modifiers, layerTreeTransactionIdAtLastTouchStart), m_pageID);
 }
 
+void WebPageProxy::didRecognizeLongPress()
+{
+    process().send(Messages::WebPage::DidRecognizeLongPress(), m_pageID);
+}
+
 void WebPageProxy::inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint& position)
 {
     process().send(Messages::WebPage::InspectorNodeSearchMovedToPosition(position), m_pageID);
index 9f73f83..ddf6b5b 100644 (file)
@@ -620,6 +620,7 @@ public:
     void cancelPotentialTap();
     void cancelPotentialTapInFrame(WebFrame&);
     void tapHighlightAtPosition(uint64_t requestID, const WebCore::FloatPoint&);
+    void didRecognizeLongPress();
 
     void inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint&);
     void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
index 20eb1a9..c2c59ef 100644 (file)
@@ -56,6 +56,7 @@ messages -> WebPage LegacyReceiver {
     CommitPotentialTap(OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t lastLayerTreeTransactionId)
     CancelPotentialTap()
     TapHighlightAtPosition(uint64_t requestID, WebCore::FloatPoint point)
+    DidRecognizeLongPress()
     InspectorNodeSearchMovedToPosition(WebCore::FloatPoint point)
     InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point)
     BlurFocusedElement()
index db00d2f..505797f 100644 (file)
@@ -890,6 +890,11 @@ void WebPage::cancelPotentialTapInFrame(WebFrame& frame)
     m_potentialTapSecurityOrigin = nullptr;
 }
 
+void WebPage::didRecognizeLongPress()
+{
+    ContentChangeObserver::didRecognizeLongPress(m_page->mainFrame());
+}
+
 void WebPage::tapHighlightAtPosition(uint64_t requestID, const FloatPoint& position)
 {
     Frame& mainframe = m_page->mainFrame();