Bug 1040543 part 9 - Move IsFinishedTransition from AnimationPlayer to Animation; r=bz

As the third step in dividing functionality between AnimationPlayer and
Animation this patch moves the mIsFinishedTransition member and related methods
from AnimationPlayer to Animation.

At the same time we rename SetFinishedTransition to SetIsFinishedTransition.
This commit is contained in:
Brian Birtles 2014-08-10 17:06:51 +10:00
Родитель 2520d366a6
Коммит 46562ab4f3
6 изменённых файлов: 37 добавлений и 31 удалений

Просмотреть файл

@ -124,6 +124,7 @@ public:
Animation(nsIDocument* aDocument, const AnimationTiming &aTiming) Animation(nsIDocument* aDocument, const AnimationTiming &aTiming)
: mDocument(aDocument) : mDocument(aDocument)
, mTiming(aTiming) , mTiming(aTiming)
, mIsFinishedTransition(false)
{ {
SetIsDOMBinding(); SetIsDOMBinding();
} }
@ -181,7 +182,27 @@ public:
// Return the duration of the active interval for the given timing parameters. // Return the duration of the active interval for the given timing parameters.
static TimeDuration ActiveDuration(const AnimationTiming& aTiming); static TimeDuration ActiveDuration(const AnimationTiming& aTiming);
// After transitions finish they need to be retained for one throttle-able
// cycle (for reasons see explanation in
// layout/style/nsTransitionManager.cpp).
// In the meantime, however, they should be ignored.
bool IsFinishedTransition() const {
return mIsFinishedTransition;
}
void SetIsFinishedTransition() {
// FIXME: Restore assertion of AsTransition once we make transitions
// a subclass of Animations
// MOZ_ASSERT(AsTransition(),
// "Calling SetIsFinishedTransition but it's not a transition");
mIsFinishedTransition = true;
}
bool IsCurrent() const { bool IsCurrent() const {
if (IsFinishedTransition()) {
return false;
}
ComputedTiming computedTiming = GetComputedTiming(); ComputedTiming computedTiming = GetComputedTiming();
return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before || return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
computedTiming.mPhase == ComputedTiming::AnimationPhase_Active; computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
@ -204,6 +225,10 @@ protected:
Nullable<TimeDuration> mParentTime; Nullable<TimeDuration> mParentTime;
AnimationTiming mTiming; AnimationTiming mTiming;
// A flag to mark transitions that have finished and are due to
// be removed on the next throttle-able cycle.
bool mIsFinishedTransition;
InfallibleTArray<AnimationProperty> mProperties; InfallibleTArray<AnimationProperty> mProperties;
}; };

Просмотреть файл

