Bug 1183461 part 2 - Reorder the parameters to EventInfo constructors; r=heycam
authorBrian Birtles <birtles@gmail.com>
Tue, 15 Sep 2015 14:04:05 +0900
changeset 295386 52305b561896b7817437698590c753e869350297
parent 295385 b070f90f3cde66aba5e3bfd5aa86d6cb10014c3d
child 295387 2718828e8f4488c0c47a1699f135b609a8dbc6c8
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 2 - Reorder the parameters to EventInfo constructors; r=heycam This patch lines up the parameters of AnimationEventInfo and TransitionEventInfo constructors so that they are more logical and consistent. Specifically, it groups the element and pseudo type together since they form a logical pair denoting the event target. For AnimationEventInfo this patch also places the type of event before the common event parameters since the event type seems to be more significant. This patch also performs some miscelleaneous housekeeping: removing some unnecessary namespace prefixes, whitespace fixes, and making TransitionEventInfo use the same concrete type to store the target element as AnimationEventInfo (dom::Element instead of nsIContent).
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -241,19 +241,19 @@ CSSAnimation::QueueEvents()
   } else if (wasActive && isActive && !isSameIteration) {
     message = eAnimationIteration;
   } else if (skippedActivePhase) {
     // First notifying for start of 0th iteration by appending an
     // 'animationstart':
     StickyTimeDuration elapsedTime =
       std::min(StickyTimeDuration(InitialAdvance()),
                computedTiming.mActiveDuration);
-    manager->QueueEvent(
-      AnimationEventInfo(owningElement, mAnimationName, eAnimationStart,
-                         elapsedTime, owningPseudoType));
+    manager->QueueEvent(AnimationEventInfo(owningElement, owningPseudoType,
+                                           eAnimationStart, mAnimationName,
+                                           elapsedTime));
     // Then have the shared code below append an 'animationend':
     message = eAnimationEnd;
   } else {
     return; // No events need to be sent
   }
 
   StickyTimeDuration elapsedTime;
 
@@ -262,19 +262,18 @@ CSSAnimation::QueueEvents()
                                     computedTiming.mCurrentIteration;
     elapsedTime = StickyTimeDuration(std::max(iterationStart,
                                               InitialAdvance()));
   } else {
     MOZ_ASSERT(message == eAnimationEnd);
     elapsedTime = computedTiming.mActiveDuration;
   }
 
-  manager->QueueEvent(
-    AnimationEventInfo(owningElement, mAnimationName, message, elapsedTime,
-                       owningPseudoType));
+  manager->QueueEvent(AnimationEventInfo(owningElement, owningPseudoType,
+                                         message, mAnimationName, elapsedTime));
 }
 
 bool
 CSSAnimation::HasEndEventToQueue() const
 {
   if (!mEffect) {
     return false;
   }
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -21,35 +21,36 @@ namespace mozilla {
 namespace css {
 class Declaration;
 } /* namespace css */
 namespace dom {
 class Promise;
 } /* namespace dom */
 
 struct AnimationEventInfo {
-  nsRefPtr<mozilla::dom::Element> mElement;
-  mozilla::InternalAnimationEvent mEvent;
+  nsRefPtr<dom::Element> mElement;
+  InternalAnimationEvent mEvent;
 
-  AnimationEventInfo(mozilla::dom::Element *aElement,
+  AnimationEventInfo(dom::Element* aElement,
+                     nsCSSPseudoElements::Type aPseudoType,
+                     EventMessage aMessage,
                      const nsSubstring& aAnimationName,
-                     EventMessage aMessage,
-                     const mozilla::StickyTimeDuration& aElapsedTime,
-                     nsCSSPseudoElements::Type aPseudoType)
-    : mElement(aElement), mEvent(true, aMessage)
+                     const StickyTimeDuration& aElapsedTime)
+    : mElement(aElement)
+    , mEvent(true, aMessage)
   {
     // 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)
+  AnimationEventInfo(const AnimationEventInfo& aOther)
     : mElement(aOther.mElement)
     , mEvent(true, aOther.mEvent.mMessage)
   {
     mEvent.AssignAnimationEventData(aOther.mEvent, false);
   }
 };
 
 namespace dom {
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -140,22 +140,22 @@ CSSTransition::QueueEvents()
   nsCSSPseudoElements::Type owningPseudoType;
   mOwningElement.GetElement(owningElement, owningPseudoType);
   MOZ_ASSERT(owningElement, "Owning element should be set");
 
   nsPresContext* presContext = mOwningElement.GetRenderedPresContext();
   if (!presContext) {
     return;
   }
+
   nsTransitionManager* manager = presContext->TransitionManager();
-
-  manager->QueueEvent(
-    TransitionEventInfo(owningElement, TransitionProperty(),
-                        mEffect->Timing().mIterationDuration,
-                        owningPseudoType));
+  manager->QueueEvent(TransitionEventInfo(owningElement, owningPseudoType,
+                                          TransitionProperty(),
+                                          mEffect->Timing()
+                                            .mIterationDuration));
 }
 
 bool
 CSSTransition::HasEndEventToQueue() const
 {
   if (!mEffect) {
     return false;
   }
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -54,17 +54,17 @@ struct ElementPropertyTransition : publi
     return Properties()[0].mProperty;
   }
 
   // This is the start value to be used for a check for whether a
   // transition is being reversed.  Normally the same as
   // mProperties[0].mSegments[0].mFromValue, except when this transition
   // started as the reversal of another in-progress transition.
   // Needed so we can handle two reverses in a row.
-  mozilla::StyleAnimationValue mStartForReversingTest;
+  StyleAnimationValue mStartForReversingTest;
   // Likewise, the portion (in value space) of the "full" reversed
   // transition that we're actually covering.  For example, if a :hover
   // effect has a transition that moves the element 10px to the right
   // (by changing 'left' from 0px to 10px), and the mouse moves in to
   // the element (starting the transition) but then moves out after the
   // transition has advanced 4px, the second transition (from 10px/4px
   // to 0px) will have mReversePortion of 0.4.  (If the mouse then moves
   // in again when the transition is back to 2px, the mReversePortion
@@ -190,35 +190,36 @@ protected:
   // When true, indicates that when this transition next leaves the idle state,
   // its animation index should be updated.
   bool mNeedsNewAnimationIndexWhenRun;
 };
 
 } // namespace dom
 
 struct TransitionEventInfo {
-  nsCOMPtr<nsIContent> mElement;
+  nsRefPtr<dom::Element> mElement;
   InternalTransitionEvent mEvent;
 
-  TransitionEventInfo(nsIContent *aElement, nsCSSProperty aProperty,
-                      TimeDuration aDuration,
-                      nsCSSPseudoElements::Type aPseudoType)
+  TransitionEventInfo(dom::Element* aElement,
+                      nsCSSPseudoElements::Type aPseudoType,
+                      nsCSSProperty aProperty,
+                      TimeDuration aDuration)
     : mElement(aElement)
     , mEvent(true, eTransitionEnd)
   {
     // 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)
+  TransitionEventInfo(const TransitionEventInfo& aOther)
     : mElement(aOther.mElement)
     , mEvent(true, eTransitionEnd)
   {
     mEvent.AssignTransitionEventData(aOther.mEvent, false);
   }
 };
 
 } // namespace mozilla