Title: [123414] trunk
Revision
123414
Author
[email protected]
Date
2012-07-23 18:14:58 -0700 (Mon, 23 Jul 2012)

Log Message

Source/WebCore: When using TextureMapper, WebKit does not retain final value of opacity in animations, unless it is specified on the last key frame.
https://bugs.webkit.org/show_bug.cgi?id=91322

Patch by Hanyee Kim <[email protected]> on 2012-07-23
Reviewed by Noam Rosenthal.

When -webkit-fill-mode is forwards, GraphicsLayerAnimation::apply does not apply
the property values defined in the last executing keyframe after the final iteration of animation.

This patch does not return right after the end of animation, but it keeps applying
the property values defined in the last executing keyframe.
Add normalizedAnimationValueForFillsForwards function that returns a normalized value of the
last executing keyframe.

Link to CSS Animations spec: http://www.w3.org/TR/css3-animations/#animation-fill-mode-property

Test: animations/fill-mode-forwards2.html

* platform/graphics/GraphicsLayerAnimation.cpp:
(WebCore::normalizedAnimationValueForFillsForwards):
(WebCore):
(WebCore::GraphicsLayerAnimation::apply):

LayoutTests: WebKit does not retain final value of opacity in animations, unless it is specified on the last key frame
https://bugs.webkit.org/show_bug.cgi?id=91322

Patch by Hanyee Kim <[email protected]> on 2012-07-23
Reviewed by Noam Rosenthal.

Added a test to check if the opacity has the right value after animation.

* animations/fill-mode-forwards2-expected.txt: Added.
* animations/fill-mode-forwards2.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123413 => 123414)


--- trunk/LayoutTests/ChangeLog	2012-07-24 00:57:18 UTC (rev 123413)
+++ trunk/LayoutTests/ChangeLog	2012-07-24 01:14:58 UTC (rev 123414)
@@ -1,3 +1,15 @@
+2012-07-23  Hanyee Kim  <[email protected]>
+
+        WebKit does not retain final value of opacity in animations, unless it is specified on the last key frame
+        https://bugs.webkit.org/show_bug.cgi?id=91322
+
+        Reviewed by Noam Rosenthal.
+
+        Added a test to check if the opacity has the right value after animation.
+
+        * animations/fill-mode-forwards2-expected.txt: Added.
+        * animations/fill-mode-forwards2.html: Added.
+
 2012-07-23  David Dorwin  <[email protected]>
 
         Fixed crash in webkitAddKey() when key parameter is null.

Added: trunk/LayoutTests/animations/fill-mode-forwards2-expected.txt (0 => 123414)


--- trunk/LayoutTests/animations/fill-mode-forwards2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/animations/fill-mode-forwards2-expected.txt	2012-07-24 01:14:58 UTC (rev 123414)
@@ -0,0 +1 @@
+PASS - Test working

Added: trunk/LayoutTests/animations/fill-mode-forwards2.html (0 => 123414)


--- trunk/LayoutTests/animations/fill-mode-forwards2.html	                        (rev 0)
+++ trunk/LayoutTests/animations/fill-mode-forwards2.html	2012-07-24 01:14:58 UTC (rev 123414)
@@ -0,0 +1,54 @@
+<html>
+<head>
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function animationEnded() {
+        var result = document.getElementById("result");
+        var square = document.getElementById('square');
+        var opacity = document.defaultView.getComputedStyle(square, null).getPropertyValue('opacity');
+
+        if (opacity == 0.5)
+            result.innerHTML = "PASS - Test working";
+        else
+            result.innerHTML = "FAIL - A opacity value must be 0.5";
+
+
+        if(window.testRunner)
+            testRunner.notifyDone();
+    }
+</script>
+<style>
+    body {
+        margin-left: 100px;
+        margin-top: 50px;
+    }
+    #square {
+        width: 100px;
+        height: 100px;
+        position: absolute;
+        top: 100px;
+        background-color: blue;
+        opacity: 0;
+        -webkit-animation-name: pop;
+        -webkit-animation-duration: 1s;
+	-webkit-animation-fill-mode: forwards;
+    }
+    @-webkit-keyframes pop {
+        0% { -webkit-transform: scale(0.05); opacity: 0; }
+        33% { -webkit-transform: scale(1.00); opacity: 1; }
+        66% { -webkit-transform: scale(1.66); opacity: 1; }
+        100% { -webkit-transform: scale(0.95); opacity: 0.5; }
+    }
+</style>
+</head>
+
+<body>
+    <div id="square" _onwebkitanimationend_="animationEnded();"></div>
+    <div id="result"></div>
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (123413 => 123414)


