Bug 1242872 - Part 2: Set timeline in CSSAnimationBuilder::Build. r=dbaron
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Fri, 19 Feb 2016 09:16:15 +0900
changeset 321839 152e7142f5db0e4ebb935abb0370259e4b252b87
parent 321838 ba0463bb2058fb05855fa68d0104f5329322e676
child 321840 f50864e2c30de5b3dee4b1e5689d04c8d803692d
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1242872
milestone47.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 1242872 - Part 2: Set timeline in CSSAnimationBuilder::Build. r=dbaron MozReview-Commit-ID: 6bisME1VK0d
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -325,20 +325,19 @@ nsAnimationManager::UpdateAnimations(nsS
       disp->mAnimationNameCount == 1 &&
       disp->mAnimations[0].GetName().IsEmpty()) {
     return;
   }
 
   nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
 
   // build the animations list
-  dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
   AnimationPtrArray newAnimations;
   if (!aStyleContext->IsInDisplayNoneSubtree()) {
-    BuildAnimations(aStyleContext, aElement, timeline, newAnimations);
+    BuildAnimations(aStyleContext, aElement, newAnimations);
   }
 
   if (newAnimations.IsEmpty()) {
     if (collection) {
       collection->Destroy();
     }
     return;
   }
@@ -564,16 +563,17 @@ class MOZ_STACK_CLASS CSSAnimationBuilde
 public:
   CSSAnimationBuilder(nsStyleContext* aStyleContext,
                       dom::Element* aTarget)
     : mStyleContext(aStyleContext)
     , mTarget(aTarget)
   {
     MOZ_ASSERT(aStyleContext);
     MOZ_ASSERT(aTarget);
+    mTimeline = mTarget->OwnerDoc()->Timeline();
   }
 
   already_AddRefed<CSSAnimation>
   Build(nsPresContext* aPresContext,
         const StyleAnimation& aSrc,
         const nsCSSKeyframesRule* aRule);
 
 private:
@@ -600,16 +600,17 @@ private:
     timing.mDirection = aStyleAnimation.GetDirection();
     timing.mFill = aStyleAnimation.GetFillMode();
 
     return timing;
   }
 
   RefPtr<nsStyleContext> mStyleContext;
   RefPtr<dom::Element> mTarget;
+  RefPtr<dom::DocumentTimeline> mTimeline;
 
   ResolvedStyleCache mResolvedStyles;
   RefPtr<nsStyleContext> mStyleWithoutAnimation;
 };
 
 already_AddRefed<CSSAnimation>
 CSSAnimationBuilder::Build(nsPresContext* aPresContext,
                            const StyleAnimation& aSrc,
@@ -628,16 +629,17 @@ CSSAnimationBuilder::Build(nsPresContext
   effect->Properties() = Move(animationProperties);
 
   RefPtr<CSSAnimation> animation =
     new CSSAnimation(aPresContext->Document()->GetScopeObject(),
                      aSrc.GetName());
   animation->SetOwningElement(
     OwningElementRef(*mTarget, mStyleContext->GetPseudoType()));
 
+  animation->SetTimeline(mTimeline);
   animation->SetEffect(effect);
 
   return animation.forget();
 }
 
 void
 CSSAnimationBuilder::BuildAnimationProperties(
   nsPresContext* aPresContext,
@@ -848,17 +850,16 @@ CSSAnimationBuilder::BuildSegment(Infall
   }
 
   return true;
 }
 
 void
 nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
                                     dom::Element* aTarget,
-                                    dom::AnimationTimeline* aTimeline,
                                     AnimationPtrArray& aAnimations)
 {
   MOZ_ASSERT(aAnimations.IsEmpty(), "expect empty array");
 
   const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
 
   CSSAnimationBuilder builder(aStyleContext, aTarget);
 
@@ -878,17 +879,16 @@ nsAnimationManager::BuildAnimations(nsSt
       src.GetName().IsEmpty()
       ? nullptr
       : mPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(src.GetName());
     if (!rule) {
       continue;
     }
 
     RefPtr<CSSAnimation> dest = builder.Build(mPresContext, src, rule);
-    dest->SetTimeline(aTimeline);
     dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
     aAnimations.AppendElement(dest);
 
     if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) {
       dest->PauseFromStyle();
     } else {
       dest->PlayFromStyle();
     }
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -342,13 +342,12 @@ protected:
     return nsGkAtoms::animationsOfAfterProperty;
   }
 
   mozilla::DelayedEventDispatcher<mozilla::AnimationEventInfo> mEventDispatcher;
 
 private:
   void BuildAnimations(nsStyleContext* aStyleContext,
                        mozilla::dom::Element* aTarget,
-                       mozilla::dom::AnimationTimeline* aTimeline,
                        mozilla::AnimationPtrArray& aAnimations);
 };
 
 #endif /* !defined(nsAnimationManager_h_) */