diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index cdd124dfd43b..764178afa12b 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -61,8 +61,7 @@ class MOZ_RAII AutoMutationBatchForAnimation { explicit AutoMutationBatchForAnimation( const Animation& aAnimation MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; - Maybe target = - nsNodeUtils::GetTargetForAnimation(&aAnimation); + Maybe target = aAnimation.GetTargetForAnimation(); if (!target) { return; } @@ -82,6 +81,15 @@ class MOZ_RAII AutoMutationBatchForAnimation { // Animation interface: // // --------------------------------------------------------------------------- + +Maybe Animation::GetTargetForAnimation() const { + AnimationEffect* effect = GetEffect(); + if (!effect || !effect->AsKeyframeEffect()) { + return Nothing(); + } + return effect->AsKeyframeEffect()->GetTarget(); +} + /* static */ already_AddRefed Animation::Constructor( const GlobalObject& aGlobal, AnimationEffect* aEffect, diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index 40eb573462cc..601a880e5a24 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -15,6 +15,7 @@ #include "mozilla/DOMEventTargetHelper.h" #include "mozilla/EffectCompositor.h" // For EffectCompositor::CascadeLevel #include "mozilla/LinkedList.h" +#include "mozilla/Maybe.h" #include "mozilla/PostRestyleMode.h" #include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration #include "mozilla/dom/AnimationBinding.h" // for AnimationPlayState @@ -57,6 +58,13 @@ class Animation : public DOMEventTargetHelper, NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Animation, DOMEventTargetHelper) nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); } + + /** + * Utility function to get the target (pseudo-)element associated with an + * animation. + */ + Maybe GetTargetForAnimation() const; + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 0c36cb892c58..71de8f14f01c 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -221,18 +221,11 @@ void nsNodeUtils::ContentRemoved(nsINode* aContainer, nsIContent* aChild, IsRemoveNotification::Yes); } -Maybe nsNodeUtils::GetTargetForAnimation( - const dom::Animation* aAnimation) { - AnimationEffect* effect = aAnimation->GetEffect(); - if (!effect || !effect->AsKeyframeEffect()) { - return Nothing(); - } - return effect->AsKeyframeEffect()->GetTarget(); -} +void nsNodeUtils::AnimationMutated( + dom::Animation* aAnimation, AnimationMutationType aMutatedType) { + MOZ_ASSERT(aAnimation); -void nsNodeUtils::AnimationMutated(dom::Animation* aAnimation, - AnimationMutationType aMutatedType) { - Maybe target = GetTargetForAnimation(aAnimation); + Maybe target = aAnimation->GetTargetForAnimation(); if (!target) { return; } diff --git a/dom/base/nsNodeUtils.h b/dom/base/nsNodeUtils.h index 44fe05a949ce..fb943f323568 100644 --- a/dom/base/nsNodeUtils.h +++ b/dom/base/nsNodeUtils.h @@ -7,7 +7,6 @@ #ifndef nsNodeUtils_h___ #define nsNodeUtils_h___ -#include "mozilla/Maybe.h" #include "nsIContent.h" // for use in inline function (ParentChainChanged) #include "nsIMutationObserver.h" // for use in inline function (ParentChainChanged) #include "mozilla/dom/Document.h" @@ -134,14 +133,6 @@ class nsNodeUtils { } } - /** - * Utility function to get the target (pseudo-)element associated with an - * animation. - * @param aAnimation The animation whose target is what we want. - */ - static mozilla::Maybe - GetTargetForAnimation(const mozilla::dom::Animation* aAnimation); - /** * Notify that an animation is added/changed/removed. * @param aAnimation The animation we added/changed/removed.