Bug 1178662 part 3 - Separate SetTimeline function in order to call from style. r=birtles
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Tue, 31 May 2016 09:42:37 +0900
changeset 340633 2f29a879a99b23540addcd077c08ead79b035502
parent 340632 00287f808a350be8ff8a452695d303968c825b4f
child 340634 ca028a4f21e9458477d0e7fe55bfaac59d914481
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1178662
milestone49.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 1178662 part 3 - Separate SetTimeline function in order to call from style. r=birtles MozReview-Commit-ID: 9KbsbPuAMW7
dom/animation/Animation.cpp
dom/animation/Animation.h
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -108,17 +108,17 @@ Animation::Constructor(const GlobalObjec
       AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
     if (!document) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
     timeline = document->Timeline();
   }
 
-  animation->SetTimeline(timeline);
+  animation->SetTimelineNoUpdate(timeline);
   animation->SetEffect(aEffect);
 
   return animation.forget();
 }
 
 void
 Animation::SetId(const nsAString& aId)
 {
@@ -146,32 +146,36 @@ Animation::SetEffect(KeyframeEffectReadO
   }
 
   UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
 }
 
 void
 Animation::SetTimeline(AnimationTimeline* aTimeline)
 {
+  SetTimelineNoUpdate(aTimeline);
+  PostUpdate();
+}
+
+void
+Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
+{
   if (mTimeline == aTimeline) {
     return;
   }
 
   if (mTimeline) {
     mTimeline->NotifyAnimationUpdated(*this);
   }
 
   mTimeline = aTimeline;
 
   // FIXME(spec): Once we implement the seeking defined in the spec
   // surely this should be SeekFlag::DidSeek but the spec says otherwise.
   UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
-
-  // FIXME: When we expose this method to script we'll need to call PostUpdate
-  // (but *not* when this method gets called from style).
 }
 
 // https://w3c.github.io/web-animations/#set-the-animation-start-time
 void
 Animation::SetStartTime(const Nullable<TimeDuration>& aNewStartTime)
 {
   if (aNewStartTime == mStartTime) {
     return;
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -140,16 +140,17 @@ public:
    * in future we will likely have to flush style in
    * CSSAnimation::PauseFromJS so we leave it for now.
    */
   void PauseFromJS(ErrorResult& aRv) { Pause(aRv); }
 
   // Wrapper functions for Animation DOM methods when called from style.
 
   virtual void CancelFromStyle() { CancelNoUpdate(); }
+  void SetTimelineNoUpdate(AnimationTimeline* aTimeline);
 
   virtual void Tick();
   bool NeedsTicks() const
   {
     AnimationPlayState playState = PlayState();
     return playState == AnimationPlayState::Running ||
            playState == AnimationPlayState::Pending;
   }
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -644,17 +644,17 @@ CSSAnimationBuilder::Build(nsPresContext
   effect->SetKeyframes(Move(keyframes), mStyleContext);
 
   RefPtr<CSSAnimation> animation =
     new CSSAnimation(aPresContext->Document()->GetScopeObject(),
                      aSrc.GetName());
   animation->SetOwningElement(
     OwningElementRef(*mTarget, mStyleContext->GetPseudoType()));
 
-  animation->SetTimeline(mTimeline);
+  animation->SetTimelineNoUpdate(mTimeline);
   animation->SetEffect(effect);
 
   if (isStylePaused) {
     animation->PauseFromStyle();
   } else {
     animation->PlayFromStyle();
   }
 
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -761,17 +761,17 @@ nsTransitionManager::ConsiderStartingTra
   MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
              "ServoRestyleManager should not use nsTransitionManager "
              "for transitions");
 
   RefPtr<CSSTransition> animation =
     new CSSTransition(mPresContext->Document()->GetScopeObject());
   animation->SetOwningElement(
     OwningElementRef(*aElement, aNewStyleContext->GetPseudoType()));
-  animation->SetTimeline(timeline);
+  animation->SetTimelineNoUpdate(timeline);
   animation->SetCreationSequence(
     mPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration());
   // The order of the following two calls is important since PlayFromStyle
   // will add the animation to the PendingAnimationTracker of its effect's
   // document. When we come to make effect writeable (bug 1049975) we should
   // remove this dependency.
   animation->SetEffect(pt);
   animation->PlayFromStyle();