--- trunk/Source/WebCore/ChangeLog	2012-07-24 00:57:18 UTC (rev 123413)
+++ trunk/Source/WebCore/ChangeLog	2012-07-24 01:14:58 UTC (rev 123414)
@@ -1,3 +1,27 @@
+2012-07-23  Hanyee Kim  <[email protected]>
+
+        When using TextureMapper, WebKit does not retain final value of opacity in animations, unless it is specified on the last key frame.
+        https://bugs.webkit.org/show_bug.cgi?id=91322
+
+        Reviewed by Noam Rosenthal.
+
+        When -webkit-fill-mode is forwards, GraphicsLayerAnimation::apply does not apply
+        the property values defined in the last executing keyframe after the final iteration of animation.
+
+        This patch does not return right after the end of animation, but it keeps applying
+        the property values defined in the last executing keyframe.
+        Add normalizedAnimationValueForFillsForwards function that returns a normalized value of the
+        last executing keyframe.
+
+        Link to CSS Animations spec: http://www.w3.org/TR/css3-animations/#animation-fill-mode-property
+
+        Test: animations/fill-mode-forwards2.html
+
+        * platform/graphics/GraphicsLayerAnimation.cpp:
+        (WebCore::normalizedAnimationValueForFillsForwards):
+        (WebCore):
+        (WebCore::GraphicsLayerAnimation::apply):
+
 2012-07-23  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r123184, r123195, and r123197.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp (123413 => 123414)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp	2012-07-24 00:57:18 UTC (rev 123413)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp	2012-07-24 01:14:58 UTC (rev 123414)
@@ -48,6 +48,15 @@
     return shouldReverseAnimationValue(direction, loopCount) ? 1 - normalized : normalized;
 }
 
+static double normalizedAnimationValueForFillsForwards(double iterationCount, Animation::AnimationDirection direction)
+{
+    if (direction == Animation::AnimationDirectionNormal)
+        return 1;
+    if (direction == Animation::AnimationDirectionReverse)
+        return 0;
+    return shouldReverseAnimationValue(direction, iterationCount) ? 1 : 0;
+}
+
 static float applyOpacityAnimation(float fromOpacity, float toOpacity, double progress)
 {
     // Optimization: special case the edge values (0 and 1).
@@ -206,14 +215,17 @@
 
 void GraphicsLayerAnimation::apply(Client* client)
 {
-    if (state() == StoppedState)
+    if (!isActive())
         return;
 
     double totalRunningTime = m_state == PausedState ? m_pauseTime : WTF::currentTime() - m_startTime;
     double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animation->duration(), m_animation->direction());
 
-    if (m_animation->iterationCount() != Animation::IterationCountInfinite && totalRunningTime >= m_animation->duration() * m_animation->iterationCount())
+    if (m_animation->iterationCount() != Animation::IterationCountInfinite && totalRunningTime >= m_animation->duration() * m_animation->iterationCount()) {
         setState(StoppedState);
+        if (m_animation->fillsForwards())
+            normalizedValue = normalizedAnimationValueForFillsForwards(m_animation->iterationCount(), m_animation->direction());
+    }
 
     if (!normalizedValue) {
         applyInternal(client, m_keyframes.at(0), m_keyframes.at(1), 0);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to