2009-01-08 Pierre-Olivier Latour <pol@apple.com>
authorpol@apple.com <pol@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jan 2009 18:24:47 +0000 (18:24 +0000)
committerpol@apple.com <pol@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jan 2009 18:24:47 +0000 (18:24 +0000)
        Reviewed by Dan Bernstein.

        Fixed CSS Transitions with zero-duration but non-zero-delay not starting or ending properly.

        Also updated AnimationController::numberOfActiveAnimations() which now returns the number of "active" animations,
        instead of simply the "running" ones.

        https://bugs.webkit.org/show_bug.cgi?id=23177

        Tests: transitions/zero-duration-with-non-zero-delay-end.html
               transitions/zero-duration-with-non-zero-delay-start.html

        * page/animation/AnimationBase.cpp:
        (WebCore::AnimationBase::fireAnimationEventsIfNeeded):
        * page/animation/AnimationController.cpp:
        (WebCore::AnimationControllerPrivate::animationTimerFired):
        * page/animation/CompositeAnimation.cpp:
        (WebCore::CompositeAnimationPrivate::numberOfActiveAnimations):

        Added layout tests for CSS Transitions with zero-duration but non-zero-delay.

        Also updated the layout test for DRT API numberOfActiveAnimations() which now returns the number of "active" animations,
        instead of simply the running ones.

        https://bugs.webkit.org/show_bug.cgi?id=23177

        * animations/animation-controller-drt-api-expected.txt:
        * animations/animation-controller-drt-api.html:
        * platform/win/Skipped:
        * transitions/zero-duration-with-non-zero-delay-end-expected.txt: Added.
        * transitions/zero-duration-with-non-zero-delay-end.html: Added.
        * transitions/zero-duration-with-non-zero-delay-start-expected.txt: Added.
        * transitions/zero-duration-with-non-zero-delay-start.html: Added.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/animation-controller-drt-api-expected.txt
LayoutTests/animations/animation-controller-drt-api.html
LayoutTests/platform/win/Skipped
LayoutTests/transitions/zero-duration-with-non-zero-delay-end-expected.txt [new file with mode: 0644]
LayoutTests/transitions/zero-duration-with-non-zero-delay-end.html [new file with mode: 0644]
LayoutTests/transitions/zero-duration-with-non-zero-delay-start-expected.txt [new file with mode: 0644]
LayoutTests/transitions/zero-duration-with-non-zero-delay-start.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/page/animation/AnimationBase.cpp
WebCore/page/animation/AnimationController.cpp
WebCore/page/animation/CompositeAnimation.cpp

index 5db31e8..ccf2af2 100644 (file)
@@ -1,3 +1,22 @@
+2009-01-08  Pierre-Olivier Latour  <pol@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Added layout tests for CSS Transitions with zero-duration but non-zero-delay.
+
+        Also updated the layout test for DRT API numberOfActiveAnimations() which now returns the number of "active" animations,
+        instead of simply the running ones.
+
+        https://bugs.webkit.org/show_bug.cgi?id=23177
+
+        * animations/animation-controller-drt-api-expected.txt:
+        * animations/animation-controller-drt-api.html:
+        * platform/win/Skipped:
+        * transitions/zero-duration-with-non-zero-delay-end-expected.txt: Added.
+        * transitions/zero-duration-with-non-zero-delay-end.html: Added.
+        * transitions/zero-duration-with-non-zero-delay-start-expected.txt: Added.
+        * transitions/zero-duration-with-non-zero-delay-start.html: Added.
+
 2009-01-07  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin Adler.
index 6809433..2722992 100644 (file)
@@ -1,4 +1,4 @@
 Test for DRT numberOfActiveAnimations() API
 
-Number of active animations at 0s is (2) as expected
+Number of active animations at 0s is (4) as expected
 Number of active animations at 1s is (4) as expected
