Bug 1153734 part 4 - Rename other uses of 'source' and 'source content'; r=jwatt

This patch also tightens up a one or two references to 'target effect' replacing
them with just 'effect'. This is because 'target effect' is longer and easily
confused with 'target element'. 'effect' should be sufficient. 'target element'
is a term from the Web Animations specification and in that context, simply
referring to the 'effect' would sound a little odd.
This commit is contained in:
Brian Birtles 2015-04-15 08:48:21 +09:00
parent 717246367d
commit 977582d70a
5 changed files with 38 additions and 39 deletions

View File

@ -127,7 +127,7 @@ AnimationPlayer::SetCurrentTime(const TimeDuration& aSeekTime)
}
UpdateFinishedState(true);
UpdateSourceContent();
UpdateEffect();
PostUpdate();
}
@ -171,7 +171,7 @@ AnimationPlayer::PlayState() const
return AnimationPlayState::Paused;
}
if ((mPlaybackRate > 0.0 && currentTime.Value() >= SourceContentEnd()) ||
if ((mPlaybackRate > 0.0 && currentTime.Value() >= EffectEnd()) ||
(mPlaybackRate < 0.0 && currentTime.Value().ToMilliseconds() <= 0.0)) {
return AnimationPlayState::Finished;
}
@ -367,14 +367,14 @@ AnimationPlayer::Cancel()
mHoldTime.SetNull();
mStartTime.SetNull();
UpdateSourceContent();
UpdateEffect();
}
void
AnimationPlayer::UpdateRelevance()
{
bool wasRelevant = mIsRelevant;
mIsRelevant = HasCurrentSource() || HasInEffectSource();
mIsRelevant = HasCurrentEffect() || IsInEffect();
// Notify animation observers.
if (wasRelevant && !mIsRelevant) {
@ -476,8 +476,8 @@ AnimationPlayer::ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
if (!timeToUse.IsNull()) {
mHoldTime.SetValue((timeToUse.Value() - mStartTime.Value())
.MultDouble(mPlaybackRate));
// Push the change down to the source content
UpdateSourceContent();
// Push the change down to the effect
UpdateEffect();
updatedHoldTime = true;
}
}
@ -508,14 +508,14 @@ AnimationPlayer::DoPlay(LimitBehavior aLimitBehavior)
(currentTime.IsNull() ||
(aLimitBehavior == LimitBehavior::AutoRewind &&
(currentTime.Value().ToMilliseconds() < 0.0 ||
currentTime.Value() >= SourceContentEnd())))) {
currentTime.Value() >= EffectEnd())))) {
mHoldTime.SetValue(TimeDuration(0));
} else if (mPlaybackRate < 0.0 &&
(currentTime.IsNull() ||
(aLimitBehavior == LimitBehavior::AutoRewind &&
(currentTime.Value().ToMilliseconds() <= 0.0 ||
currentTime.Value() > SourceContentEnd())))) {
mHoldTime.SetValue(TimeDuration(SourceContentEnd()));
currentTime.Value() > EffectEnd())))) {
mHoldTime.SetValue(TimeDuration(EffectEnd()));
} else if (mPlaybackRate == 0.0 && currentTime.IsNull()) {
mHoldTime.SetValue(TimeDuration(0));
}
@ -647,30 +647,29 @@ AnimationPlayer::PauseAt(const TimeDuration& aReadyTime)
void
AnimationPlayer::UpdateTiming()
{
// We call UpdateFinishedState before UpdateSourceContent because the former
// We call UpdateFinishedState before UpdateEffect because the former
// can change the current time, which is used by the latter.
UpdateFinishedState();
UpdateSourceContent();
UpdateEffect();
}
void
AnimationPlayer::UpdateFinishedState(bool aSeekFlag)
{
Nullable<TimeDuration> currentTime = GetCurrentTime();
TimeDuration targetEffectEnd = TimeDuration(SourceContentEnd());
TimeDuration effectEnd = TimeDuration(EffectEnd());
if (!mStartTime.IsNull() &&
mPendingState == PendingState::NotPending) {
if (mPlaybackRate > 0.0 &&
!currentTime.IsNull() &&
currentTime.Value() >= targetEffectEnd) {
currentTime.Value() >= effectEnd) {
if (aSeekFlag) {
mHoldTime = currentTime;
} else if (!mPreviousCurrentTime.IsNull()) {
mHoldTime.SetValue(std::max(mPreviousCurrentTime.Value(),
targetEffectEnd));
mHoldTime.SetValue(std::max(mPreviousCurrentTime.Value(), effectEnd));
} else {
mHoldTime.SetValue(targetEffectEnd);
mHoldTime.SetValue(effectEnd);
}
} else if (mPlaybackRate < 0.0 &&
!currentTime.IsNull() &&
@ -706,7 +705,7 @@ AnimationPlayer::UpdateFinishedState(bool aSeekFlag)
}
void
AnimationPlayer::UpdateSourceContent()
AnimationPlayer::UpdateEffect()
{
if (mEffect) {
mEffect->SetParentTime(GetCurrentTime());
@ -764,7 +763,7 @@ AnimationPlayer::IsFinished() const
// and we need this much more messy check to see if we're finished.
Nullable<TimeDuration> currentTime = GetCurrentTime();
return !currentTime.IsNull() &&
((mPlaybackRate > 0.0 && currentTime.Value() >= SourceContentEnd()) ||
((mPlaybackRate > 0.0 && currentTime.Value() >= EffectEnd()) ||
(mPlaybackRate < 0.0 && currentTime.Value().ToMilliseconds() <= 0.0));
}
@ -776,15 +775,15 @@ AnimationPlayer::IsPossiblyOrphanedPendingPlayer() const
//
// This covers the following cases:
//
// * We started playing but our source content's target element was orphaned
// * We started playing but our effect's target element was orphaned
// or bound to a different document.
// (note that for the case of our source content changing we should handle
// that in SetSource)
// (note that for the case of our effect changing we should handle
// that in SetEffect)
// * We started playing but our timeline became inactive.
// In this case the pending player tracker will drop us from its hashmap
// when we have been painted.
// * When we started playing we couldn't find a PendingPlayerTracker to
// register with (perhaps the source content had no document) so we simply
// register with (perhaps the effect had no document) so we simply
// set mPendingState in DoPlay and relied on this method to catch us on the
// next tick.
@ -823,7 +822,7 @@ AnimationPlayer::IsPossiblyOrphanedPendingPlayer() const
}
StickyTimeDuration
AnimationPlayer::SourceContentEnd() const
AnimationPlayer::EffectEnd() const
{
if (!mEffect) {
return StickyTimeDuration(0);

View File

@ -120,7 +120,7 @@ public:
* Set the time to use for starting or pausing a pending player.
*
* Typically, when a player is played, it does not start immediately but is
* added to a table of pending players on the document of its source content.
* added to a table of pending players on the document of its effect.
* In the meantime it sets its hold time to the time from which playback
* should begin.
*
@ -212,15 +212,15 @@ public:
mPendingState == PendingState::PausePending;
}
bool HasInPlaySource() const
bool HasInPlayEffect() const
{
return GetEffect() && GetEffect()->IsInPlay(*this);
}
bool HasCurrentSource() const
bool HasCurrentEffect() const
{
return GetEffect() && GetEffect()->IsCurrent(*this);
}
bool HasInEffectSource() const
bool IsInEffect() const
{
return GetEffect() && GetEffect()->IsInEffect();
}
@ -235,9 +235,9 @@ public:
*/
bool IsPlaying() const
{
// We need to have a source animation in its active interval, and
// We need to have an effect in its active interval, and
// be either running or waiting to run.
return HasInPlaySource() &&
return HasInPlayEffect() &&
(PlayState() == AnimationPlayState::Running ||
mPendingState == PendingState::PlayPending);
}
@ -253,13 +253,13 @@ public:
// running on the compositor).
bool CanThrottle() const;
// Updates |aStyleRule| with the animation values of this player's source
// content, if any.
// Updates |aStyleRule| with the animation values of this player's effect,
// if any.
// Any properties already contained in |aSetProperties| are not changed. Any
// properties that are changed are added to |aSetProperties|.
// |aNeedsRefreshes| will be set to true if this player expects to update
// the style rule on the next refresh driver tick as well (because it
// is running and has source content to sample).
// is running and has an effect to sample).
void ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
nsCSSPropertySet& aSetProperties,
bool& aNeedsRefreshes);
@ -282,7 +282,7 @@ protected:
void UpdateTiming();
void UpdateFinishedState(bool aSeekFlag = false);
void UpdateSourceContent();
void UpdateEffect();
void FlushStyle() const;
void PostUpdate();
/**
@ -295,7 +295,7 @@ protected:
bool IsFinished() const;
bool IsPossiblyOrphanedPendingPlayer() const;
StickyTimeDuration SourceContentEnd() const;
StickyTimeDuration EffectEnd() const;
nsIDocument* GetRenderedDocument() const;
nsPresContext* GetPresContext() const;
@ -317,7 +317,7 @@ protected:
// See http://w3c.github.io/web-animations/#current-ready-promise
nsRefPtr<Promise> mReady;
// A Promise that is resolved when we reach the end of the source content, or
// A Promise that is resolved when we reach the end of the effect, or
// 0 when playing backwards. The Promise is replaced if the animation is
// finished but then a state change makes it not finished.
// This object is lazily created by GetFinished.

View File

@ -422,7 +422,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
continue;
}
dom::KeyframeEffectReadonly* effect = player->GetEffect();
MOZ_ASSERT(effect, "A playing player should have a target effect");
MOZ_ASSERT(effect, "A playing player should have an effect");
const AnimationProperty* property =
effect->GetAnimationOfProperty(aProperty);
if (!property) {

View File

@ -914,7 +914,7 @@ bool
AnimationPlayerCollection::HasCurrentAnimations() const
{
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
if (mPlayers[playerIdx]->HasCurrentSource()) {
if (mPlayers[playerIdx]->HasCurrentEffect()) {
return true;
}
}

View File

@ -230,7 +230,7 @@ nsAnimationManager::MaybeUpdateCascadeResults(AnimationPlayerCollection* aCollec
CSSAnimationPlayer* player =
aCollection->mPlayers[playerIdx]->AsCSSAnimationPlayer();
if (player->HasInEffectSource() != player->mInEffectForCascadeResults) {
if (player->IsInEffect() != player->mInEffectForCascadeResults) {
// Update our own cascade results.
mozilla::dom::Element* element = aCollection->GetElementToRestyle();
if (element) {
@ -806,7 +806,7 @@ nsAnimationManager::UpdateCascadeResults(
aElementAnimations->mPlayers[playerIdx]->AsCSSAnimationPlayer();
KeyframeEffectReadonly* effect = player->GetEffect();
player->mInEffectForCascadeResults = player->HasInEffectSource();
player->mInEffectForCascadeResults = player->IsInEffect();
if (!effect) {
continue;