Bug 1244638 - Part 1:implement AnimationEffectTiming iterationStart. r=birtles, r=smaug
authorDaisuke Akatsuka <daisuke@mozilla-japan.org>
Fri, 11 Mar 2016 17:22:32 +0900
changeset 288502 a25e46c8d9c598f3232ea676a0deb78ac6411f2d
parent 288501 0e90c6048f3f5567ac135751c2849932a6641ac9
child 288503 729fd971cfa66054610a55acef9d8101c33f0b67
push id30082
push userryanvm@gmail.com
push dateSun, 13 Mar 2016 23:08:35 +0000
treeherdermozilla-central@f0c0480732d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, smaug
bugs1244638
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1244638 - Part 1:implement AnimationEffectTiming iterationStart. r=birtles, r=smaug MozReview-Commit-ID: K9UfNViDMHz
dom/animation/AnimationEffectTiming.cpp
dom/animation/AnimationEffectTiming.h
dom/webidl/AnimationEffectTiming.webidl
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/animation-effect-timing/iterationStart.html
--- a/dom/animation/AnimationEffectTiming.cpp
+++ b/dom/animation/AnimationEffectTiming.cpp
@@ -35,16 +35,28 @@ AnimationEffectTiming::SetEndDelay(doubl
     return;
   }
   mTiming.mEndDelay = endDelay;
 
   NotifyTimingUpdate();
 }
 
 void
+AnimationEffectTiming::SetIterationStart(double aIterationStart)
+{
+  if (mTiming.mIterationStart == aIterationStart) {
+    return;
+  }
+  mTiming.mIterationStart = aIterationStart;
+  if (mEffect) {
+    mEffect->NotifySpecifiedTimingUpdated();
+  }
+}
+
+void
 AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration,
                                    ErrorResult& aRv)
 {
   Maybe<StickyTimeDuration> newDuration =
     TimingParams::ParseDuration(aDuration, aRv);
   if (aRv.Failed()) {
     return;
   }
--- a/dom/animation/AnimationEffectTiming.h
+++ b/dom/animation/AnimationEffectTiming.h
@@ -20,16 +20,17 @@ public:
     : AnimationEffectTimingReadOnly(aTiming)
     , mEffect(aEffect) { }
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   void Unlink() override { mEffect = nullptr; }
 
   void SetEndDelay(double aEndDelay);
+  void SetIterationStart(double aIterationStart);
   void SetDuration(const UnrestrictedDoubleOrString& aDuration,
                    ErrorResult& aRv);
 
 private:
   void NotifyTimingUpdate();
   KeyframeEffect* MOZ_NON_OWNING_REF mEffect;
 };
 
--- a/dom/webidl/AnimationEffectTiming.webidl
+++ b/dom/webidl/AnimationEffectTiming.webidl
@@ -7,24 +7,23 @@
  * https://w3c.github.io/web-animations/#animationeffecttiming
  *
  * Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Func="nsDocument::IsWebAnimationsEnabled"]
 interface AnimationEffectTiming : AnimationEffectTimingReadOnly {
-   //Bug 1244633 - implement AnimationEffectTiming delay
-   //inherit attribute double                             delay;
-   inherit attribute double                             endDelay;
-   //Bug 1244637 - implement AnimationEffectTiming fill
-   //inherit attribute FillMode                           fill;
-   //Bug 1244638 - implement AnimationEffectTiming iterationStart
-   //inherit attribute double                             iterationStart;
-   //Bug 1244640 - implement AnimationEffectTiming iterations
-   //inherit attribute unrestricted double                iterations;
+  //Bug 1244633 - implement AnimationEffectTiming delay
+  //inherit attribute double                             delay;
+  inherit attribute double                             endDelay;
+  //Bug 1244637 - implement AnimationEffectTiming fill
+  //inherit attribute FillMode                           fill;
+  inherit attribute double                             iterationStart;
+  //Bug 1244640 - implement AnimationEffectTiming iterations
+  //inherit attribute unrestricted double                iterations;
   [SetterThrows]
   inherit attribute (unrestricted double or DOMString) duration;
-   //Bug 1244642 - implement AnimationEffectTiming direction
-   //inherit attribute PlaybackDirection                  direction;
-   //Bug 1244643 - implement AnimationEffectTiming easing
-   //inherit attribute DOMString                          easing;
+  //Bug 1244642 - implement AnimationEffectTiming direction
+  //inherit attribute PlaybackDirection                  direction;
+  //Bug 1244643 - implement AnimationEffectTiming easing
+  //inherit attribute DOMString                          easing;
 };
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -28345,16 +28345,20 @@
         "path": "web-animations/animation-effect-timing/getAnimations.html",
         "url": "/web-animations/animation-effect-timing/getAnimations.html"
       },
       {
         "path": "web-animations/animation-effect-timing/getComputedStyle.html",
         "url": "/web-animations/animation-effect-timing/getComputedStyle.html"
       },
       {
+        "path": "web-animations/animation-effect-timing/iterationStart.html",
+        "url": "/web-animations/animation-effect-timing/iterationStart.html"
+      },
+      {
         "path": "web-animations/animation-node/animation-node-after.html",
         "url": "/web-animations/animation-node/animation-node-after.html"
       },
       {
         "path": "web-animations/animation-node/animation-node-before.html",
         "url": "/web-animations/animation-node/animation-node-before.html"
       },
       {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/animation-effect-timing/iterationStart.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>iterationStart tests</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-iterationstart">
+<link rel="author" title="Daisuke Akatsuka" href="mailto:daisuke@mozilla-japan.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+test(function(t) {
+  var div = createDiv(t);
+  var anim = div.animate({ opacity: [ 0, 1 ] },
+                         { iterationStart: 0.2,
+                           iterations: 1,
+                           fill: 'both',
+                           duration: 100,
+                           delay: 1 });
+  anim.effect.timing.iterationStart = 2.5;
+  assert_equals(anim.effect.getComputedTiming().progress, 0.5);
+  assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
+}, 'Test that changing the iterationStart affects computed timing ' +
+   'when backwards-filling');
+
+test(function(t) {
+  var div = createDiv(t);
+  var anim = div.animate({ opacity: [ 0, 1 ] },
+                         { iterationStart: 0.2,
+                           iterations: 1,
+                           fill: 'both',
+                           duration: 100,
+                           delay: 0 });
+  anim.effect.timing.iterationStart = 2.5;
+  assert_equals(anim.effect.getComputedTiming().progress, 0.5);
+  assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
+}, 'Test that changing the iterationStart affects computed timing ' +
+   'during the active phase');
+
+test(function(t) {
+  var div = createDiv(t);
+  var anim = div.animate({ opacity: [ 0, 1 ] },
+                         { iterationStart: 0.2,
+                           iterations: 1,
+                           fill: 'both',
+                           duration: 100,
+                           delay: 0 });
+  anim.finish();
+  anim.effect.timing.iterationStart = 2.5;
+  assert_equals(anim.effect.getComputedTiming().progress, 0.5);
+  assert_equals(anim.effect.getComputedTiming().currentIteration, 3);
+}, 'Test that changing the iterationStart affects computed timing ' +
+   'when forwards-filling');
+</script>
+</body>