Bug 1344603 - Make Stop{Animations|Transitions}ForElement as a member function of CommonAnimationManager. r?boris
MozReview-Commit-ID: LSSpWYjoPn9
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1710,17 +1710,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
@@ -351,32 +351,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
@@ -1073,24 +1073,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.