From e8729cc7fd4055f82fef730eb21629bc8593d6ec Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Fri, 20 Jun 2014 12:39:25 +0900 Subject: [PATCH] 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. --- layout/style/AnimationCommon.cpp | 4 +++- layout/style/nsAnimationManager.cpp | 22 +++++++++------------- layout/style/nsAnimationManager.h | 4 +++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 2816198b9521..5c92337ffcfd 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -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 = diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 5e2305660ba1..5f393191928a 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -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 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 { diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index eefebdf6e7d9..3b9f7050a2a7 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -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;