index 6e185c6..5d4878d 100644 (file)
@@ -49,7 +49,7 @@
    <script type="text/javascript" charset="utf-8">
    
     function sample0() {
-      var expected = 2;
+      var expected = 4;
       var current = layoutTestController.numberOfActiveAnimations();
       if (current == expected)
         document.getElementById('result0').innerHTML = "Number of active animations at 0s is (" + current + ") as expected";
index 48e410e..bb878ac 100644 (file)
@@ -435,3 +435,4 @@ animations/keyframes-to-missing.html
 transitions/transition-drt-api.html
 transitions/transition-drt-api-delay.html
 transitions/transition-shorthand-delay.html
+transitions/zero-duration-non-zero-delay-end.html
diff --git a/LayoutTests/transitions/zero-duration-with-non-zero-delay-end-expected.txt b/LayoutTests/transitions/zero-duration-with-non-zero-delay-end-expected.txt
new file mode 100644 (file)
index 0000000..6ced0fc
--- /dev/null
@@ -0,0 +1,4 @@
+Test for DRT numberOfActiveAnimations() API
+
+Number of active animations before transition is (1) as expected
+Number of active animations after transition is (0) as expected
diff --git a/LayoutTests/transitions/zero-duration-with-non-zero-delay-end.html b/LayoutTests/transitions/zero-duration-with-non-zero-delay-end.html
new file mode 100644 (file)
index 0000000..f6e92ef
--- /dev/null
@@ -0,0 +1,80 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <style>
+    
+    body {
+      margin: 0;
+    }
+    
+    #target {
+      position: relative;
+      top: 100px;
+      left: 100px;
+      width: 200px;
+      height: 200px;
+      background-color: red;
+      -webkit-transition-property: left;
+      -webkit-transition-duration: 0s;
+      -webkit-transition-delay: 0.5s;
+    }
+    
+   </style>
+   <script type="text/javascript" charset="utf-8">
+   
+    function sample0() {
+      var expected = 1;
+      var current = layoutTestController.numberOfActiveAnimations();
+      if (current == expected)
+        document.getElementById('result0').innerHTML = "Number of active animations before transition is (" + current + ") as expected";
+      else
+        document.getElementById('result0').innerHTML = "Number of active animations before transition is (" + current + ") but was expecting (" + expected + ")";
+    }
+    
+    function sample1() {
+      var expected = 0;
+      var current = layoutTestController.numberOfActiveAnimations();
+      if (current == expected)
+        document.getElementById('result1').innerHTML = "Number of active animations after transition is (" + current + ") as expected";
+      else
+        document.getElementById('result1').innerHTML = "Number of active animations after transition is (" + current + ") but was expecting (" + expected + ")";
+      
+      layoutTestController.notifyDone();
+    }
+    
+    function runTest() {
+      window.setTimeout(sample0, 250);
+      window.setTimeout(sample1, 500);
+    }
+    
+    function startTest() {
+      if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+        
+        var target = document.getElementById('target');
+        target.style.left = '200px';
+        
+        window.setTimeout(runTest, 0);
+      }
+    }
+    
+   </script>
+</head>
+<body onload="startTest()">
+  <h1>Test for DRT numberOfActiveAnimations() API</h1>
+
+  <div id="target">
+  </div>
+  
+  <div id="result0">
+  </div>
+  
+  <div id="result1">
+  </div>
+
+</body>
+</html>
diff --git a/LayoutTests/transitions/zero-duration-with-non-zero-delay-start-expected.txt b/LayoutTests/transitions/zero-duration-with-non-zero-delay-start-expected.txt
new file mode 100644 (file)
index 0000000..ba19c0a
--- /dev/null
@@ -0,0 +1,3 @@
+Test that transitions with a zero-duration and but a non-zero delay effectively work
+
+PASS - left property is 200px as expected
diff --git a/LayoutTests/transitions/zero-duration-with-non-zero-delay-start.html b/LayoutTests/transitions/zero-duration-with-non-zero-delay-start.html
new file mode 100644 (file)
index 0000000..4a59725
--- /dev/null
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <style>
+    
+    body {
+      margin: 0;
+    }
+    
+    #target {
+      position: relative;
+      top: 100px;
+      left: 100px;
+      width: 200px;
+      height: 200px;
+      background-color: red;
+      -webkit-transition-property: left;
+      -webkit-transition-duration: 0s;
+      -webkit-transition-delay: 0.5s;
+    }
+    
+   </style>
+   <script type="text/javascript" charset="utf-8">
+   
+    function finishTest() {
+      var expected = 200;
+      var current = parseInt(window.getComputedStyle(document.getElementById('target')).left);
+      if (current == expected)
+        document.getElementById('result').innerHTML = "PASS - left property is " + current + "px as expected";
+      else
+        document.getElementById('result').innerHTML = "FAIL - left property is " + current + "px instead of " + expected + "px";
+
+      if (window.layoutTestController)
+        layoutTestController.notifyDone();
+    }
+    
+    function runTest() {
+      window.setTimeout(finishTest, 1000);
+    }
+    
+    function startTest() {
+      if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+      }
+      
+      var target = document.getElementById('target');
+      target.style.left = '200px';
+        
+      window.setTimeout(runTest, 0);
+    }
+    
+   </script>
+</head>
+<body onload="startTest()">
+  <h1>Test that transitions with a zero-duration and but a non-zero delay effectively work</h1>
+
+  <div id="target">
+  </div>
+
+  <div id="result">
+  </div>
+
+</body>
+</html>
index 7ed239e..e55eb7d 100644 (file)
@@ -1,3 +1,24 @@
+2009-01-08  Pierre-Olivier Latour  <pol@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Fixed CSS Transitions with zero-duration but non-zero-delay not starting or ending properly.
+
+        Also updated AnimationController::numberOfActiveAnimations() which now returns the number of "active" animations,
+        instead of simply the "running" ones.
+
+        https://bugs.webkit.org/show_bug.cgi?id=23177
+
+        Tests: transitions/zero-duration-with-non-zero-delay-end.html
+               transitions/zero-duration-with-non-zero-delay-start.html
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::fireAnimationEventsIfNeeded):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::animationTimerFired):
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimationPrivate::numberOfActiveAnimations):
+
 2009-01-08  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Oliver Hunt.
