Bug 969219 Simplify constructor of InternalTransitionEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 11 Feb 2014 14:35:25 +0900
changeset 186249 23e8f3e7bab574369e730c63b8a5ebf32778e3d9
parent 186248 7b911af320e5c63018ac4d2aad25eee71a307505
child 186250 edd724161ab431c0f9905c707d016553ed19c5e8
child 186251 1e038f308b8da2e04fdafe5bf06931d8c0d919b5
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs969219
milestone30.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 969219 Simplify constructor of InternalTransitionEvent r=smaug
dom/events/nsDOMTransitionEvent.cpp
layout/style/nsTransitionManager.cpp
widget/ContentEvents.h
--- a/dom/events/nsDOMTransitionEvent.cpp
+++ b/dom/events/nsDOMTransitionEvent.cpp
@@ -8,19 +8,17 @@
 #include "mozilla/ContentEvents.h"
 
 using namespace mozilla;
 
 nsDOMTransitionEvent::nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
                                            nsPresContext *aPresContext,
                                            InternalTransitionEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
-               aEvent ? aEvent :
-                        new InternalTransitionEvent(false, 0, EmptyString(),
-                                                    0.0, EmptyString()))
+               aEvent ? aEvent : new InternalTransitionEvent(false, 0))
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -830,31 +830,33 @@ nsTransitionManager::SizeOfIncludingThis
 }
 
 struct TransitionEventInfo {
   nsCOMPtr<nsIContent> mElement;
   InternalTransitionEvent mEvent;
 
   TransitionEventInfo(nsIContent *aElement, nsCSSProperty aProperty,
                       TimeDuration aDuration, const nsAString& aPseudoElement)
-    : mElement(aElement),
-      mEvent(true, NS_TRANSITION_END,
-             NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty)),
-             aDuration.ToSeconds(), aPseudoElement)
+    : mElement(aElement)
+    , mEvent(true, NS_TRANSITION_END)
   {
+    // XXX Looks like nobody initialize WidgetEvent::time
+    mEvent.propertyName =
+      NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
+    mEvent.elapsedTime = aDuration.ToSeconds();
+    mEvent.pseudoElement = aPseudoElement;
   }
 
   // InternalTransitionEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   TransitionEventInfo(const TransitionEventInfo &aOther)
-    : mElement(aOther.mElement),
-      mEvent(true, NS_TRANSITION_END,
-             aOther.mEvent.propertyName, aOther.mEvent.elapsedTime,
-             aOther.mEvent.pseudoElement)
+    : mElement(aOther.mElement)
+    , mEvent(true, NS_TRANSITION_END)
   {
+    mEvent.AssignTransitionEventData(aOther.mEvent, false);
   }
 };
 
 /* virtual */ void
 nsTransitionManager::WillRefresh(mozilla::TimeStamp aTime)
 {
   NS_ABORT_IF_FALSE(mPresContext,
                     "refresh driver should not notify additional observers "
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -282,49 +282,46 @@ public:
 class InternalTransitionEvent : public WidgetEvent
 {
 public:
   virtual InternalTransitionEvent* AsTransitionEvent() MOZ_OVERRIDE
   {
     return this;
   }
 
-  InternalTransitionEvent(bool aIsTrusted, uint32_t aMessage,
-                          const nsAString& aPropertyName, float aElapsedTime,
-                          const nsAString& aPseudoElement) :
-    WidgetEvent(aIsTrusted, aMessage, NS_TRANSITION_EVENT),
-    propertyName(aPropertyName), elapsedTime(aElapsedTime),
-    pseudoElement(aPseudoElement)
+  InternalTransitionEvent(bool aIsTrusted, uint32_t aMessage)
+    : WidgetEvent(aIsTrusted, aMessage, NS_TRANSITION_EVENT)
+    , elapsedTime(0.0)
   {
     mFlags.mCancelable = false;
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_TRANSITION_EVENT,
                "Duplicate() must be overridden by sub class");
     InternalTransitionEvent* result =
-      new InternalTransitionEvent(false, message, propertyName,
-                                  elapsedTime, pseudoElement);
+      new InternalTransitionEvent(false, message);
     result->AssignTransitionEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   nsString propertyName;
   float elapsedTime;
   nsString pseudoElement;
 
   void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
                                  bool aCopyTargets)
   {
     AssignEventData(aEvent, aCopyTargets);
 
-    // propertyName, elapsedTime and pseudoElement must have been initialized
-    // with the constructor.
+    propertyName = aEvent.propertyName;
+    elapsedTime = aEvent.elapsedTime;
+    pseudoElement = aEvent.pseudoElement;
   }
 };
 
 /******************************************************************************
  * mozilla::InternalAnimationEvent
  ******************************************************************************/
 
 class InternalAnimationEvent : public WidgetEvent