зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1117603 part 2 - Don't unregister from the refresh driver unless we are also queueing events; r=dbaron
This commit is contained in:
Родитель
fec249e9b1
Коммит
d2405f9465
|
@ -99,23 +99,39 @@ CommonAnimationManager::RemoveAllElementCollections()
|
|||
}
|
||||
|
||||
void
|
||||
CommonAnimationManager::CheckNeedsRefresh()
|
||||
CommonAnimationManager::MaybeStartObservingRefreshDriver()
|
||||
{
|
||||
if (mIsObservingRefreshDriver || !NeedsRefresh()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style);
|
||||
mIsObservingRefreshDriver = true;
|
||||
}
|
||||
|
||||
void
|
||||
CommonAnimationManager::MaybeStartOrStopObservingRefreshDriver()
|
||||
{
|
||||
bool needsRefresh = NeedsRefresh();
|
||||
if (needsRefresh && !mIsObservingRefreshDriver) {
|
||||
mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style);
|
||||
} else if (!needsRefresh && mIsObservingRefreshDriver) {
|
||||
mPresContext->RefreshDriver()->RemoveRefreshObserver(this, Flush_Style);
|
||||
}
|
||||
mIsObservingRefreshDriver = needsRefresh;
|
||||
}
|
||||
|
||||
bool
|
||||
CommonAnimationManager::NeedsRefresh() const
|
||||
{
|
||||
for (PRCList *l = PR_LIST_HEAD(&mElementCollections);
|
||||
l != &mElementCollections;
|
||||
l = PR_NEXT_LINK(l)) {
|
||||
if (static_cast<AnimationPlayerCollection*>(l)->mNeedsRefreshes) {
|
||||
if (!mIsObservingRefreshDriver) {
|
||||
mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style);
|
||||
mIsObservingRefreshDriver = true;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mIsObservingRefreshDriver) {
|
||||
mIsObservingRefreshDriver = false;
|
||||
mPresContext->RefreshDriver()->RemoveRefreshObserver(this, Flush_Style);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AnimationPlayerCollection*
|
||||
|
@ -276,7 +292,7 @@ void
|
|||
CommonAnimationManager::NotifyCollectionUpdated(AnimationPlayerCollection&
|
||||
aCollection)
|
||||
{
|
||||
CheckNeedsRefresh();
|
||||
MaybeStartObservingRefreshDriver();
|
||||
mPresContext->ClearLastStyleUpdateForAllAnimations();
|
||||
mPresContext->RestyleManager()->IncrementAnimationGeneration();
|
||||
aCollection.UpdateAnimationGeneration(mPresContext);
|
||||
|
@ -732,8 +748,6 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
|||
}
|
||||
}
|
||||
|
||||
mManager->CheckNeedsRefresh();
|
||||
|
||||
// If one of our animations just started or stopped filling, we need
|
||||
// to notify the transition manager. This does the notification a bit
|
||||
// more than necessary, but it's easier than doing it exactly.
|
||||
|
|
|
@ -131,11 +131,15 @@ protected:
|
|||
friend struct mozilla::AnimationPlayerCollection;
|
||||
|
||||
void AddElementCollection(AnimationPlayerCollection* aCollection);
|
||||
void ElementCollectionRemoved() { CheckNeedsRefresh(); }
|
||||
void ElementCollectionRemoved() { MaybeStartOrStopObservingRefreshDriver(); }
|
||||
void RemoveAllElementCollections();
|
||||
|
||||
// Check to see if we should stop or start observing the refresh driver
|
||||
void CheckNeedsRefresh();
|
||||
// We should normally only call MaybeStartOrStopObservingRefreshDriver in
|
||||
// situations where we will also queue events since otherwise we may stop
|
||||
// getting refresh driver ticks before we queue the necessary events.
|
||||
void MaybeStartObservingRefreshDriver();
|
||||
void MaybeStartOrStopObservingRefreshDriver();
|
||||
bool NeedsRefresh() const;
|
||||
|
||||
virtual nsIAtom* GetAnimationsAtom() = 0;
|
||||
virtual nsIAtom* GetAnimationsBeforeAtom() = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче