Source/WebCore:
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2019 06:11:40 +0000 (06:11 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2019 06:11:40 +0000 (06:11 +0000)
[ContentChangeObserver][REGRESSION] Check if visibility change happens while dispatching mouseMoved
https://bugs.webkit.org/show_bug.cgi?id=195421
<rdar://problem/48682004>

Reviewed by Simon Fraser.

Visibility change might be triggered synchronously while dispatching mouseMoved event.

Test: fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html

* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::mouseMovedDidStart):
(WebCore::ContentChangeObserver::mouseMovedDidFinish):
(WebCore::ContentChangeObserver::isNotifyContentChangeAllowed const):
* page/ios/ContentChangeObserver.h:
(WebCore::ContentChangeObserver::isObservingContentChanges const):

LayoutTests:
[ContentChangeObserver] Check if visibility change happens while dispatching mouseMoved
https://bugs.webkit.org/show_bug.cgi?id=195421
<rdar://problem/48682004>

Reviewed by Simon Fraser.

* fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved-expected.txt: Added.
* fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/ios/ContentChangeObserver.cpp
Source/WebCore/page/ios/ContentChangeObserver.h

index c745405..79ffd05 100644 (file)
@@ -1,5 +1,16 @@
 2019-03-07  Zalan Bujtas  <zalan@apple.com>
 
+        [ContentChangeObserver] Check if visibility change happens while dispatching mouseMoved
+        https://bugs.webkit.org/show_bug.cgi?id=195421
+        <rdar://problem/48682004>
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved-expected.txt: Added.
+        * fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html: Added.
+
+2019-03-07  Zalan Bujtas  <zalan@apple.com>
+
         [ContentChangeObserver] Check if max-height change triggers visible content change.
         https://bugs.webkit.org/show_bug.cgi?id=195417
         <rdar://problem/48680631>
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved-expected.txt b/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved-expected.txt
new file mode 100644 (file)
index 0000000..66db4c9
--- /dev/null
@@ -0,0 +1,2 @@
+PASS if 'clicked' text is not shown below.
+
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html b/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html
new file mode 100644 (file)
index 0000000..2079f1e
--- /dev/null
@@ -0,0 +1,57 @@
+<html>
+<head>
+<title>This tests the case when visible content change happens on touchstart</title>
+<script src="../../../../../resources/basic-gestures.js"></script>
+<style>
+#tapthis {
+    width: 400px;
+    height: 400px;
+    border: 1px solid green;
+}
+
+#becomesVisible {
+    display: none;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+    if (window.internals)
+        internals.settings.setContentChangeObserverEnabled(true);
+
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+
+    let rect = tapthis.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+    await tapAtPoint(x, y);
+}
+</script>
+</head>
+<body onload="test()">
+<div id=tapthis>PASS if 'clicked' text is not shown below.</div>
+<div id=becomesVisible></div>
+<pre id=result></pre>
+<script>
+tapthis.addEventListener("mouseover", function( event ) {
+    becomesVisible.style.display = "block";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+
+becomesVisible.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked hidden";
+}, false);
+
+tapthis.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked";
+}, false);
+</script>
+</body>
+</html>
index d84e167..d1df0f8 100644 (file)
@@ -1,5 +1,24 @@
 2019-03-07  Zalan Bujtas  <zalan@apple.com>
 
+        [ContentChangeObserver][REGRESSION] Check if visibility change happens while dispatching mouseMoved
+        https://bugs.webkit.org/show_bug.cgi?id=195421
+        <rdar://problem/48682004>
+
+        Reviewed by Simon Fraser.
+
+        Visibility change might be triggered synchronously while dispatching mouseMoved event.
+
+        Test: fast/events/touch/ios/content-observation/visibility-change-happens-while-in-mousemoved.html
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::mouseMovedDidStart):
+        (WebCore::ContentChangeObserver::mouseMovedDidFinish):
+        (WebCore::ContentChangeObserver::isNotifyContentChangeAllowed const):
+        * page/ios/ContentChangeObserver.h:
+        (WebCore::ContentChangeObserver::isObservingContentChanges const):
+
+2019-03-07  Zalan Bujtas  <zalan@apple.com>
+
         [ContentChangeObserver] Check if max-height change triggers visible content change.
         https://bugs.webkit.org/show_bug.cgi?id=195417
         <rdar://problem/48680631>
index b8abb78..612d19b 100644 (file)
@@ -183,18 +183,21 @@ void ContentChangeObserver::touchEventDidFinish()
 
 void ContentChangeObserver::mouseMovedDidStart()
 {
-#if !ASSERT_DISABLED
-    m_mouseMovedIsBeingDispatched = true;
-#endif
+    if (!m_document.settings().contentChangeObserverEnabled())
+        return;
+    LOG(ContentObservation, "mouseMovedDidStart: mouseMoved started.");
+    m_mouseMovedEventIsBeingDispatched = true;
     adjustObservedState(Event::StartedMouseMovedEventDispatching);
 }
 
 void ContentChangeObserver::mouseMovedDidFinish()
 {
+    if (!m_mouseMovedEventIsBeingDispatched)
+        return;
+    ASSERT(m_document.settings().contentChangeObserverEnabled());
+    LOG(ContentObservation, "mouseMovedDidFinish: mouseMoved finished.");
     adjustObservedState(Event::EndedMouseMovedEventDispatching);
-#if !ASSERT_DISABLED
-    m_mouseMovedIsBeingDispatched = false;
-#endif
+    m_mouseMovedEventIsBeingDispatched = false;
 }
 
 WKContentChange ContentChangeObserver::observedContentChange() const
@@ -219,7 +222,7 @@ bool ContentChangeObserver::hasDeterminateState() const
 #if !ASSERT_DISABLED
 bool ContentChangeObserver::isNotifyContentChangeAllowed() const
 {
-    return m_document.settings().contentChangeObserverEnabled() && !m_mouseMovedIsBeingDispatched;
+    return m_document.settings().contentChangeObserverEnabled() && !m_mouseMovedEventIsBeingDispatched;
 }
 #endif
 
index 350997e..672ff19 100644 (file)
@@ -119,7 +119,7 @@ private:
     void setShouldObserveNextStyleRecalc(bool);
     bool isObservingStyleRecalc() const { return m_isObservingStyleRecalc; }
 
-    bool isObservingContentChanges() const { return m_touchEventIsBeingDispatched || m_domTimerIsBeingExecuted || m_styleRecalcIsBeingExecuted || m_contentObservationTimer.isActive(); }
+    bool isObservingContentChanges() const { return m_mouseMovedEventIsBeingDispatched || m_touchEventIsBeingDispatched || m_domTimerIsBeingExecuted || m_styleRecalcIsBeingExecuted || m_contentObservationTimer.isActive(); }
 
     void cancelPendingActivities();
 
@@ -162,9 +162,7 @@ private:
     bool m_isObservingDOMTimerScheduling { false };
     bool m_domTimerIsBeingExecuted { false };
     bool m_isMouseMovedPrecededByTouch { false };
-#if !ASSERT_DISABLED
-    bool m_mouseMovedIsBeingDispatched { false };
-#endif
+    bool m_mouseMovedEventIsBeingDispatched { false };
 };
 
 inline void ContentChangeObserver::setHasNoChangeState()