AnimationCollection* CommonAnimationManager::GetAnimationsForCompositor(const nsIFrame* aFrame, nsCSSProperty aProperty) { AnimationCollection* collection = GetAnimationCollection(aFrame); if (!collection || !collection->HasCurrentAnimationOfProperty(aProperty) || !collection->CanPerformOnCompositorThread( AnimationCollection::CanAnimate_AllowPartial)) { return nullptr; } // This animation can be done on the compositor. return collection; }
AnimationCollection* CommonAnimationManager::GetAnimationsForCompositor(nsIContent* aContent, nsIAtom* aElementProperty, nsCSSProperty aProperty) { if (!aContent->MayHaveAnimations()) return nullptr; AnimationCollection* collection = static_cast<AnimationCollection*>(aContent->GetProperty(aElementProperty)); if (!collection || !collection->HasAnimationOfProperty(aProperty) || !collection->CanPerformOnCompositorThread( AnimationCollection::CanAnimate_AllowPartial)) { return nullptr; } // This animation can be done on the compositor. return collection; }
void nsAnimationManager::FlushAnimations(FlushFlags aFlags) { TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh(); bool didThrottle = false; for (PRCList *l = PR_LIST_HEAD(&mElementCollections); l != &mElementCollections; l = PR_NEXT_LINK(l)) { AnimationCollection* collection = static_cast<AnimationCollection*>(l); nsAutoAnimationMutationBatch mb(collection->mElement); collection->Tick(); bool canThrottleTick = aFlags == Can_Throttle && collection->CanPerformOnCompositorThread( AnimationCollection::CanAnimateFlags(0)) && collection->CanThrottleAnimation(now); nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = collection->mStyleRule; UpdateStyleAndEvents(collection, now, canThrottleTick ? EnsureStyleRule_IsThrottled : EnsureStyleRule_IsNotThrottled); if (oldStyleRule != collection->mStyleRule) { collection->PostRestyleForAnimation(mPresContext); } else { didThrottle = true; } } if (didThrottle) { mPresContext->Document()->SetNeedStyleFlush(); } MaybeStartOrStopObservingRefreshDriver(); DispatchEvents(); // may destroy us }