Adding -webkit-animation-play-state back in
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jul 2009 18:03:03 +0000 (18:03 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jul 2009 18:03:03 +0000 (18:03 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=26867

        We've decided to keep -webkit-animation-play-state. So this
        just adds back in the code from https://bugs.webkit.org/show_bug.cgi?id=22907.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/animation-test-helpers.js
LayoutTests/animations/play-state-expected.txt [new file with mode: 0644]
LayoutTests/animations/play-state.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSParser.cpp
WebCore/css/CSSParser.h
WebCore/css/CSSPropertyNames.in
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSStyleSelector.h
WebCore/platform/animation/Animation.h
WebCore/rendering/style/RenderStyleConstants.h

index 8a0afc4..c95abaf 100644 (file)
@@ -1,3 +1,22 @@
+2009-07-29  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Adding -webkit-animation-play-state back in
+        https://bugs.webkit.org/show_bug.cgi?id=26867
+
+        This tests play-state for both hardware and software animations. I also
+        added the ability to disable the use of the pauseAnimation API because
+        that API interferes with the operation of play-state. I also fixed some
+        tests which now print out the -webkit-animation-play-state property
+
+        * animations/animation-test-helpers.js:
+        * animations/play-state-expected.txt: Added.
+        * animations/play-state.html: Added.
+        * platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
+        * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2009-07-29  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by Adam Treat.
index 21504d3..6fe1812 100644 (file)
@@ -29,11 +29,13 @@ Function parameters:
     If the CSS property name is "webkitTransform.N", expected value must be a number corresponding to the Nth element of the matrix
 
 */
-function runAnimationTest(expected, callback, event)
+function runAnimationTest(expected, callback, event, disablePauseAnimationAPI)
 {
     var result = "";
     var hasPauseAnimationAPI = ('layoutTestController' in window) && ('pauseAnimationAtTimeOnElementWithId' in layoutTestController);
-    
+    if (disablePauseAnimationAPI)
+        hasPauseAnimationAPI = false;
+
     function isCloseEnough(actual, desired, tolerance)
     {
         var diff = Math.abs(actual - desired);
diff --git a/LayoutTests/animations/play-state-expected.txt b/LayoutTests/animations/play-state-expected.txt
new file mode 100644 (file)
index 0000000..dd4f796
--- /dev/null
@@ -0,0 +1,9 @@
+This tests the operation of -webkit-animation-play-state. After 1 seconds the box should stop and after one more second it should start again. We test it both while in motion and when stopped.
+
+PASS - "webkitTransform" property for "box1" element at 0.5s saw something close to: 1,0,0,1,25,0
+PASS - "left" property for "box2" element at 0.5s saw something close to: 25
+PASS - "webkitTransform" property for "box1" element at 1.5s saw something close to: 1,0,0,1,50,0
+PASS - "left" property for "box2" element at 1.5s saw something close to: 50
+PASS - "webkitTransform" property for "box1" element at 2.5s saw something close to: 1,0,0,1,75,0
+PASS - "left" property for "box2" element at 2.5s saw something close to: 75
+
diff --git a/LayoutTests/animations/play-state.html b/LayoutTests/animations/play-state.html
new file mode 100644 (file)
index 0000000..f2d12a4
--- /dev/null
@@ -0,0 +1,82 @@
+<!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">
+  <title>Test of -webkit-animation-play-state</title>
+  <style type="text/css" media="screen">
+    #box1 {
+      height: 100px;
+      width: 100px;
+      background-color: blue;
+      margin: 0;
+      -webkit-animation-duration: 2s;
+      -webkit-animation-timing-function: linear;
+      -webkit-animation-name: "move1";
+      -webkit-animation-play-state: running;
+    }
+    @-webkit-keyframes "move1" {
+        from { -webkit-transform: translateX(0); }
+        to   { -webkit-transform: translateX(100px); }
+    }
+    #box2 {
+      position:absolute;
+      top: 260px;
+      height: 100px;
+      width: 100px;
+      background-color: red;
+      -webkit-animation-duration: 2s;
+      -webkit-animation-timing-function: linear;
+      -webkit-animation-name: "move2";
+    }
+    @-webkit-keyframes "move2" {
+        from { left: 0; }
+        to   { left: 100px; }
+    }
+  </style>
+  <script src="animation-test-helpers.js" type="text/javascript" charset="utf-8"></script>
+  <script type="text/javascript" charset="utf-8">
+    
+    const expectedValues = [
+      // [animation-name, time, element-id, property, expected-value, tolerance]
+      ["move1", 0.5, "box1", "webkitTransform", [1,0,0,1,25,0], 3],
+      ["move1", 1.5, "box1", "webkitTransform", [1,0,0,1,50,0], 3],
+      ["move1", 2.5, "box1", "webkitTransform", [1,0,0,1,75,0], 3],
+      ["move2", 0.5, "box2", "left", 25, 3],
+      ["move3", 1.5, "box2", "left", 50, 3],
+      ["move4", 2.5, "box2", "left", 75, 3],
+    ];
+    
+    function stop()
+    {
+        document.getElementById("box1").style.webkitAnimationPlayState = "paused";
+        document.getElementById("box2").style.webkitAnimationPlayState = "paused";
+    }
+
+    function start()
+    {
+        document.getElementById("box1").style.webkitAnimationPlayState = "running";
+        document.getElementById("box2").style.webkitAnimationPlayState = "running";
+    }
+
+    function setTimers()
+    {
+        setTimeout(stop, 1000);
+        setTimeout(start, 2000);
+    }
+    
+    runAnimationTest(expectedValues, setTimers, null, true);
+    
+  </script>
+</head>
+<body>
+<p>
+This tests the operation of -webkit-animation-play-state. After 1 seconds the box should stop and after one
+more second it should start again. We test it both while in motion and when stopped.
+<div id="box1">
+</div>
+<div id="box2">
+</div>
+<div id="result">
+</div>
+</body>
+</html>
index 2c52e60..c38eea4 100644 (file)
@@ -97,6 +97,7 @@ zoom: 1;
 -webkit-animation-duration: 0s;
 -webkit-animation-iteration-count: 1;
 -webkit-animation-name: none;
+-webkit-animation-play-state: running;
 -webkit-animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
 -webkit-appearance: none;
 -webkit-backface-visibility: visible;
index 69718f5..62e321a 100644 (file)
@@ -96,6 +96,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     -webkit-animation-duration: 0s
     -webkit-animation-iteration-count: 1
     -webkit-animation-name: none
+    -webkit-animation-play-state: running
     -webkit-animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1)
     -webkit-appearance: none
     -webkit-backface-visibility: visible
index 7795cbc..c235748 100644 (file)
@@ -192,6 +192,8 @@ rect: style.getPropertyValue(-webkit-animation-iteration-count) : 1
 rect: style.getPropertyCSSValue(-webkit-animation-iteration-count) : [object CSSValueList]
 rect: style.getPropertyValue(-webkit-animation-name) : none
 rect: style.getPropertyCSSValue(-webkit-animation-name) : [object CSSValueList]
+rect: style.getPropertyValue(-webkit-animation-play-state) : running
+rect: style.getPropertyCSSValue(-webkit-animation-play-state) : [object CSSValueList]
 rect: style.getPropertyValue(-webkit-animation-timing-function) : cubic-bezier(0.25, 0.1, 0.25, 1)
 rect: style.getPropertyCSSValue(-webkit-animation-timing-function) : [object CSSValueList]
 rect: style.getPropertyValue(-webkit-appearance) : none
@@ -596,6 +598,8 @@ g: style.getPropertyValue(-webkit-animation-iteration-count) : 1
 g: style.getPropertyCSSValue(-webkit-animation-iteration-count) : [object CSSValueList]
 g: style.getPropertyValue(-webkit-animation-name) : none
 g: style.getPropertyCSSValue(-webkit-animation-name) : [object CSSValueList]
+g: style.getPropertyValue(-webkit-animation-play-state) : running
+g: style.getPropertyCSSValue(-webkit-animation-play-state) : [object CSSValueList]
 g: style.getPropertyValue(-webkit-animation-timing-function) : cubic-bezier(0.25, 0.1, 0.25, 1)
 g: style.getPropertyCSSValue(-webkit-animation-timing-function) : [object CSSValueList]
 g: style.getPropertyValue(-webkit-appearance) : none
index 48036f4..559ea3d 100644 (file)
@@ -1,3 +1,32 @@
+2009-07-29  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Adding -webkit-animation-play-state back in
+        https://bugs.webkit.org/show_bug.cgi?id=26867
+
+        We've decided to keep -webkit-animation-play-state. So this
+        just adds back in the code from https://bugs.webkit.org/show_bug.cgi?id=22907.
+
+        Test: animations/play-state.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseAnimationPlayState):
+        (WebCore::CSSParser::parseAnimationProperty):
+        * css/CSSParser.h:
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        (WebCore::CSSStyleSelector::mapAnimationPlayState):
+        * css/CSSStyleSelector.h:
+        * platform/animation/Animation.h:
+        * rendering/style/RenderStyleConstants.h:
+        (WebCore::):
+
 2009-07-29  Jakub Wieczorek  <faw217@gmail.com>
 
         Reviewed by Simon Hausmann.
