Bug 1025709 part 5 - Replace aIsThrottled bool value with an enum; r=heycam

This commit is contained in:
Brian Birtles 2014-06-20 12:39:25 +09:00
parent ae594f7975
commit af843d9fd9
4 changed files with 18 additions and 10 deletions

View File

@ -243,7 +243,8 @@ CommonAnimationManager::UpdateThrottledStyle(dom::Element* aElement,
"Rule has level eTransitionSheet without transition on manager"); "Rule has level eTransitionSheet without transition on manager");
et->EnsureStyleRuleFor( et->EnsureStyleRuleFor(
mPresContext->RefreshDriver()->MostRecentRefresh(), false); mPresContext->RefreshDriver()->MostRecentRefresh(),
EnsureStyleRule_IsNotThrottled);
curRule.mRule = et->mStyleRule; curRule.mRule = et->mStyleRule;
} else { } else {
curRule.mRule = ruleNode->GetRule(); curRule.mRule = ruleNode->GetRule();
@ -616,7 +617,7 @@ CommonElementAnimationData::LogAsyncAnimationFailure(nsCString& aMessage,
void void
CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime, CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime,
bool aIsThrottled) EnsureStyleRuleFlags aFlags)
{ {
if (!mNeedsRefreshes) { if (!mNeedsRefreshes) {
mStyleRuleRefreshTime = aRefreshTime; mStyleRuleRefreshTime = aRefreshTime;
@ -629,7 +630,7 @@ CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime,
// of animation behaviour (the styles of the animation disappear, or the fill // of animation behaviour (the styles of the animation disappear, or the fill
// mode behaviour). This loop checks for any finishing animations and forces // mode behaviour). This loop checks for any finishing animations and forces
// the style recalculation if we find any. // the style recalculation if we find any.
if (aIsThrottled) { if (aFlags == EnsureStyleRule_IsThrottled) {
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
ElementAnimation* anim = mAnimations[animIdx]; ElementAnimation* anim = mAnimations[animIdx];
@ -653,13 +654,13 @@ CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime,
(computedTiming.mPhase == ComputedTiming::AnimationPhase_After && (computedTiming.mPhase == ComputedTiming::AnimationPhase_After &&
anim->mLastNotification != ElementAnimation::LAST_NOTIFICATION_END)) anim->mLastNotification != ElementAnimation::LAST_NOTIFICATION_END))
{ {
aIsThrottled = false; aFlags = EnsureStyleRule_IsNotThrottled;
break; break;
} }
} }
} }
if (aIsThrottled) { if (aFlags == EnsureStyleRule_IsThrottled) {
return; return;
} }

View File

@ -387,6 +387,11 @@ public:
typedef InfallibleTArray<nsRefPtr<ElementAnimation> > ElementAnimationPtrArray; typedef InfallibleTArray<nsRefPtr<ElementAnimation> > ElementAnimationPtrArray;
enum EnsureStyleRuleFlags {
EnsureStyleRule_IsThrottled,
EnsureStyleRule_IsNotThrottled
};
namespace css { namespace css {
struct CommonElementAnimationData : public PRCList struct CommonElementAnimationData : public PRCList
@ -425,7 +430,7 @@ struct CommonElementAnimationData : public PRCList
// for changes to values (for example, nsAnimationManager provides // for changes to values (for example, nsAnimationManager provides
// CheckNeedsRefresh to register or unregister from observing the refresh // CheckNeedsRefresh to register or unregister from observing the refresh
// driver when this value changes). // driver when this value changes).
void EnsureStyleRuleFor(TimeStamp aRefreshTime, bool aIsThrottled); void EnsureStyleRuleFor(TimeStamp aRefreshTime, EnsureStyleRuleFlags aFlags);
bool CanThrottleTransformChanges(mozilla::TimeStamp aTime); bool CanThrottleTransformChanges(mozilla::TimeStamp aTime);

View File

@ -250,7 +250,7 @@ void
nsAnimationManager::EnsureStyleRuleFor(ElementAnimations* aEA) nsAnimationManager::EnsureStyleRuleFor(ElementAnimations* aEA)
{ {
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh(); TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
aEA->EnsureStyleRuleFor(refreshTime, false); aEA->EnsureStyleRuleFor(refreshTime, EnsureStyleRule_IsNotThrottled);
aEA->GetEventsAt(refreshTime, mPendingEvents); aEA->GetEventsAt(refreshTime, mPendingEvents);
CheckNeedsRefresh(); CheckNeedsRefresh();
} }
@ -414,7 +414,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
ea->mAnimations.SwapElements(newAnimations); ea->mAnimations.SwapElements(newAnimations);
ea->mNeedsRefreshes = true; ea->mNeedsRefreshes = true;
ea->EnsureStyleRuleFor(refreshTime, false); ea->EnsureStyleRuleFor(refreshTime, EnsureStyleRule_IsNotThrottled);
ea->GetEventsAt(refreshTime, mPendingEvents); ea->GetEventsAt(refreshTime, mPendingEvents);
CheckNeedsRefresh(); CheckNeedsRefresh();
// We don't actually dispatch the mPendingEvents now. We'll either // We don't actually dispatch the mPendingEvents now. We'll either
@ -844,7 +844,9 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags)
ea->CanThrottleAnimation(now); ea->CanThrottleAnimation(now);
nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = ea->mStyleRule; nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = ea->mStyleRule;
ea->EnsureStyleRuleFor(now, canThrottleTick); ea->EnsureStyleRuleFor(now, canThrottleTick
? EnsureStyleRule_IsThrottled
: EnsureStyleRule_IsNotThrottled);
ea->GetEventsAt(now, mPendingEvents); ea->GetEventsAt(now, mPendingEvents);
CheckNeedsRefresh(); CheckNeedsRefresh();
if (oldStyleRule != ea->mStyleRule) { if (oldStyleRule != ea->mStyleRule) {

View File

@ -793,7 +793,7 @@ nsTransitionManager::WalkTransitionRule(ElementDependentRuleProcessorData* aData
et->mNeedsRefreshes = true; et->mNeedsRefreshes = true;
et->EnsureStyleRuleFor( et->EnsureStyleRuleFor(
aData->mPresContext->RefreshDriver()->MostRecentRefresh(), aData->mPresContext->RefreshDriver()->MostRecentRefresh(),
false); EnsureStyleRule_IsNotThrottled);
if (et->mStyleRule) { if (et->mStyleRule) {
aData->mRuleWalker->Forward(et->mStyleRule); aData->mRuleWalker->Forward(et->mStyleRule);