Bug 1025709 part 6 - Reuse nsAnimationManager::EnsureStyleRuleFor; r=heycam

In a number of places in nsAnimationManager we have the following sequence of
calls:

  CommonElementAnimationData::EnsureStyleRuleFor
  ElementAnimations::GetEventsAt
  nsAnimationManager::CheckNeedsRefresh

nsAnimationManager::EnsureStyleRuleFor already does exactly that so we should
just reuse it.

At the same time we rename EnsureStyleRuleFor to UpdateStyleAndEvents since
that's a bit more accurate. It's also confusing to have two methods of the same
name (but on different objects) that don't exactly correspond in terms of
the scope of what they do.
This commit is contained in:
Brian Birtles 2014-06-20 12:39:25 +09:00
Родитель 95c414f550
Коммит e8729cc7fd
3 изменённых файлов: 15 добавлений и 15 удалений

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

@ -231,7 +231,9 @@ CommonAnimationManager::UpdateThrottledStyle(dom::Element* aElement,
NS_ASSERTION(ea,
"Rule has level eAnimationSheet without animation on manager");
mPresContext->AnimationManager()->EnsureStyleRuleFor(ea);
mPresContext->AnimationManager()->UpdateStyleAndEvents(
ea, mPresContext->RefreshDriver()->MostRecentRefresh(),
EnsureStyleRule_IsNotThrottled);
curRule.mRule = ea->mStyleRule;
} else if (curRule.mLevel == nsStyleSet::eTransitionSheet) {
ElementTransitions *et =

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

@ -245,13 +245,13 @@ nsAnimationManager::GetElementAnimations(dom::Element *aElement,
return ea;
}
void
nsAnimationManager::EnsureStyleRuleFor(ElementAnimations* aEA)
nsAnimationManager::UpdateStyleAndEvents(ElementAnimations* aEA,
TimeStamp aRefreshTime,
EnsureStyleRuleFlags aFlags)
{
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
aEA->EnsureStyleRuleFor(refreshTime, EnsureStyleRule_IsNotThrottled);
aEA->GetEventsAt(refreshTime, mPendingEvents);
aEA->EnsureStyleRuleFor(aRefreshTime, aFlags);
aEA->GetEventsAt(aRefreshTime, mPendingEvents);
CheckNeedsRefresh();
}
@ -414,9 +414,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
ea->mAnimations.SwapElements(newAnimations);
ea->mNeedsRefreshes = true;
ea->EnsureStyleRuleFor(refreshTime, EnsureStyleRule_IsNotThrottled);
ea->GetEventsAt(refreshTime, mPendingEvents);
CheckNeedsRefresh();
UpdateStyleAndEvents(ea, refreshTime, EnsureStyleRule_IsNotThrottled);
// We don't actually dispatch the mPendingEvents now. We'll either
// dispatch them the next time we get a refresh driver notification
// or the next time somebody calls
@ -844,11 +842,9 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags)
ea->CanThrottleAnimation(now);
nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = ea->mStyleRule;
ea->EnsureStyleRuleFor(now, canThrottleTick
? EnsureStyleRule_IsThrottled
: EnsureStyleRule_IsNotThrottled);
ea->GetEventsAt(now, mPendingEvents);
CheckNeedsRefresh();
UpdateStyleAndEvents(ea, now, canThrottleTick
? EnsureStyleRule_IsThrottled
: EnsureStyleRule_IsNotThrottled);
if (oldStyleRule != ea->mStyleRule) {
ea->PostRestyleForAnimation(mPresContext);
} else {

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

@ -136,7 +136,9 @@ public:
return false;
}
void EnsureStyleRuleFor(ElementAnimations* aET);
void UpdateStyleAndEvents(ElementAnimations* aEA,
TimeStamp aRefreshTime,
mozilla::EnsureStyleRuleFlags aFlags);
// nsIStyleRuleProcessor (parts)
virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;