Bug 1412716 - De-templatize functions used for in nsAnimationManager. r?emilio draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 09 Apr 2018 20:16:00 +0900
changeset 779419 6af9942e8b97c615073c3397d47ef593b5ea0d3e
parent 779418 95c1aa2615235c827d644c5e61176263e3300851
child 779420 fb3a2d72a39faf1fbe16c4010ada1d0984da40af
child 779459 e54f409da2110384ec4833d5c954aff4a655a481
push id105766
push userhikezoe@mozilla.com
push dateMon, 09 Apr 2018 20:53:39 +0000
reviewersemilio
bugs1412716
milestone61.0a1
Bug 1412716 - De-templatize functions used for in nsAnimationManager. r?emilio MozReview-Commit-ID: Kj4pLgmgF0x
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -413,24 +413,23 @@ public:
     keyframeEffect->RequestRestyle(EffectCompositor::RestyleType::Standard);
   }
 
 private:
   const ComputedStyle* mComputedStyle;
 };
 
 
-template<class BuilderType>
 static void
 UpdateOldAnimationPropertiesWithNew(
     CSSAnimation& aOld,
     TimingParams& aNewTiming,
     nsTArray<Keyframe>&& aNewKeyframes,
     bool aNewIsStylePaused,
-    BuilderType& aBuilder)
+    ServoCSSAnimationBuilder& aBuilder)
 {
   bool animationChanged = false;
 
   // Update the old from the new so we can keep the original object
   // identity (and any expando properties attached to it).
   if (aOld.GetEffect()) {
     dom::AnimationEffectReadOnly* oldEffect = aOld.GetEffect();
     animationChanged = oldEffect->SpecifiedTiming() != aNewTiming;
@@ -467,23 +466,22 @@ UpdateOldAnimationPropertiesWithNew(
   if (animationChanged && aOld.IsRelevant()) {
     nsNodeUtils::AnimationChanged(&aOld);
   }
 }
 
 // Returns a new animation set up with given StyleAnimation.
 // Or returns an existing animation matching StyleAnimation's name updated
 // with the new StyleAnimation.
-template<class BuilderType>
 static already_AddRefed<CSSAnimation>
 BuildAnimation(nsPresContext* aPresContext,
                const NonOwningAnimationTarget& aTarget,
                const nsStyleDisplay& aStyleDisplay,
                uint32_t animIdx,
-               BuilderType& aBuilder,
+               ServoCSSAnimationBuilder& aBuilder,
                nsAnimationManager::CSSAnimationCollection* aCollection)
 {
   MOZ_ASSERT(aPresContext);
 
   nsAtom* animationName = aStyleDisplay.GetAnimationName(animIdx);
   nsTArray<Keyframe> keyframes;
   if (!aBuilder.BuildKeyframes(aPresContext,
                                animationName,
@@ -550,22 +548,21 @@ BuildAnimation(nsPresContext* aPresConte
   }
 
   aBuilder.NotifyNewOrRemovedAnimation(*animation);
 
   return animation.forget();
 }
 
 
-template<class BuilderType>
 static nsAnimationManager::OwningCSSAnimationPtrArray
 BuildAnimations(nsPresContext* aPresContext,
                 const NonOwningAnimationTarget& aTarget,
                 const nsStyleDisplay& aStyleDisplay,
-                BuilderType& aBuilder,
+                ServoCSSAnimationBuilder& aBuilder,
                 nsAnimationManager::CSSAnimationCollection* aCollection,
                 nsTHashtable<nsRefPtrHashKey<nsAtom>>& aReferencedAnimations)
 {
   nsAnimationManager::OwningCSSAnimationPtrArray result;
 
   for (size_t animIdx = aStyleDisplay.mAnimationNameCount; animIdx-- != 0;) {
     nsAtom* name = aStyleDisplay.GetAnimationName(animIdx);
     // CSS Animations whose animation-name does not match a @keyframes rule do
@@ -623,22 +620,21 @@ nsAnimationManager::UpdateAnimations(
   }
 
   NonOwningAnimationTarget target(aElement, aPseudoType);
   ServoCSSAnimationBuilder builder(aComputedStyle);
 
   DoUpdateAnimations(target, *disp, builder);
 }
 
-template<class BuilderType>
 void
 nsAnimationManager::DoUpdateAnimations(
   const NonOwningAnimationTarget& aTarget,
   const nsStyleDisplay& aStyleDisplay,
-  BuilderType& aBuilder)
+  ServoCSSAnimationBuilder& aBuilder)
 {
   // Everything that causes our animation data to change triggers a
   // style change, which in turn triggers a non-animation restyle.
   // Likewise, when we initially construct frames, we're not in a
   // style change, but also not in an animation restyle.
 
   CSSAnimationCollection* collection =
     CSSAnimationCollection::GetAnimationCollection(aTarget.mElement,
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -14,16 +14,17 @@
 #include "mozilla/Keyframe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 #include "nsISupportsImpl.h"
 
 class nsIGlobalObject;
 class ServoComputedData;
 struct nsStyleDisplay;
+class ServoCSSAnimationBuilder;
 
 namespace mozilla {
 class ComputedStyle;
 namespace css {
 class Declaration;
 } /* namespace css */
 namespace dom {
 class KeyframeEffectReadOnly;
@@ -345,16 +346,15 @@ private:
   // This includes all animation names referenced regardless of whether a
   // corresponding `@keyframes` rule is available.
   //
   // It may contain names which are no longer referenced, but it should always
   // contain names which are currently referenced, so that it is usable for
   // style invalidation.
   nsTHashtable<nsRefPtrHashKey<nsAtom>> mMaybeReferencedAnimations;
 
-  template<class BuilderType>
   void DoUpdateAnimations(
     const mozilla::NonOwningAnimationTarget& aTarget,
     const nsStyleDisplay& aStyleDisplay,
-    BuilderType& aBuilder);
+    ServoCSSAnimationBuilder& aBuilder);
 };
 
 #endif /* !defined(nsAnimationManager_h_) */