index c8b468d..60bc774 100644 (file)
@@ -729,7 +729,7 @@ void AnimationBase::fireAnimationEventsIfNeeded()
     ASSERT(elapsedDuration >= 0);
     
     // Check for end timeout
-    if (m_totalDuration > 0 && elapsedDuration >= m_totalDuration) {
+    if (m_totalDuration >= 0 && elapsedDuration >= m_totalDuration) {
         // Fire an end event
         updateStateMachine(AnimationStateInputEndTimerFired, m_totalDuration);
     }
index 98369c3..3b6cfcc 100644 (file)
@@ -233,6 +233,10 @@ void AnimationControllerPrivate::addEventToDispatch(PassRefPtr<Element> element,
 
 void AnimationControllerPrivate::animationTimerFired(Timer<AnimationControllerPrivate>*)
 {
+    // Make sure animationUpdateTime is updated, so that it is current even if no
+    // styleChange has happened (e.g. hardware animations)
+    setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet);
+
     // When the timer fires, all we do is call setChanged on all DOM nodes with running animations and then do an immediate
     // updateRendering.  It will then call back to us with new information.
     updateAnimationTimer(true);
index d4a8374..57cb774 100644 (file)
@@ -579,14 +579,14 @@ unsigned CompositeAnimationPrivate::numberOfActiveAnimations() const
     AnimationNameMap::const_iterator animationsEnd = m_keyframeAnimations.end();
     for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != animationsEnd; ++it) {
         KeyframeAnimation* anim = it->second.get();
-        if (anim->active())
+        if (anim->running())
             ++count;
     }
 
     CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
     for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
         ImplicitAnimation* anim = it->second.get();
-        if (anim->active())
+        if (anim->running())
             ++count;
     }