Bug 1073336 part 7 - Move style flushing to CSSAnimationPlayer and CSSTransitionPlayer; r=dbaron

Previously AnimationPlayer::Play() and AnimationPlayer::PlayState() would flush
styles as part of their operation. This, however, is only needed when the player
corresponds to a CSS Animation or CSS Transition. Now that we have concrete
subclasses for each of these cases we can move style flushing to the subclasses
and remove it from the base class (which is expected to be shared with
animations that are not dependent on style).
This commit is contained in:
Brian Birtles
2014-11-17 13:45:58 +09:00
parent fc90515b33
commit e5f74b42c4
6 changed files with 44 additions and 24 deletions

View File

@@ -115,31 +115,9 @@ AnimationPlayer::GetCurrentTimeAsDouble() const
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
}
AnimationPlayState
AnimationPlayer::PlayStateFromJS() const
{
// FIXME: Once we introduce CSSTransitionPlayer, this should move to an
// override of PlayStateFromJS in CSSAnimationPlayer and CSSTransitionPlayer
// and we should skip it in the general case.
FlushStyle();
return PlayState();
}
void
AnimationPlayer::PlayFromJS()
{
// 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);
}

View File

@@ -78,8 +78,8 @@ public:
// script but when called from script we perform extra steps such
// as flushing style or converting the return type.
Nullable<double> GetCurrentTimeAsDouble() const;
AnimationPlayState PlayStateFromJS() const;
void PlayFromJS();
virtual AnimationPlayState PlayStateFromJS() const { return PlayState(); }
virtual void PlayFromJS();
void PauseFromJS();
void SetSource(Animation* aSource);

View File

@@ -41,6 +41,24 @@ CSSAnimationPlayer::Pause(UpdateFlags aUpdateFlags)
AnimationPlayer::Pause(aUpdateFlags);
}
mozilla::dom::AnimationPlayState
CSSAnimationPlayer::PlayStateFromJS() const
{
// Flush style to ensure that any properties controlling animation state
// (e.g. animation-play-state) are fully updated.
FlushStyle();
return AnimationPlayer::PlayStateFromJS();
}
void
CSSAnimationPlayer::PlayFromJS()
{
// Note that flushing style below might trigger calls to
// PlayFromStyle()/PauseFromStyle() on this object.
FlushStyle();
AnimationPlayer::PlayFromJS();
}
void
CSSAnimationPlayer::PlayFromStyle()
{

View File

@@ -66,6 +66,9 @@ public:
virtual void Play(UpdateFlags aUpdateFlags) MOZ_OVERRIDE;
virtual void Pause(UpdateFlags aUpdateFlags) MOZ_OVERRIDE;
virtual dom::AnimationPlayState PlayStateFromJS() const MOZ_OVERRIDE;
virtual void PlayFromJS() MOZ_OVERRIDE;
void PlayFromStyle();
void PauseFromStyle();

View File

@@ -70,6 +70,24 @@ ElementPropertyTransition::CurrentValuePortion() const
.GetValue(computedTiming.mTimeFraction);
}
/*****************************************************************************
* CSSTransitionPlayer *
*****************************************************************************/
mozilla::dom::AnimationPlayState
CSSTransitionPlayer::PlayStateFromJS() const
{
FlushStyle();
return AnimationPlayer::PlayStateFromJS();
}
void
CSSTransitionPlayer::PlayFromJS()
{
FlushStyle();
AnimationPlayer::PlayFromJS();
}
/*****************************************************************************
* nsTransitionManager *
*****************************************************************************/

View File

@@ -76,6 +76,9 @@ public:
virtual CSSTransitionPlayer*
AsCSSTransitionPlayer() MOZ_OVERRIDE { return this; }
virtual dom::AnimationPlayState PlayStateFromJS() const MOZ_OVERRIDE;
virtual void PlayFromJS() MOZ_OVERRIDE;
protected:
virtual ~CSSTransitionPlayer() { }
};