mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 996796 patch 3 - Move the knowledge of when we last updated main-thread-suppressed animation styles into the restyle manager rather than have two separate but always equal timestamps for animations and transitions. r=birtles
This commit is contained in:
parent
fe9af3ff1f
commit
364d06998b
@ -52,6 +52,8 @@ RestyleManager::RestyleManager(nsPresContext* aPresContext)
|
||||
, mInStyleRefresh(false)
|
||||
, mHoverGeneration(0)
|
||||
, mRebuildAllExtraHint(nsChangeHint(0))
|
||||
, mLastUpdateForThrottledAnimations(aPresContext->RefreshDriver()->
|
||||
MostRecentRefresh())
|
||||
, mAnimationGeneration(0)
|
||||
, mPendingRestyles(ELEMENT_HAS_PENDING_RESTYLE |
|
||||
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT)
|
||||
@ -1531,6 +1533,12 @@ RestyleManager::EndProcessingRestyles()
|
||||
void
|
||||
RestyleManager::UpdateOnlyAnimationStyles()
|
||||
{
|
||||
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
if (mLastUpdateForThrottledAnimations == now) {
|
||||
return;
|
||||
}
|
||||
mLastUpdateForThrottledAnimations = now;
|
||||
|
||||
mPresContext->TransitionManager()->UpdateAllThrottledStyles();
|
||||
mPresContext->AnimationManager()->UpdateAllThrottledStyles();
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include "nsChangeHint.h"
|
||||
#include "RestyleTracker.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsRefreshDriver;
|
||||
class nsStyleChangeList;
|
||||
struct TreeMatchContext;
|
||||
|
||||
@ -166,6 +166,11 @@ public:
|
||||
// out-of-date.
|
||||
void UpdateOnlyAnimationStyles();
|
||||
|
||||
bool ThrottledAnimationStyleIsUpToDate() const {
|
||||
return mLastUpdateForThrottledAnimations ==
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
}
|
||||
|
||||
// Rebuilds all style data by throwing out the old rule tree and
|
||||
// building a new one, and additionally applying aExtraHint (which
|
||||
// must not contain nsChangeHint_ReconstructFrame) to the root frame.
|
||||
@ -270,6 +275,8 @@ private:
|
||||
uint32_t mHoverGeneration;
|
||||
nsChangeHint mRebuildAllExtraHint;
|
||||
|
||||
mozilla::TimeStamp mLastUpdateForThrottledAnimations;
|
||||
|
||||
OverflowChangedTracker mOverflowChangedTracker;
|
||||
|
||||
// The total number of animation flushes by this frame constructor.
|
||||
|
@ -968,10 +968,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
|
||||
mAnimationManager = new nsAnimationManager(this);
|
||||
|
||||
// Since there are methods in nsPresContext have the same name as the
|
||||
// classes, it is necessary to prefix them with the namespace here.
|
||||
mRestyleManager = new mozilla::RestyleManager(this);
|
||||
|
||||
// Since CounterStyleManager is also the name of a method of
|
||||
// nsPresContext, it is necessary to prefix the class with the mozilla
|
||||
// namespace here.
|
||||
mCounterStyleManager = new mozilla::CounterStyleManager(this);
|
||||
|
||||
if (mDocument->GetDisplayDocument()) {
|
||||
@ -1017,9 +1016,13 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
}
|
||||
|
||||
// Initialise refresh tick counters for OMTA
|
||||
mLastStyleUpdateForAllAnimations =
|
||||
mLastUpdateThrottledAnimationStyle =
|
||||
mLastUpdateThrottledTransitionStyle = mRefreshDriver->MostRecentRefresh();
|
||||
mLastStyleUpdateForAllAnimations = mRefreshDriver->MostRecentRefresh();
|
||||
|
||||
// Initialize restyle manager after initializing the refresh driver.
|
||||
// Since RestyleManager is also the name of a method of nsPresContext,
|
||||
// it is necessary to prefix the class with the mozilla namespace
|
||||
// here.
|
||||
mRestyleManager = new mozilla::RestyleManager(this);
|
||||
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
|
||||
@ -1551,32 +1554,6 @@ nsPresContext::Detach()
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsPresContext::ThrottledTransitionStyleIsUpToDate() const
|
||||
{
|
||||
return
|
||||
mLastUpdateThrottledTransitionStyle == mRefreshDriver->MostRecentRefresh();
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::TickLastUpdateThrottledTransitionStyle()
|
||||
{
|
||||
mLastUpdateThrottledTransitionStyle = mRefreshDriver->MostRecentRefresh();
|
||||
}
|
||||
|
||||
bool
|
||||
nsPresContext::ThrottledAnimationStyleIsUpToDate() const
|
||||
{
|
||||
return
|
||||
mLastUpdateThrottledAnimationStyle == mRefreshDriver->MostRecentRefresh();
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::TickLastUpdateThrottledAnimationStyle()
|
||||
{
|
||||
mLastUpdateThrottledAnimationStyle = mRefreshDriver->MostRecentRefresh();
|
||||
}
|
||||
|
||||
bool
|
||||
nsPresContext::StyleUpdateForAllAnimationsIsUpToDate()
|
||||
{
|
||||
|
@ -688,10 +688,6 @@ public:
|
||||
/**
|
||||
* Getter and setter for OMTA time counters
|
||||
*/
|
||||
bool ThrottledTransitionStyleIsUpToDate() const;
|
||||
void TickLastUpdateThrottledTransitionStyle();
|
||||
bool ThrottledAnimationStyleIsUpToDate() const;
|
||||
void TickLastUpdateThrottledAnimationStyle();
|
||||
bool StyleUpdateForAllAnimationsIsUpToDate();
|
||||
void TickLastStyleUpdateForAllAnimations();
|
||||
|
||||
@ -1282,10 +1278,6 @@ protected:
|
||||
|
||||
mozilla::TimeStamp mReflowStartTime;
|
||||
|
||||
// last time animations styles were flushed to their primary frames
|
||||
mozilla::TimeStamp mLastUpdateThrottledAnimationStyle;
|
||||
// last time transition styles were flushed to their primary frames
|
||||
mozilla::TimeStamp mLastUpdateThrottledTransitionStyle;
|
||||
// last time we did a full style flush
|
||||
mozilla::TimeStamp mLastStyleUpdateForAllAnimations;
|
||||
|
||||
|
@ -822,17 +822,9 @@ nsAnimationManager::UpdateAllThrottledStyles()
|
||||
{
|
||||
if (PR_CLIST_IS_EMPTY(&mElementCollections)) {
|
||||
// no throttled animations, leave early
|
||||
mPresContext->TickLastUpdateThrottledAnimationStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPresContext->ThrottledAnimationStyleIsUpToDate()) {
|
||||
// throttled transitions are up to date, leave early
|
||||
return;
|
||||
}
|
||||
|
||||
mPresContext->TickLastUpdateThrottledAnimationStyle();
|
||||
|
||||
UpdateAllThrottledStylesInternal();
|
||||
}
|
||||
|
||||
|
@ -118,16 +118,9 @@ nsTransitionManager::UpdateAllThrottledStyles()
|
||||
{
|
||||
if (PR_CLIST_IS_EMPTY(&mElementCollections)) {
|
||||
// no throttled transitions, leave early
|
||||
mPresContext->TickLastUpdateThrottledTransitionStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPresContext->ThrottledTransitionStyleIsUpToDate()) {
|
||||
// throttled transitions are up to date, leave early
|
||||
return;
|
||||
}
|
||||
|
||||
mPresContext->TickLastUpdateThrottledTransitionStyle();
|
||||
UpdateAllThrottledStylesInternal();
|
||||
}
|
||||
|
||||
@ -223,7 +216,8 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
||||
}
|
||||
|
||||
NS_WARN_IF_FALSE(!nsLayoutUtils::AreAsyncAnimationsEnabled() ||
|
||||
mPresContext->ThrottledTransitionStyleIsUpToDate(),
|
||||
mPresContext->RestyleManager()->
|
||||
ThrottledAnimationStyleIsUpToDate(),
|
||||
"throttled animations not up to date");
|
||||
|
||||
// Per http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html
|
||||
|
Loading…
Reference in New Issue
Block a user