index 56e939b..20e0695 100644 (file)
@@ -149,6 +149,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitAnimationDuration,
     CSSPropertyWebkitAnimationIterationCount,
     CSSPropertyWebkitAnimationName,
+    CSSPropertyWebkitAnimationPlayState,
     CSSPropertyWebkitAnimationTimingFunction,
     CSSPropertyWebkitAppearance,
     CSSPropertyWebkitBackfaceVisibility,
@@ -1183,6 +1184,21 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
             return list.release();
         }
+        case CSSPropertyWebkitAnimationPlayState: {
+            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+            const AnimationList* t = style->animations();
+            if (t) {
+                for (size_t i = 0; i < t->size(); ++i) {
+                    int prop = t->animation(i)->playState();
+                    if (prop == AnimPlayStatePlaying)
+                        list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
+                    else
+                        list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused));
+                }
+            } else
+                list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
+            return list.release();
+        }
         case CSSPropertyWebkitAnimationTimingFunction:
             return getTimingFunctionValue(style->animations());
         case CSSPropertyWebkitAppearance:
index e380575..b483141 100644 (file)
@@ -1348,6 +1348,7 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSSPropertyWebkitAnimationDirection:
     case CSSPropertyWebkitAnimationDuration:
     case CSSPropertyWebkitAnimationName:
