Bug 1183461 part 6 - Store the generating animation on the event; r=heycam
authorBrian Birtles <birtles@gmail.com>
Tue, 15 Sep 2015 14:05:44 +0900
changeset 295390 e3d6aa401ec04d51a251228a11b79e472dc97e40
parent 295389 aa1792f2af78378d4e6a276935685da14e42ebed
child 295391 95e0fae6c3e2e243dd22ba01fa8d4a2b76a26856
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1183461
milestone43.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 1183461 part 6 - Store the generating animation on the event; r=heycam In order to sort between events that have the same timestamp we use the sort order of the corresponding animations so we need to store a pointer to the animation along with the event.
layout/style/AnimationCommon.h
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -532,16 +532,17 @@ public:
   bool HasQueuedEvents() const { return !mPendingEvents.IsEmpty(); }
 
   // Methods for supporting cycle-collection
   void Traverse(nsCycleCollectionTraversalCallback* aCallback,
                 const char* aName)
   {
     for (EventInfo& info : mPendingEvents) {
       ImplCycleCollectionTraverse(*aCallback, info.mElement, aName);
+      ImplCycleCollectionTraverse(*aCallback, info.mAnimation, aName);
     }
   }
   void Unlink() { mPendingEvents.Clear(); }
 
 protected:
   typedef nsTArray<EventInfo> EventArray;
 
   EventArray mPendingEvents;
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -244,18 +244,18 @@ CSSAnimation::QueueEvents()
     // First notifying for start of 0th iteration by appending an
     // 'animationstart':
     StickyTimeDuration elapsedTime =
       std::min(StickyTimeDuration(InitialAdvance()),
                computedTiming.mActiveDuration);
     manager->QueueEvent(AnimationEventInfo(owningElement, owningPseudoType,
                                            eAnimationStart, mAnimationName,
                                            elapsedTime,
-                                           ElapsedTimeToTimeStamp(
-                                             elapsedTime)));
+                                           ElapsedTimeToTimeStamp(elapsedTime),
+                                           this));
     // Then have the shared code below append an 'animationend':
     message = eAnimationEnd;
   } else {
     return; // No events need to be sent
   }
 
   StickyTimeDuration elapsedTime;
 
@@ -266,17 +266,18 @@ CSSAnimation::QueueEvents()
                                               InitialAdvance()));
   } else {
     MOZ_ASSERT(message == eAnimationEnd);
     elapsedTime = computedTiming.mActiveDuration;
   }
 
   manager->QueueEvent(AnimationEventInfo(owningElement, owningPseudoType,
                                          message, mAnimationName, elapsedTime,
-                                         ElapsedTimeToTimeStamp(elapsedTime)));
+                                         ElapsedTimeToTimeStamp(elapsedTime),
+                                         this));
 }
 
 bool
 CSSAnimation::HasEndEventToQueue() const
 {
   if (!mEffect) {
     return false;
   }
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -22,39 +22,43 @@ namespace css {
 class Declaration;
 } /* namespace css */
 namespace dom {
 class Promise;
 } /* namespace dom */
 
 struct AnimationEventInfo {
   nsRefPtr<dom::Element> mElement;
+  nsRefPtr<dom::Animation> mAnimation;
   InternalAnimationEvent mEvent;
   TimeStamp mTimeStamp;
 
   AnimationEventInfo(dom::Element* aElement,
                      nsCSSPseudoElements::Type aPseudoType,
                      EventMessage aMessage,
                      const nsSubstring& aAnimationName,
                      const StickyTimeDuration& aElapsedTime,
-                     const TimeStamp& aTimeStamp)
+                     const TimeStamp& aTimeStamp,
+                     dom::Animation* aAnimation)
     : mElement(aElement)
+    , mAnimation(aAnimation)
     , mEvent(true, aMessage)
     , mTimeStamp(aTimeStamp)
   {
     // XXX Looks like nobody initialize WidgetEvent::time
     mEvent.animationName = aAnimationName;
     mEvent.elapsedTime = aElapsedTime.ToSeconds();
     mEvent.pseudoElement = AnimationCollection::PseudoTypeAsString(aPseudoType);
   }
 
   // InternalAnimationEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   AnimationEventInfo(const AnimationEventInfo& aOther)
     : mElement(aOther.mElement)
+    , mAnimation(aOther.mAnimation)
     , mEvent(true, aOther.mEvent.mMessage)
     , mTimeStamp(aOther.mTimeStamp)
   {
     mEvent.AssignAnimationEventData(aOther.mEvent, false);
   }
 };
 
 namespace dom {
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -146,18 +146,18 @@ CSSTransition::QueueEvents()
     return;
   }
 
   nsTransitionManager* manager = presContext->TransitionManager();
   manager->QueueEvent(TransitionEventInfo(owningElement, owningPseudoType,
                                           TransitionProperty(),
                                           mEffect->Timing()
                                             .mIterationDuration,
-                                          AnimationTimeToTimeStamp(
-                                            EffectEnd())));
+                                          AnimationTimeToTimeStamp(EffectEnd()),
+                                          this));
 }
 
 bool
 CSSTransition::HasEndEventToQueue() const
 {
   if (!mEffect) {
     return false;
   }
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -191,39 +191,43 @@ protected:
   // its animation index should be updated.
   bool mNeedsNewAnimationIndexWhenRun;
 };
 
 } // namespace dom
 
 struct TransitionEventInfo {
   nsRefPtr<dom::Element> mElement;
+  nsRefPtr<dom::Animation> mAnimation;
   InternalTransitionEvent mEvent;
   TimeStamp mTimeStamp;
 
   TransitionEventInfo(dom::Element* aElement,
                       nsCSSPseudoElements::Type aPseudoType,
                       nsCSSProperty aProperty,
                       TimeDuration aDuration,
-                      const TimeStamp& aTimeStamp)
+                      const TimeStamp& aTimeStamp,
+                      dom::Animation* aAnimation)
     : mElement(aElement)
+    , mAnimation(aAnimation)
     , mEvent(true, eTransitionEnd)
     , mTimeStamp(aTimeStamp)
   {
     // XXX Looks like nobody initialize WidgetEvent::time
     mEvent.propertyName =
       NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
     mEvent.elapsedTime = aDuration.ToSeconds();
     mEvent.pseudoElement = AnimationCollection::PseudoTypeAsString(aPseudoType);
   }
 
   // InternalTransitionEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   TransitionEventInfo(const TransitionEventInfo& aOther)
     : mElement(aOther.mElement)
+    , mAnimation(aOther.mAnimation)
     , mEvent(true, eTransitionEnd)
     , mTimeStamp(aOther.mTimeStamp)
   {
     mEvent.AssignTransitionEventData(aOther.mEvent, false);
   }
 };
 
 } // namespace mozilla