Bug 1040543 part 4 - Create Animation objects and set on AnimationPlayer; r=bz
authorBrian Birtles <birtles@gmail.com>
Sun, 10 Aug 2014 17:06:47 +1000
changeset 198786 a50e04b3a69991cd592b394db8bd163ebe05c993
parent 198785 cc995232033eb474ca0ce46f27c2f43a849cdff1
child 198787 86f0c54582ffec5ef017b76d48261cf093aae35c
push id27286
push usernigelbabu@gmail.com
push dateMon, 11 Aug 2014 06:26:45 +0000
treeherdermozilla-central@8c4a1b3a2a8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1040543
milestone34.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 1040543 part 4 - Create Animation objects and set on AnimationPlayer; r=bz
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -51,17 +51,17 @@ ComputedTimingFunction::GetValue(double 
 }
 
 // In the Web Animations model, the time fraction can be outside the range
 // [0.0, 1.0] but it shouldn't be Infinity.
 const double ComputedTiming::kNullTimeFraction = PositiveInfinity<double>();
 
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline, mSource)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationPlayer, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationPlayer, Release)
 
 JSObject*
 AnimationPlayer::WrapObject(JSContext* aCx)
 {
   return dom::AnimationPlayerBinding::Wrap(aCx, this);
@@ -96,16 +96,22 @@ AnimationPlayer::CurrentTime() const
   // is null.
   if (currentTime.IsNull()) {
     return 0.0;
   }
 
   return currentTime.Value().ToMilliseconds();
 }
 
+void
+AnimationPlayer::SetSource(Animation* aSource)
+{
+  mSource = aSource;
+}
+
 bool
 AnimationPlayer::IsRunning() const
 {
   if (IsPaused() || IsFinishedTransition()) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTiming(mTiming);
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -141,21 +141,23 @@ public:
 
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
 
   AnimationTimeline* GetParentObject() const { return mTimeline; }
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   // AnimationPlayer methods
-  Animation* GetSource() const { return nullptr; }
+  Animation* GetSource() const { return mSource; }
   AnimationTimeline* Timeline() const { return mTimeline; }
   double StartTime() const;
   double CurrentTime() const;
 
+  void SetSource(Animation* aSource);
+
   // FIXME: If we succeed in moving transition-specific code to a type of
   // AnimationEffect (as per the Web Animations API) we should remove these
   // virtual methods.
   virtual ElementPropertyTransition* AsTransition() { return nullptr; }
   virtual const ElementPropertyTransition* AsTransition() const {
     return nullptr;
   }
 
@@ -248,14 +250,15 @@ public:
   };
   // One of the above constants, or an integer for the iteration
   // whose start we last notified on.
   uint64_t mLastNotification;
 
   InfallibleTArray<AnimationProperty> mProperties;
 
   nsRefPtr<AnimationTimeline> mTimeline;
+  nsRefPtr<Animation> mSource;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_AnimationPlayer_h
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -19,16 +19,17 @@
 #include "RestyleManager.h"
 #include "nsLayoutUtils.h"
 #include "nsIFrame.h"
 #include "nsIDocument.h"
 #include <math.h>
 
 using namespace mozilla;
 using namespace mozilla::css;
+using mozilla::dom::Animation;
 using mozilla::dom::AnimationPlayer;
 
 void
 nsAnimationManager::UpdateStyleAndEvents(AnimationPlayerCollection*
                                            aCollection,
                                          TimeStamp aRefreshTime,
                                          EnsureStyleRuleFlags aFlags)
 {
@@ -438,16 +439,20 @@ nsAnimationManager::BuildAnimations(nsSt
 
     dest->mTiming.mIterationDuration =
       TimeDuration::FromMilliseconds(src.GetDuration());
     dest->mTiming.mDelay = TimeDuration::FromMilliseconds(src.GetDelay());
     dest->mTiming.mIterationCount = src.GetIterationCount();
     dest->mTiming.mDirection = src.GetDirection();
     dest->mTiming.mFillMode = src.GetFillMode();
 
+    nsRefPtr<Animation> destAnim =
+      new Animation(mPresContext->Document());
+    dest->SetSource(destAnim);
+
     dest->mStartTime = now;
     dest->mPlayState = src.GetPlayState();
     if (dest->IsPaused()) {
       dest->mPauseStart = now;
     } else {
       dest->mPauseStart = TimeStamp();
     }
 
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -484,16 +484,19 @@ nsTransitionManager::ConsiderStartingTra
     }
 
     duration *= valuePortion;
 
     pt->mStartForReversingTest = oldPT->mProperties[0].mSegments[0].mToValue;
     pt->mReversePortion = valuePortion;
   }
 
+  nsRefPtr<dom::Animation> anim = new dom::Animation(aElement->OwnerDoc());
+  pt->SetSource(anim);
+
   AnimationProperty& prop = *pt->mProperties.AppendElement();
   prop.mProperty = aProperty;
 
   AnimationPropertySegment& segment = *prop.mSegments.AppendElement();
   segment.mFromValue = startValue;
   segment.mToValue = endValue;
   segment.mFromKey = 0;
   segment.mToKey = 1;