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.
--- 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);