Bug 968725 Simplify constructor of InternalAnimationEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 11 Feb 2014 14:35:25 +0900
changeset 168036 7b911af320e5c63018ac4d2aad25eee71a307505
parent 168035 978094768f3ed5ac66164b977f2ac0fb6e79e65a
child 168037 23e8f3e7bab574369e730c63b8a5ebf32778e3d9
push id4990
push userryanvm@gmail.com
push dateTue, 11 Feb 2014 13:44:23 +0000
treeherderfx-team@937e5e0668ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs968725
milestone30.0a1
Bug 968725 Simplify constructor of InternalAnimationEvent r=smaug
dom/events/nsDOMAnimationEvent.cpp
layout/style/nsAnimationManager.h
widget/ContentEvents.h
--- a/dom/events/nsDOMAnimationEvent.cpp
+++ b/dom/events/nsDOMAnimationEvent.cpp
@@ -8,19 +8,17 @@
 #include "mozilla/ContentEvents.h"
 
 using namespace mozilla;
 
 nsDOMAnimationEvent::nsDOMAnimationEvent(mozilla::dom::EventTarget* aOwner,
                                          nsPresContext *aPresContext,
                                          InternalAnimationEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
-               aEvent ? aEvent :
-                        new InternalAnimationEvent(false, 0, EmptyString(),
-                                                   0.0, EmptyString()))
+               aEvent ? aEvent : new InternalAnimationEvent(false, 0))
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -24,30 +24,30 @@ class Declaration;
 struct AnimationEventInfo {
   nsRefPtr<mozilla::dom::Element> mElement;
   mozilla::InternalAnimationEvent mEvent;
 
   AnimationEventInfo(mozilla::dom::Element *aElement,
                      const nsString& aAnimationName,
                      uint32_t aMessage, mozilla::TimeDuration aElapsedTime,
                      const nsAString& aPseudoElement)
-    : mElement(aElement),
-      mEvent(true, aMessage, aAnimationName, aElapsedTime.ToSeconds(),
-             aPseudoElement)
+    : mElement(aElement), mEvent(true, aMessage)
   {
+    // XXX Looks like nobody initialize WidgetEvent::time
+    mEvent.animationName = aAnimationName;
+    mEvent.elapsedTime = aElapsedTime.ToSeconds();
+    mEvent.pseudoElement = aPseudoElement;
   }
 
   // InternalAnimationEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   AnimationEventInfo(const AnimationEventInfo &aOther)
-    : mElement(aOther.mElement),
-      mEvent(true, aOther.mEvent.message,
-             aOther.mEvent.animationName, aOther.mEvent.elapsedTime,
-             aOther.mEvent.pseudoElement)
+    : mElement(aOther.mElement), mEvent(true, aOther.mEvent.message)
   {
+    mEvent.AssignAnimationEventData(aOther.mEvent, false);
   }
 };
 
 typedef InfallibleTArray<AnimationEventInfo> EventArray;
 
 struct AnimationPropertySegment
 {
   float mFromKey, mToKey;
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -330,47 +330,43 @@ public:
 class InternalAnimationEvent : public WidgetEvent
 {
 public:
   virtual InternalAnimationEvent* AsAnimationEvent() MOZ_OVERRIDE
   {
     return this;
   }
 
-  InternalAnimationEvent(bool aIsTrusted, uint32_t aMessage,
-                         const nsAString& aAnimationName, float aElapsedTime,
-                         const nsAString& aPseudoElement) :
-    WidgetEvent(aIsTrusted, aMessage, NS_ANIMATION_EVENT),
-    animationName(aAnimationName), elapsedTime(aElapsedTime),
-    pseudoElement(aPseudoElement)
+  InternalAnimationEvent(bool aIsTrusted, uint32_t aMessage)
+    : WidgetEvent(aIsTrusted, aMessage, NS_ANIMATION_EVENT)
+    , elapsedTime(0.0)
   {
     mFlags.mCancelable = false;
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_ANIMATION_EVENT,
                "Duplicate() must be overridden by sub class");
-    InternalAnimationEvent* result =
-      new InternalAnimationEvent(false, message, animationName,
-                                 elapsedTime, pseudoElement);
+    InternalAnimationEvent* result = new InternalAnimationEvent(false, message);
     result->AssignAnimationEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   nsString animationName;
   float elapsedTime;
   nsString pseudoElement;
 
   void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
                                 bool aCopyTargets)
   {
     AssignEventData(aEvent, aCopyTargets);
 
-    // animationName, elapsedTime and pseudoElement must have been initialized
-    // with the constructor.
+    animationName = aEvent.animationName;
+    elapsedTime = aEvent.elapsedTime;
+    pseudoElement = aEvent.pseudoElement;
   }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_ContentEvents_h__