Bug 920425 part.10 Use mozilla::WidgetEvent::AsTransitionEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:22 +0900
changeset 166073 5a65548a15565a05742d489d9c05f0b9a9803ede
parent 166072 9080e47ab89d3dd3299ec38f314c51c1e1407cef
child 166074 2a8ad5e277383b6ef8c4bdde4acfe8e413c85cb5
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs920425
milestone27.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 920425 part.10 Use mozilla::WidgetEvent::AsTransitionEvent() r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMTransitionEvent.cpp
content/events/src/nsDOMTransitionEvent.h
content/events/src/nsEventDispatcher.cpp
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -707,18 +707,17 @@ nsDOMEvent::DuplicatePrivateData()
         new WidgetSimpleGestureEvent(false, msg, nullptr, 0, 0.0);
       simpleGestureEvent->
         AssignSimpleGestureEventData(*oldSimpleGestureEvent, true);
       newEvent = simpleGestureEvent;
       break;
     }
     case NS_TRANSITION_EVENT:
     {
-      InternalTransitionEvent* oldTransitionEvent =
-        static_cast<InternalTransitionEvent*>(mEvent);
+      InternalTransitionEvent* oldTransitionEvent = mEvent->AsTransitionEvent();
       InternalTransitionEvent* transitionEvent =
          new InternalTransitionEvent(false, msg,
                                      oldTransitionEvent->propertyName,
                                      oldTransitionEvent->elapsedTime,
                                      oldTransitionEvent->pseudoElement);
       transitionEvent->AssignTransitionEventData(*oldTransitionEvent, true);
       newEvent = transitionEvent;
       break;
--- a/content/events/src/nsDOMTransitionEvent.cpp
+++ b/content/events/src/nsDOMTransitionEvent.cpp
@@ -41,42 +41,49 @@ nsDOMTransitionEvent::Constructor(const 
                                   mozilla::ErrorResult& aRv)
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
 
-  e->TransitionEvent()->propertyName = aParam.mPropertyName;
-  e->TransitionEvent()->elapsedTime = aParam.mElapsedTime;
-  e->TransitionEvent()->pseudoElement = aParam.mPseudoElement;
+  InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
+  internalEvent->propertyName = aParam.mPropertyName;
+  internalEvent->elapsedTime = aParam.mElapsedTime;
+  internalEvent->pseudoElement = aParam.mPseudoElement;
 
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 NS_IMETHODIMP
 nsDOMTransitionEvent::GetPropertyName(nsAString & aPropertyName)
 {
-  aPropertyName = TransitionEvent()->propertyName;
+  aPropertyName = mEvent->AsTransitionEvent()->propertyName;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTransitionEvent::GetElapsedTime(float *aElapsedTime)
 {
   *aElapsedTime = ElapsedTime();
   return NS_OK;
 }
 
+float
+nsDOMTransitionEvent::ElapsedTime()
+{
+  return mEvent->AsTransitionEvent()->elapsedTime;
+}
+
 NS_IMETHODIMP
 nsDOMTransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
 {
-  aPseudoElement = TransitionEvent()->pseudoElement;
+  aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement;
   return NS_OK;
 }
 
 nsresult
 NS_NewDOMTransitionEvent(nsIDOMEvent **aInstancePtrResult,
                          mozilla::dom::EventTarget* aOwner,
                          nsPresContext *aPresContext,
                          InternalTransitionEvent* aEvent)
--- a/content/events/src/nsDOMTransitionEvent.h
+++ b/content/events/src/nsDOMTransitionEvent.h
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsDOMTransitionEvent_h_
 #define nsDOMTransitionEvent_h_
 
 #include "nsDOMEvent.h"
 #include "nsIDOMTransitionEvent.h"
-#include "mozilla/ContentEvents.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/dom/TransitionEventBinding.h"
 
 class nsAString;
 
 class nsDOMTransitionEvent : public nsDOMEvent,
                              public nsIDOMTransitionEvent
 {
 public:
@@ -35,22 +35,12 @@ public:
   {
     return mozilla::dom::TransitionEventBinding::Wrap(aCx, aScope, this);
   }
 
   // xpidl implementation
   // GetPropertyName(nsAString& aPropertyName)
   // GetPseudoElement(nsAString& aPreudoElement)
 
-  float ElapsedTime()
-  {
-    return TransitionEvent()->elapsedTime;
-  }
-
-private:
-  mozilla::InternalTransitionEvent* TransitionEvent() {
-    NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_TRANSITION_EVENT,
-                      "unexpected struct type");
-    return static_cast<mozilla::InternalTransitionEvent*>(mEvent);
-  }
+  float ElapsedTime();
 };
 
 #endif /* !defined(nsDOMTransitionEvent_h_) */
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -741,17 +741,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_SIMPLE_GESTURE_EVENT:
       return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
                static_cast<WidgetSimpleGestureEvent*>(aEvent));
     case NS_TOUCH_EVENT:
       return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
                                  static_cast<WidgetTouchEvent*>(aEvent));
     case NS_TRANSITION_EVENT:
       return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
-               static_cast<InternalTransitionEvent*>(aEvent));
+                                      aEvent->AsTransitionEvent());
     case NS_ANIMATION_EVENT:
       return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
                static_cast<InternalAnimationEvent*>(aEvent));
     default:
       // For all other types of events, create a vanilla event object.
       return NS_NewDOMEvent(aDOMEvent, aOwner, aPresContext, aEvent);
     }
   }