Bug 1063992 - Set the animation player hold time to zero when it is initially paused; r=dzbarsky
authorBrian Birtles <birtles@gmail.com>
Tue, 09 Sep 2014 08:55:34 +0900
changeset 204226 8ef4e254bd15c3be61820d7a3b82c23b766469be
parent 204225 8a0f3c42df5d799491970c015c634f8056a5ad84
child 204227 792b0721903ec0ec0b61175cd1dc7624c50fc135
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs1063992, 1033114
Bug 1063992 - Set the animation player hold time to zero when it is initially paused; r=dzbarsky This patch fixes a regression from bug 1033114, m-c changeset 9db3e43c19c1. That changeset changed the meaning of mHoldTime (despite the commit message which erroneously refers to mStartTime) to make it an offset from the start time rather than a timestamp. However, it failed to update the case when we have an initially-paused player. In that case the offset should be zero but the existing code set it to the same value as the start time (which is, itself, an offset from the beginning of the timeline) and the above changeset failed to update that.
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -452,17 +452,17 @@ nsAnimationManager::BuildAnimations(nsSt
     nsRefPtr<Animation> destAnim =
       new Animation(mPresContext->Document(), timing, src.GetName());
     dest->mStartTime = now;
     dest->mPlayState = src.GetPlayState();
     if (dest->IsPaused()) {
-      dest->mHoldTime = now;
+      dest->mHoldTime.SetValue(TimeDuration(0));
     // While current drafts of css3-animations say that later keyframes
     // with the same key entirely replace earlier ones (no cascading),
     // this is a bad idea and contradictory to the rest of CSS.  So
     // we're going to keep all the keyframes for each key and then do
     // the replacement on a per-property basis rather than a per-rule
     // basis, just like everything else in CSS.
--- a/layout/style/test/test_animations.html
+++ b/layout/style/test/test_animations.html
@@ -1126,16 +1126,29 @@ is_approx(px_to_num(cs.marginBottom), 10
           "animation-play-state test 4 at 9550ms");
 is(cs.marginRight, "0px", "animation-play-state test 2 at 10050ms");
 is(cs.marginTop, "0px", "animation-play-state test 3 at 10050ms");
 is_approx(px_to_num(cs.marginBottom), 100 * gTF.ease_in_out(0.8), 0.01,
           "animation-play-state test 4 at 10050ms");
+// an initially paused animation (bug 1063992)
+new_div("animation: anim1 1s paused both");
+is(cs.marginLeft, "0px", "animation-play-state test 5, at 0s");
+is(cs.marginLeft, "0px", "animation-play-state test 5, at 0.5s");
+div.style.animationPlayState = "running";
+is(cs.marginLeft, "0px",
+   "animation-play-state test 5, at 0.5s after unpausing");
+is(cs.marginLeft, "80px",
+   "animation-play-state test 5, at 1s after unpaused");
  * css3-animations:  3.8. The 'animation-delay' Property
  * http://dev.w3.org/csswg/css3-animations/#the-animation-delay-property-
 // test positive delay
 new_div("animation: anim2 1s 0.5s ease-out");
 is(cs.marginRight, "0px", "positive delay test at 0ms");