diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index c8a84ad224f3..1eb2cc9883b6 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1579,8 +1579,18 @@ RestyleManager::UpdateOnlyAnimationStyles() transitionManager->SetInAnimationOnlyStyleUpdate(true); - transitionManager->UpdateAllThrottledStyles(); - animationManager->UpdateAllThrottledStyles(); + RestyleTracker tracker(ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE | + ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT); + tracker.Init(this); + + // FIXME: We should have the transition manager and animation manager + // add only the elements for which animations are currently throttled + // (i.e., animating on the compositor with main-thread style updates + // suppressed). + transitionManager->AddStyleUpdatesTo(tracker); + animationManager->AddStyleUpdatesTo(tracker); + + tracker.ProcessRestyles(); transitionManager->SetInAnimationOnlyStyleUpdate(false); } diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index cb88bc63d3be..60ec19a375ef 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -166,6 +166,28 @@ CommonAnimationManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } +void +CommonAnimationManager::AddStyleUpdatesTo(RestyleTracker& aTracker) +{ + PRCList* next = PR_LIST_HEAD(&mElementCollections); + while (next != &mElementCollections) { + ElementAnimationCollection* collection = static_cast(next); + next = PR_NEXT_LINK(next); + + if (!collection->IsForElement()) { + // We don't support compositor-driven animation of :before/:after + // transitions or animations, so at least skip those. + // FIXME: We'll need to handle this before using this for the + // transitions redesign. + continue; + } + + nsRestyleHint rshint = collection->IsForTransitions() + ? eRestyle_CSSTransitions : eRestyle_CSSAnimations; + aTracker.AddPendingRestyle(collection->mElement, rshint, nsChangeHint(0)); + } +} + /* static */ bool CommonAnimationManager::ExtractComputedValueForTransition( nsCSSProperty aProperty, diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index 08f4fe596d73..084119606207 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -34,6 +34,7 @@ class nsStyleChangeList; namespace mozilla { +class RestyleTracker; class StyleAnimationValue; struct ElementPropertyTransition; struct ElementAnimationCollection; @@ -67,6 +68,11 @@ public: */ void Disconnect(); + // Tell the restyle tracker about all the styles that we're currently + // animating, so that it can update the animation rule for these + // elements. + void AddStyleUpdatesTo(mozilla::RestyleTracker& aTracker); + enum FlushFlags { Can_Throttle, Cannot_Throttle @@ -529,6 +535,18 @@ struct ElementAnimationCollection : public PRCList mElementProperty == nsGkAtoms::transitionsProperty; } + bool IsForTransitions() const { + return mElementProperty == nsGkAtoms::transitionsProperty || + mElementProperty == nsGkAtoms::transitionsOfBeforeProperty || + mElementProperty == nsGkAtoms::transitionsOfAfterProperty; + } + + bool IsForAnimations() const { + return mElementProperty == nsGkAtoms::animationsProperty || + mElementProperty == nsGkAtoms::animationsOfBeforeProperty || + mElementProperty == nsGkAtoms::animationsOfAfterProperty; + } + nsString PseudoElement() { if (IsForElement()) {