[ContentChangeObserver] Reset state when touchStart does not turn into click.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 00:12:15 +0000 (00:12 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 00:12:15 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195603
<rdar://problem/48796582>

Reviewed by Simon Fraser.

Add reset() function to assert and reset the current state.

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

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

Source/WebCore/ChangeLog
Source/WebCore/page/ios/ContentChangeObserver.cpp
Source/WebCore/page/ios/ContentChangeObserver.h

index 5c5f147..a12ea17 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-12  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Reset state when touchStart does not turn into click.
+        https://bugs.webkit.org/show_bug.cgi?id=195603
+        <rdar://problem/48796582>
+
+        Reviewed by Simon Fraser.
+
+        Add reset() function to assert and reset the current state.
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::willNotProceedWithClick):
+        (WebCore::ContentChangeObserver::adjustObservedState):
+        * page/ios/ContentChangeObserver.h:
+
 2019-03-12  Timothy Hatcher  <timothy@apple.com>
 
         Expose document attributes and body background color through HTMLConverter.
index 7c6b2ea..fc256ce 100644 (file)
@@ -100,7 +100,7 @@ void ContentChangeObserver::didRemoveDOMTimer(const DOMTimer& timer)
 void ContentChangeObserver::willNotProceedWithClick()
 {
     LOG(ContentObservation, "willNotProceedWithClick: click will not happen.");
-    setIsBetweenTouchEndAndMouseMoved(false);
+    adjustObservedState(Event::WillNotProceedWithClick);
     // FIXME: Add support for preventDefault().
 }
 
@@ -236,6 +236,16 @@ bool ContentChangeObserver::hasDeterminateState() const
 
 void ContentChangeObserver::adjustObservedState(Event event)
 {
+    auto reset = [&] {
+        setHasNoChangeState();
+        clearObservedDOMTimers();
+        setIsBetweenTouchEndAndMouseMoved(false);
+        ASSERT(!m_isObservingDOMTimerScheduling);
+        ASSERT(!m_isWaitingForStyleRecalc);
+        ASSERT(!m_isInObservedStyleRecalc);
+        ASSERT(!m_observedDomTimerIsBeingExecuted);
+    };
+
     auto adjustStateAndNotifyContentChangeIfNeeded = [&] {
         // Demote to "no change" when there's no pending activity anymore.
         if (observedContentChange() == WKContentIndeterminateChange && !hasPendingActivity())
@@ -258,14 +268,16 @@ void ContentChangeObserver::adjustObservedState(Event event)
 
     switch (event) {
     case Event::StartedTouchStartEventDispatching:
-        setHasNoChangeState();
-        clearObservedDOMTimers();
+        reset();
         setShouldObserveDOMTimerScheduling(true);
         break;
     case Event::EndedTouchStartEventDispatching:
         setShouldObserveDOMTimerScheduling(false);
         setIsBetweenTouchEndAndMouseMoved(true);
         break;
+    case Event::WillNotProceedWithClick:
+        reset();
+        break;
     case Event::StartedMouseMovedEventDispatching:
         ASSERT(!m_document.hasPendingStyleRecalc());
         if (!isBetweenTouchEndAndMouseMoved()) {
index ff21355..3a2408e 100644 (file)
@@ -146,6 +146,7 @@ private:
     enum class Event {
         StartedTouchStartEventDispatching,
         EndedTouchStartEventDispatching,
+        WillNotProceedWithClick,
         StartedMouseMovedEventDispatching,
         EndedMouseMovedEventDispatching,
         InstalledDOMTimer,