[ContentChangeObserver] Stop content observation when content calls preventDefault...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 04:49:15 +0000 (04:49 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 04:49:15 +0000 (04:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195724
<rdar://problem/48873456>

Reviewed by Simon Fraser.

Source/WebCore:

Call willNotProceedWithClick on preventDefault. This is very similar to the long press case.

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

Source/WebKit:

* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::didPreventDefaultForEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242935 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/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm

index 8e315ce..ac6b3ee 100644 (file)
@@ -1,3 +1,19 @@
+2019-03-13  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Stop content observation when content calls preventDefault() on touch events
+        https://bugs.webkit.org/show_bug.cgi?id=195724
+        <rdar://problem/48873456>
+
+        Reviewed by Simon Fraser.
+
+        Call willNotProceedWithClick on preventDefault. This is very similar to the long press case.
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::willNotProceedWithClick):
+        (WebCore::ContentChangeObserver::didRecognizeLongPress):
+        (WebCore::ContentChangeObserver::didPreventDefaultForEvent):
+        * page/ios/ContentChangeObserver.h:
+
 2019-03-13  Justin Fan  <justin_fan@apple.com>
 
         [Web GPU] Updates to GPUCommandBuffer for new GPUCommandQueue concept
index fc256ce..c48d8ac 100644 (file)
@@ -44,15 +44,26 @@ ContentChangeObserver::ContentChangeObserver(Document& document)
 {
 }
 
-void ContentChangeObserver::didRecognizeLongPress(Frame& mainframe)
+static void willNotProceedWithClick(Frame& mainFrame)
 {
-    LOG(ContentObservation, "didRecognizeLongPress: cancel ongoing content change observing.");
-    for (auto* frame = &mainframe; frame; frame = frame->tree().traverseNext()) {
+    for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) {
         if (auto* document = frame->document())
             document->contentChangeObserver().willNotProceedWithClick();
     }
 }
 
+void ContentChangeObserver::didRecognizeLongPress(Frame& mainFrame)
+{
+    LOG(ContentObservation, "didRecognizeLongPress: cancel ongoing content change observing.");
+    WebCore::willNotProceedWithClick(mainFrame);
+}
+
+void ContentChangeObserver::didPreventDefaultForEvent(Frame& mainFrame)
+{
+    LOG(ContentObservation, "didPreventDefaultForEvent: cancel ongoing content change observing.");
+    WebCore::willNotProceedWithClick(mainFrame);
+}
+
 void ContentChangeObserver::startContentObservationForDuration(Seconds duration)
 {
     if (!m_document.settings().contentChangeObserverEnabled())
index 3a2408e..6ae1802 100644 (file)
@@ -46,7 +46,9 @@ public:
     void didInstallDOMTimer(const DOMTimer&, Seconds timeout, bool singleShot);
     void didRemoveDOMTimer(const DOMTimer&);
     WEBCORE_EXPORT void willNotProceedWithClick();
-    WEBCORE_EXPORT static void didRecognizeLongPress(Frame& mainframe);
+    WEBCORE_EXPORT static void didRecognizeLongPress(Frame& mainFrame);
+    WEBCORE_EXPORT static void didPreventDefaultForEvent(Frame& mainFrame);
+
     void didSuspendActiveDOMObjects();
     void willDetachPage();
 
index b5114a8..960ad1e 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-13  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Stop content observation when content calls preventDefault() on touch events
+        https://bugs.webkit.org/show_bug.cgi?id=195724
+        <rdar://problem/48873456>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        (WebKit::WebChromeClient::didPreventDefaultForEvent):
+
 2019-03-13  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Make -[_WKAttachment setFileWrapper:contentType:completion:] robust when given a nil completion handler
index 90327cc..2944091 100644 (file)
@@ -37,6 +37,7 @@
 #import "WebPage.h"
 #import "WebPageProxyMessages.h"
 #import <WebCore/AudioSession.h>
+#import <WebCore/ContentChangeObserver.h>
 #import <WebCore/Icon.h>
 #import <WebCore/NotImplemented.h>
 #import <wtf/RefPtr.h>
@@ -48,7 +49,9 @@ using namespace WebCore;
 
 void WebChromeClient::didPreventDefaultForEvent()
 {
-    notImplemented();
+    if (!m_page.mainFrame())
+        return;
+    ContentChangeObserver::didPreventDefaultForEvent(*m_page.mainFrame());
 }
 
 #endif