@ -73,7 +73,7 @@ AnimationPlayer::Tick()
bool bool
AnimationPlayer::IsRunning() const AnimationPlayer::IsRunning() const
{ {
if (IsPaused() || !GetSource() || IsFinishedTransition()) { if (IsPaused() || !GetSource() || GetSource()->IsFinishedTransition()) {
return false; return false;
} }
@ -84,7 +84,7 @@ AnimationPlayer::IsRunning() const
bool bool
AnimationPlayer::IsCurrent() const AnimationPlayer::IsCurrent() const
{ {
return GetSource() && !IsFinishedTransition() && GetSource()->IsCurrent(); return GetSource() && GetSource()->IsCurrent();
} }
} // namespace dom } // namespace dom

Просмотреть файл

@ -36,7 +36,6 @@ protected:
public: public:
explicit AnimationPlayer(AnimationTimeline* aTimeline) explicit AnimationPlayer(AnimationTimeline* aTimeline)
: mIsRunningOnCompositor(false) : mIsRunningOnCompositor(false)
, mIsFinishedTransition(false)
, mLastNotification(LAST_NOTIFICATION_NONE) , mLastNotification(LAST_NOTIFICATION_NONE)
, mTimeline(aTimeline) , mTimeline(aTimeline)
{ {
@ -70,18 +69,6 @@ public:
return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED; return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
} }
// After transitions finish they need to be retained for one throttle-able
// cycle (for reasons see explanation in nsTransitionManager.cpp). In the
// meantime, however, they should be ignored.
bool IsFinishedTransition() const {
return mIsFinishedTransition;
}
void SetFinishedTransition() {
MOZ_ASSERT(AsTransition(),
"Calling SetFinishedTransition but it's not a transition");
mIsFinishedTransition = true;
}
bool IsRunning() const; bool IsRunning() const;
bool IsCurrent() const; bool IsCurrent() const;
@ -112,9 +99,6 @@ public:
TimeStamp mPauseStart; TimeStamp mPauseStart;
uint8_t mPlayState; uint8_t mPlayState;
bool mIsRunningOnCompositor; bool mIsRunningOnCompositor;
// A flag to mark transitions that have finished and are due to
// be removed on the next throttle-able cycle.
bool mIsFinishedTransition;
enum { enum {
LAST_NOTIFICATION_NONE = uint64_t(-1), LAST_NOTIFICATION_NONE = uint64_t(-1),

Просмотреть файл

@ -472,7 +472,7 @@ GetMinAndMaxScaleForAnimationProperty(nsIContent* aContent,
for (size_t playerIdx = collection->mPlayers.Length(); playerIdx-- != 0; ) { for (size_t playerIdx = collection->mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = collection->mPlayers[playerIdx]; AnimationPlayer* player = collection->mPlayers[playerIdx];
if (!player->GetSource() || player->IsFinishedTransition()) { if (!player->GetSource() || player->GetSource()->IsFinishedTransition()) {
continue; continue;
} }
dom::Animation* anim = player->GetSource(); dom::Animation* anim = player->GetSource();

Просмотреть файл

@ -404,12 +404,9 @@ AnimationPlayerCollection::HasAnimationOfProperty(
nsCSSProperty aProperty) const nsCSSProperty aProperty) const
{ {
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
const AnimationPlayer* player = mPlayers[playerIdx]; const Animation* anim = mPlayers[playerIdx]->GetSource();
const Animation* anim = player->GetSource();
// FIXME: Drop the reference to the player once we move
// IsFinishedTransition to Animation
if (anim && anim->HasAnimationOfProperty(aProperty) && if (anim && anim->HasAnimationOfProperty(aProperty) &&
!player->IsFinishedTransition()) { !anim->IsFinishedTransition()) {
return true; return true;
} }
} }
@ -480,7 +477,7 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
// Skip player with no source content, finished transitions, or animations // Skip player with no source content, finished transitions, or animations
// whose @keyframes rule is empty. // whose @keyframes rule is empty.
if (!player->GetSource() || if (!player->GetSource() ||
player->IsFinishedTransition() || player->GetSource()->IsFinishedTransition() ||
player->GetSource()->Properties().IsEmpty()) { player->GetSource()->Properties().IsEmpty()) {
continue; continue;
} }
@ -523,7 +520,7 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = mPlayers[playerIdx]; AnimationPlayer* player = mPlayers[playerIdx];
if (!player->GetSource() || player->IsFinishedTransition()) { if (!player->GetSource() || player->GetSource()->IsFinishedTransition()) {
continue; continue;
} }

Просмотреть файл

@ -41,10 +41,11 @@ using namespace mozilla::css;
double double
ElementPropertyTransition::CurrentValuePortion() const ElementPropertyTransition::CurrentValuePortion() const
{ {
MOZ_ASSERT(GetSource(), "Transitions should have source content");
// It would be easy enough to handle finished transitions by using a time // It would be easy enough to handle finished transitions by using a time
// fraction of 1 but currently we should not be called for finished // fraction of 1 but currently we should not be called for finished
// transitions. // transitions.
MOZ_ASSERT(!IsFinishedTransition(), MOZ_ASSERT(!GetSource()->IsFinishedTransition(),
"Getting the value portion of a finished transition"); "Getting the value portion of a finished transition");
MOZ_ASSERT(!GetCurrentTimeDuration().IsNull(), MOZ_ASSERT(!GetCurrentTimeDuration().IsNull(),
"Getting the value portion of an animation that's not being " "Getting the value portion of an animation that's not being "
@ -56,7 +57,6 @@ ElementPropertyTransition::CurrentValuePortion() const
// causing us to get called *after* the animation interval. So, just in // causing us to get called *after* the animation interval. So, just in
// case, we override the fill mode to 'both' to ensure the time fraction // case, we override the fill mode to 'both' to ensure the time fraction
// is never null. // is never null.
MOZ_ASSERT(GetSource(), "Transitions should have source content");
AnimationTiming timingToUse = GetSource()->Timing(); AnimationTiming timingToUse = GetSource()->Timing();
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH; timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
ComputedTiming computedTiming = GetSource()->GetComputedTiming(&timingToUse); ComputedTiming computedTiming = GetSource()->GetComputedTiming(&timingToUse);
@ -461,7 +461,7 @@ nsTransitionManager::ConsiderStartingTransition(
// If the new transition reverses an existing one, we'll need to // If the new transition reverses an existing one, we'll need to
// handle the timing differently. // handle the timing differently.
if (haveCurrentTransition && if (haveCurrentTransition &&
!oldPT->IsFinishedTransition() && !oldPT->GetSource()->IsFinishedTransition() &&
oldPT->mStartForReversingTest == endValue) { oldPT->mStartForReversingTest == endValue) {
// Compute the appropriate negative transition-delay such that right // Compute the appropriate negative transition-delay such that right
// now we'd end up at the current position. // now we'd end up at the current position.
@ -778,7 +778,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
do { do {
--i; --i;
AnimationPlayer* player = collection->mPlayers[i]; AnimationPlayer* player = collection->mPlayers[i];
if (player->IsFinishedTransition()) { if (player->GetSource()->IsFinishedTransition()) {
// Actually remove transitions one throttle-able cycle after their // Actually remove transitions one throttle-able cycle after their
// completion. We only clear on a throttle-able cycle because that // completion. We only clear on a throttle-able cycle because that
// means it is a regular restyle tick and thus it is safe to discard // means it is a regular restyle tick and thus it is safe to discard
@ -814,7 +814,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
// a non-animation style change that would affect it, we need // a non-animation style change that would affect it, we need
// to know not to start a new transition for the transition // to know not to start a new transition for the transition
// from the almost-completed value to the final value. // from the almost-completed value to the final value.
player->SetFinishedTransition(); player->GetSource()->SetIsFinishedTransition();
collection->UpdateAnimationGeneration(mPresContext); collection->UpdateAnimationGeneration(mPresContext);
transitionStartedOrEnded = true; transitionStartedOrEnded = true;
} else if ((computedTiming.mPhase == } else if ((computedTiming.mPhase ==