+    case CSSPropertyWebkitAnimationPlayState:
     case CSSPropertyWebkitAnimationIterationCount:
     case CSSPropertyWebkitAnimationTimingFunction:
     case CSSPropertyWebkitTransitionDelay:
@@ -2446,6 +2447,14 @@ PassRefPtr<CSSValue> CSSParser::parseAnimationName()
     return 0;
 }
 
+PassRefPtr<CSSValue> CSSParser::parseAnimationPlayState()
+{
+    CSSParserValue* value = m_valueList->current();
+    if (value->id == CSSValueRunning || value->id == CSSValuePaused)
+        return CSSPrimitiveValue::createIdentifier(value->id);
+    return 0;
+}
+
 PassRefPtr<CSSValue> CSSParser::parseAnimationProperty()
 {
     CSSParserValue* value = m_valueList->current();
@@ -2567,6 +2576,11 @@ bool CSSParser::parseAnimationProperty(int propId, RefPtr<CSSValue>& result)
                     if (currValue)
                         m_valueList->next();
                     break;
+                case CSSPropertyWebkitAnimationPlayState:
+                    currValue = parseAnimationPlayState();
+                    if (currValue)
+                        m_valueList->next();
+                    break;
                 case CSSPropertyWebkitTransitionProperty:
                     currValue = parseAnimationProperty();
                     if (currValue)
index 3319a2a..5a2b283 100644 (file)
@@ -96,6 +96,7 @@ namespace WebCore {
         PassRefPtr<CSSValue> parseAnimationDuration();
         PassRefPtr<CSSValue> parseAnimationIterationCount();
         PassRefPtr<CSSValue> parseAnimationName();
+        PassRefPtr<CSSValue> parseAnimationPlayState();
         PassRefPtr<CSSValue> parseAnimationProperty();
         PassRefPtr<CSSValue> parseAnimationTimingFunction();
 
index 69c8eca..9ef0591 100644 (file)
@@ -150,6 +150,7 @@ zoom
 -webkit-animation-duration
 -webkit-animation-iteration-count
 -webkit-animation-name
+-webkit-animation-play-state
 -webkit-animation-timing-function
 -webkit-appearance
 -webkit-backface-visibility
index 0f10aaf..d57717b 100644 (file)
@@ -5068,6 +5068,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyWebkitAnimationName:
         HANDLE_ANIMATION_VALUE(name, Name, value)
         return;
+    case CSSPropertyWebkitAnimationPlayState:
+        HANDLE_ANIMATION_VALUE(playState, PlayState, value)
+        return;
     case CSSPropertyWebkitAnimationTimingFunction:
         HANDLE_ANIMATION_VALUE(timingFunction, TimingFunction, value)
         return;
@@ -5415,6 +5418,18 @@ void CSSStyleSelector::mapAnimationName(Animation* layer, CSSValue* value)
         layer->setName(primitiveValue->getStringValue());
 }
 
+void CSSStyleSelector::mapAnimationPlayState(Animation* layer, CSSValue* value)
+{
+    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+        layer->setPlayState(Animation::initialAnimationPlayState());
+        return;
+    }
+
+    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+    EAnimPlayState playState = (primitiveValue->getIdent() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying;
+    layer->setPlayState(playState);
+}
+
 void CSSStyleSelector::mapAnimationProperty(Animation* animation, CSSValue* value)
 {
     if (value->cssValueType() == CSSValue::CSS_INITIAL) {
index d86dd8c..2b92a38 100644 (file)
@@ -233,6 +233,7 @@ public:
         void mapAnimationDuration(Animation*, CSSValue*);
         void mapAnimationIterationCount(Animation*, CSSValue*);
         void mapAnimationName(Animation*, CSSValue*);
+        void mapAnimationPlayState(Animation*, CSSValue*);
         void mapAnimationProperty(Animation*, CSSValue*);
         void mapAnimationTimingFunction(Animation*, CSSValue*);
 
index 9e1e8e1..306a1b9 100644 (file)
@@ -35,12 +35,6 @@ namespace WebCore {
 const int cAnimateNone = 0;
 const int cAnimateAll = -2;
 
-// These were in RenderStyle, but have been moved here as
-// animation-play-state is in the process of being removed.
-
-const unsigned AnimPlayStatePlaying = 0;
-const unsigned AnimPlayStatePaused = 1;
-
 class Animation : public RefCounted<Animation> {
 public:
     ~Animation();
index 1b3e1f4..c491816 100644 (file)
@@ -212,6 +212,11 @@ enum StyleContentType {
 
 enum EBorderFit { BorderFitBorder, BorderFitLines };
 
+enum EAnimPlayState {
+    AnimPlayStatePlaying = 0x0,
+    AnimPlayStatePaused = 0x1
+};
+
 enum ETimingFunctionType { LinearTimingFunction, CubicBezierTimingFunction };
 
 enum EWhiteSpace {