[ContentChangeObserver] Check if the transitioned content is visible at onAnimationEnd
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Mar 2019 20:47:47 +0000 (20:47 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Mar 2019 20:47:47 +0000 (20:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196171

Reviewed by Simon Fraser.

Source/WebCore:

At onAnimationEnd we don't yet have the final computed style for the transitioned content.
However the current state (before computing the final style) might already be qualified to be visible.
Introduce "CompletedTransition" to indicate that the transition is all set as far observing is concerned
(as opposed to "EndedTransition" where we still need to observe the content for the final style change).

Test: fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html

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

LayoutTests:

* fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end-expected.txt: Added.
* fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/ios/ContentChangeObserver.cpp
Source/WebCore/page/ios/ContentChangeObserver.h

index 90729d7..09f67a9 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-23  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Check if the transitioned content is visible at onAnimationEnd
+        https://bugs.webkit.org/show_bug.cgi?id=196171
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end-expected.txt: Added.
+        * fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html: Added.
+
 2019-03-22  Devin Rousso  <drousso@apple.com>
 
         Unreviewed, fix test failures after r243269.
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end-expected.txt b/LayoutTests/fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end-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/10ms-delay-transition-on-touch-start-with-non-0px-end.html b/LayoutTests/fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html
new file mode 100644 (file)
index 0000000..c59562a
--- /dev/null
@@ -0,0 +1,60 @@
+<html>
+<head>
+<title>This tests the case when touchEnd triggers a 0ms transition with delay.</title>
+<script src="../../../../../resources/basic-gestures.js"></script>
+<style>
+#tapthis {
+    width: 400px;
+    height: 400px;
+    border: 1px solid green;
+}
+
+#becomesVisible {
+       position: absolute;
+       top: 100px;
+       left: -110px;
+       width: 100px;
+       height: 100px;
+       background-color: green;
+       transition: left 200ms ease-in-out 10ms;
+}
+</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("mousemove", function( event ) {
+    becomesVisible.style.left = "400px";
+    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 dc82166..e3debc4 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-23  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Check if the transitioned content is visible at onAnimationEnd
+        https://bugs.webkit.org/show_bug.cgi?id=196171
+
+        Reviewed by Simon Fraser.
+
+        At onAnimationEnd we don't yet have the final computed style for the transitioned content.
+        However the current state (before computing the final style) might already be qualified to be visible.
+        Introduce "CompletedTransition" to indicate that the transition is all set as far observing is concerned
+        (as opposed to "EndedTransition" where we still need to observe the content for the final style change).
+
+        Test: fast/events/touch/ios/content-observation/10ms-delay-transition-on-touch-start-with-non-0px-end.html
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::didFinishTransition):
+        (WebCore::ContentChangeObserver::adjustObservedState):
+        * page/ios/ContentChangeObserver.h:
+
 2019-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Remove build time dependency on Geoclue2
index fd6d14d..0c921b1 100644 (file)
@@ -152,7 +152,7 @@ void ContentChangeObserver::didFinishTransition(const Element& element, CSSPrope
         return;
     LOG_WITH_STREAM(ContentObservation, stream << "didFinishTransition: transition finished (" << &element << ").");
 
-    adjustObservedState(Event::EndedTransition);
+    adjustObservedState(isConsideredHidden(element) ? Event::EndedTransition : Event::CompletedTransition);
 }
 
 void ContentChangeObserver::didRemoveTransition(const Element& element, CSSPropertyID propertyID)
@@ -434,13 +434,21 @@ void ContentChangeObserver::adjustObservedState(Event event)
         break;
     case Event::EndedTransition:
         // onAnimationEnd can be called while in the middle of resolving the document (synchronously) or
-        // asynchronously right before the style update is issued.
+        // asynchronously right before the style update is issued. It also means we don't know whether this animation ends up producing visible content yet. 
         if (m_document.inStyleRecalc()) {
             // We need to start observing this style change synchronously.
             m_isInObservedStyleRecalc = true;
         } else
             setShouldObserveNextStyleRecalc(true);
         break;
+    case Event::CompletedTransition:
+        // Set visibility flag on and report visible change synchronously or asynchronously depending whether we are in the middle of style recalc.
+        contentVisibilityDidChange();
+        if (m_document.inStyleRecalc())
+            m_isInObservedStyleRecalc = true;
+        else if (!isObservationTimeWindowActive())
+            adjustStateAndNotifyContentChangeIfNeeded();
+        break;
     case Event::EndedFixedObservationTimeWindow:
         adjustStateAndNotifyContentChangeIfNeeded();
         break;
index 05aa058..4eb9390 100644 (file)
@@ -173,6 +173,7 @@ private:
         EndedStyleRecalc,
         AddedTransition,
         EndedTransition,
+        CompletedTransition,
         CanceledTransition,
         StartedFixedObservationTimeWindow,
         EndedFixedObservationTimeWindow,