Bug 1070745 part 7 - Add style flush at the beginning of Play(); r=dholbert
authorBrian Birtles <birtles@gmail.com>
Mon, 20 Oct 2014 13:55:44 +0900
changeset 211170 8d9236ef0f6be2d9111beb226b92d64858c42ab3
parent 211169 445a34c37d9508ab2a9cf8fb7ee59d691eb0c0dc
child 211171 33635f1b4005efe3e0a507557b8af922e408e1ae
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdholbert
bugs1070745, 1074630
milestone36.0a1
Bug 1070745 part 7 - Add style flush at the beginning of Play(); r=dholbert For players running CSS animations and CSS transitions we should perform a style flush before running play() so that we are operating on the most up-to-date state of animation-play-state. For transitions, which don't have a play-state property, we will still need to run this style flush before running play() to get the right finishing behavior if transition-duration has changed. We haven't implemented finishing yet (that's bug 1074630) but I've kept the flush for both cases now since I'm afraid we'll forget it later. Also, since we don't have a subclass of AnimationPlayer for transitions yet I've put the style flush in the base class. In future, when we add CSSTransitionPlayer we can move the flush to only those players that need up to date style information.
dom/animation/AnimationPlayer.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -79,17 +79,26 @@ AnimationPlayer::Pause(UpdateFlags aFlag
   if (aFlags == eUpdateStyle) {
     MaybePostRestyle();
   }
 }
 
 void
 AnimationPlayer::PlayFromJS()
 {
-  // TODO (flush styles etc.)
+  // Flush style to ensure that any properties controlling animation state
+  // (e.g. animation-play-state) are fully updated before we proceed.
+  //
+  // Note that this might trigger PlayFromStyle()/PauseFromStyle() on this
+  // object.
+  //
+  // FIXME: Once we introduce CSSTransitionPlayer, this should move to an
+  // override of PlayFromJS in CSSAnimationPlayer and CSSTransitionPlayer and
+  // we should skip it in the general case.
+  FlushStyle();
 
   Play(eUpdateStyle);
 }
 
 void
 AnimationPlayer::PauseFromJS()
 {
   Pause(eUpdateStyle);