[ContentChangeObserver] Assert on if notify content change is allowed
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 23:35:02 +0000 (23:35 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 23:35:02 +0000 (23:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195332
<rdar://problem/48603276>

Reviewed by Simon Fraser.

Assert we don't notify the client about the state change while in handleSyntheticClick().

* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::domTimerExecuteDidStart):
(WebCore::ContentChangeObserver::domTimerExecuteDidFinish):
(WebCore::ContentChangeObserver::adjustObservedState):
* page/ios/ContentChangeObserver.h:
(WebCore::ContentChangeObserver::isObservingContentChanges const):
(WebCore::ContentChangeObserver::isNotifyContentChangeAllowed const):

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

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

index 804c02d..0eaf950 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-05  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Assert on if notify content change is allowed
+        https://bugs.webkit.org/show_bug.cgi?id=195332
+        <rdar://problem/48603276>
+
+        Reviewed by Simon Fraser.
+
+        Assert we don't notify the client about the state change while in handleSyntheticClick().
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::domTimerExecuteDidStart):
+        (WebCore::ContentChangeObserver::domTimerExecuteDidFinish):
+        (WebCore::ContentChangeObserver::adjustObservedState):
+        * page/ios/ContentChangeObserver.h:
+        (WebCore::ContentChangeObserver::isObservingContentChanges const):
+        (WebCore::ContentChangeObserver::isNotifyContentChangeAllowed const):
+
 2019-03-05  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         SVGPathSegList.insertItemBefore() should fail if the newItem belongs to an animating animPathSegList
index 87e888a..27190c8 100644 (file)
@@ -73,7 +73,7 @@ void ContentChangeObserver::domTimerExecuteDidStart(const DOMTimer& timer)
         return;
     LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback.");
 
-    m_domTimerisBeingExecuted = true;
+    m_domTimerIsBeingExecuted = true;
 }
 
 void ContentChangeObserver::domTimerExecuteDidFinish(const DOMTimer& timer)
@@ -82,7 +82,7 @@ void ContentChangeObserver::domTimerExecuteDidFinish(const DOMTimer& timer)
         return;
     LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: stop observing (" << &timer << ") timer callback.");
 
-    m_domTimerisBeingExecuted = false;
+    m_domTimerIsBeingExecuted = false;
     unregisterDOMTimer(timer);
     setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());
     adjustObservedState(Event::EndedDOMTimerExecution);
@@ -140,6 +140,9 @@ void ContentChangeObserver::contentVisibilityDidChange()
 
 void ContentChangeObserver::mouseMovedDidStart()
 {
+#if !ASSERT_DISABLED
+    m_mouseMovedIsBeingDispatched = true;
+#endif
     ASSERT(!m_document.hasPendingStyleRecalc());
     clearObservedDOMTimers();
     setShouldObserveDOMTimerScheduling(true);
@@ -149,6 +152,9 @@ void ContentChangeObserver::mouseMovedDidStart()
 void ContentChangeObserver::mouseMovedDidFinish()
 {
     setShouldObserveDOMTimerScheduling(false);
+#if !ASSERT_DISABLED
+    m_mouseMovedIsBeingDispatched = false;
+#endif
 }
 
 WKContentChange ContentChangeObserver::observedContentChange() const
@@ -178,6 +184,7 @@ void ContentChangeObserver::adjustObservedState(Event event)
             return;
         }
         LOG_WITH_STREAM(ContentObservation, stream << "notifyContentChangeIfNeeded: sending observedContentChange ->" << observedContentChange());
+        ASSERT(isNotifyContentChangeAllowed());
         ASSERT(m_document.page());
         ASSERT(m_document.frame());
         m_document.page()->chrome().client().observedContentChange(*m_document.frame());
index 0e01ea1..e31cd02 100644 (file)
@@ -102,7 +102,7 @@ private:
     void setShouldObserveNextStyleRecalc(bool);
     bool isObservingStyleRecalc() const { return m_isObservingStyleRecalc; }
 
-    bool isObservingContentChanges() const { return m_domTimerisBeingExecuted || m_styleRecalcIsBeingExecuted; }
+    bool isObservingContentChanges() const { return m_domTimerIsBeingExecuted || m_styleRecalcIsBeingExecuted; }
 
     void clearObservedDOMTimers() { m_DOMTimerList.clear(); }
     void clearTimersAndReportContentChange();
@@ -116,6 +116,9 @@ private:
     bool hasDeterminateState() const;
 
     bool hasPendingActivity() const { return hasObservedDOMTimer() || m_document.hasPendingStyleRecalc(); }
+#if !ASSERT_DISABLED
+    bool isNotifyContentChangeAllowed() const { return !m_mouseMovedIsBeingDispatched; }
+#endif
 
     enum class Event {
         StartedMouseMovedEventDispatching,
@@ -132,7 +135,10 @@ private:
     bool m_isObservingStyleRecalc { false };
     bool m_styleRecalcIsBeingExecuted { false };
     bool m_isObservingDOMTimerScheduling { false };
-    bool m_domTimerisBeingExecuted { false };
+    bool m_domTimerIsBeingExecuted { false };
+#if !ASSERT_DISABLED
+    bool m_mouseMovedIsBeingDispatched { false };
+#endif
 };
 
 inline void ContentChangeObserver::setHasNoChangeState()