Bug 1344603 - Make Stop{Animations|Transitions}ForElement as a member function of CommonAnimationManager. r=boris
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 13:19:09 +0900
changeset 345988 911024a9cf3c072f0e11bf5f6dafce3db07bd881
parent 345987 26cf91f36f5ea3b6f40802b6542d4a37c0848ad4
child 345989 7099e03837e84970d07d0c7fbdf6724643cc6f30
child 346056 3f962c5a62d3a7d8d38bb4a328b7cd9bd9dcafda
push id31451
push usercbook@mozilla.com
push dateMon, 06 Mar 2017 09:52:09 +0000
treeherdermozilla-central@7099e03837e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1344603
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1344603 - Make Stop{Animations|Transitions}ForElement as a member function of CommonAnimationManager. r=boris MozReview-Commit-ID: LSSpWYjoPn9
layout/base/RestyleManager.cpp
layout/style/AnimationCommon.h
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1745,17 +1745,17 @@ RestyleManager::AnimationsWithDestroyedF
     mRestyleManager->PresContext()->TransitionManager();
   for (nsIContent* content : aArray) {
     if (content->GetPrimaryFrame()) {
       continue;
     }
     dom::Element* element = content->AsElement();
 
     animationManager->StopAnimationsForElement(element, aPseudoType);
-    transitionManager->StopTransitionsForElement(element, aPseudoType);
+    transitionManager->StopAnimationsForElement(element, aPseudoType);
 
     // All other animations should keep running but not running on the
     // *compositor* at this point.
     EffectSet* effectSet = EffectSet::GetEffectSet(element, aPseudoType);
     if (effectSet) {
       for (KeyframeEffectReadOnly* effect : *effectSet) {
         effect->ResetIsRunningOnCompositor();
       }
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -19,16 +19,17 @@
 #include "nsContentUtils.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsIFrame;
 class nsPresContext;
 
 namespace mozilla {
+enum class CSSPseudoElementType : uint8_t;
 
 namespace dom {
 class Element;
 }
 
 template <class AnimationType>
 class CommonAnimationManager {
 public:
@@ -46,16 +47,36 @@ public:
   void Disconnect()
   {
     // Content nodes might outlive the transition or animation manager.
     RemoveAllElementCollections();
 
     mPresContext = nullptr;
   }
 
+  /**
+   * Stop animations on the element. This method takes the real element
+   * rather than the element for the generated content for animations on
+   * ::before and ::after.
+   */
+  void StopAnimationsForElement(dom::Element* aElement,
+                                CSSPseudoElementType aPseudoType)
+  {
+    MOZ_ASSERT(aElement);
+    AnimationCollection<AnimationType>* collection =
+      AnimationCollection<AnimationType>::GetAnimationCollection(aElement,
+                                                                 aPseudoType);
+    if (!collection) {
+      return;
+    }
+
+    nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
+    collection->Destroy();
+  }
+
 protected:
   virtual ~CommonAnimationManager()
   {
     MOZ_ASSERT(!mPresContext, "Disconnect should have been called");
   }
 
   void AddElementCollection(AnimationCollection<AnimationType>* aCollection)
   {
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -353,32 +353,16 @@ PopExistingAnimation(const nsAString& aN
       aCollection->mAnimations.RemoveElementAt(idx);
       return match.forget();
     }
   }
 
   return nullptr;
 }
 
-void
-nsAnimationManager::StopAnimationsForElement(
-  mozilla::dom::Element* aElement,
-  mozilla::CSSPseudoElementType aPseudoType)
-{
-  MOZ_ASSERT(aElement);
-  CSSAnimationCollection* collection =
-    CSSAnimationCollection::GetAnimationCollection(aElement, aPseudoType);
-  if (!collection) {
-    return;
-  }
-
-  nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
-  collection->Destroy();
-}
-
 class ResolvedStyleCache {
 public:
   ResolvedStyleCache() : mCache() {}
   nsStyleContext* Get(nsPresContext *aPresContext,
                       nsStyleContext *aParentStyleContext,
                       Declaration* aKeyframeDeclaration);
 
 private:
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -352,22 +352,16 @@ public:
   void DispatchEvents()
   {
     RefPtr<nsAnimationManager> kungFuDeathGrip(this);
     mEventDispatcher.DispatchEvents(mPresContext);
   }
   void SortEvents()      { mEventDispatcher.SortEvents(); }
   void ClearEventQueue() { mEventDispatcher.ClearEventQueue(); }
 
-  // Stop animations on the element. This method takes the real element
-  // rather than the element for the generated content for animations on
-  // ::before and ::after.
-  void StopAnimationsForElement(mozilla::dom::Element* aElement,
-                                mozilla::CSSPseudoElementType aPseudoType);
-
 protected:
   ~nsAnimationManager() override = default;
 
 private:
   template<class BuilderType>
   void DoUpdateAnimations(
     const mozilla::NonOwningAnimationTarget& aTarget,
     const nsStyleDisplay& aStyleDisplay,
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -1075,24 +1075,8 @@ nsTransitionManager::PruneCompletedTrans
   } while (i != 0);
 
   if (collection->mAnimations.IsEmpty()) {
     collection->Destroy();
     // |collection| is now a dangling pointer!
     collection = nullptr;
   }
 }
-
-void
-nsTransitionManager::StopTransitionsForElement(
-  mozilla::dom::Element* aElement,
-  mozilla::CSSPseudoElementType aPseudoType)
-{
-  MOZ_ASSERT(aElement);
-  CSSTransitionCollection* collection =
-    CSSTransitionCollection::GetAnimationCollection(aElement, aPseudoType);
-  if (!collection) {
-    return;
-  }
-
-  nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
-  collection->Destroy();
-}
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -400,22 +400,16 @@ public:
   void DispatchEvents()
   {
     RefPtr<nsTransitionManager> kungFuDeathGrip(this);
     mEventDispatcher.DispatchEvents(mPresContext);
   }
   void SortEvents()      { mEventDispatcher.SortEvents(); }
   void ClearEventQueue() { mEventDispatcher.ClearEventQueue(); }
 
-  // Stop transitions on the element. This method takes the real element
-  // rather than the element for the generated content for transitions on
-  // ::before and ::after.
-  void StopTransitionsForElement(mozilla::dom::Element* aElement,
-                                 mozilla::CSSPseudoElementType aPseudoType);
-
 protected:
   virtual ~nsTransitionManager() {}
 
   typedef nsTArray<RefPtr<mozilla::dom::CSSTransition>>
     OwningCSSTransitionPtrArray;
 
   // Update the transitions. It'd start new, replace, or stop current
   // transitions if need. aDisp and aElement shouldn't be nullptr.