Bug 920425 part.11 Use mozilla::WidgetEvent::AsAnimationEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:22 +0900
changeset 165122 2a8ad5e277383b6ef8c4bdde4acfe8e413c85cb5
parent 165121 5a65548a15565a05742d489d9c05f0b9a9803ede
child 165123 8d1be2be411cc79ca227dfd343fbd81d129a603d
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [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.11 Use mozilla::WidgetEvent::AsAnimationEvent() r=smaug
content/events/src/nsDOMAnimationEvent.cpp
content/events/src/nsDOMAnimationEvent.h
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
--- a/content/events/src/nsDOMAnimationEvent.cpp
+++ b/content/events/src/nsDOMAnimationEvent.cpp
@@ -41,42 +41,49 @@ nsDOMAnimationEvent::Constructor(const m
                                  mozilla::ErrorResult& aRv)
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<nsDOMAnimationEvent> e = new nsDOMAnimationEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
 
-  e->AnimationEvent()->animationName = aParam.mAnimationName;
-  e->AnimationEvent()->elapsedTime = aParam.mElapsedTime;
-  e->AnimationEvent()->pseudoElement = aParam.mPseudoElement;
+  InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
+  internalEvent->animationName = aParam.mAnimationName;
+  internalEvent->elapsedTime = aParam.mElapsedTime;
+  internalEvent->pseudoElement = aParam.mPseudoElement;
 
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 NS_IMETHODIMP
 nsDOMAnimationEvent::GetAnimationName(nsAString & aAnimationName)
 {
-  aAnimationName = AnimationEvent()->animationName;
+  aAnimationName = mEvent->AsAnimationEvent()->animationName;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMAnimationEvent::GetElapsedTime(float *aElapsedTime)
 {
   *aElapsedTime = ElapsedTime();
   return NS_OK;
 }
 
+float
+nsDOMAnimationEvent::ElapsedTime()
+{
+  return mEvent->AsAnimationEvent()->elapsedTime;
+}
+
 NS_IMETHODIMP
 nsDOMAnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
 {
-  aPseudoElement = AnimationEvent()->pseudoElement;
+  aPseudoElement = mEvent->AsAnimationEvent()->pseudoElement;
   return NS_OK;
 }
 
 nsresult
 NS_NewDOMAnimationEvent(nsIDOMEvent **aInstancePtrResult,
                         mozilla::dom::EventTarget* aOwner,
                         nsPresContext *aPresContext,
                         InternalAnimationEvent *aEvent)
--- a/content/events/src/nsDOMAnimationEvent.h
+++ b/content/events/src/nsDOMAnimationEvent.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 nsDOMAnimationEvent_h_
 #define nsDOMAnimationEvent_h_
 
 #include "nsDOMEvent.h"
 #include "nsIDOMAnimationEvent.h"
-#include "mozilla/ContentEvents.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/dom/AnimationEventBinding.h"
 
 class nsAString;
 
 class nsDOMAnimationEvent : public nsDOMEvent,
                             public nsIDOMAnimationEvent
 {
 public:
@@ -35,22 +35,12 @@ public:
   {
     return mozilla::dom::AnimationEventBinding::Wrap(aCx, aScope, this);
   }
 
   // xpidl implementation
   // GetAnimationName(nsAString& aAnimationName);
   // GetPseudoElement(nsAString& aPseudoElement);
 
-  float ElapsedTime()
-  {
-    return AnimationEvent()->elapsedTime;
-  }
-
-private:
-  mozilla::InternalAnimationEvent* AnimationEvent() {
-    NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_ANIMATION_EVENT,
-                      "unexpected struct type");
-    return static_cast<mozilla::InternalAnimationEvent*>(mEvent);
-  }
+  float ElapsedTime();
 };
 
 #endif /* !defined(nsDOMAnimationEvent_h_) */
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -719,18 +719,17 @@ nsDOMEvent::DuplicatePrivateData()
                                      oldTransitionEvent->elapsedTime,
                                      oldTransitionEvent->pseudoElement);
       transitionEvent->AssignTransitionEventData(*oldTransitionEvent, true);
       newEvent = transitionEvent;
       break;
     }
     case NS_ANIMATION_EVENT:
     {
-      InternalAnimationEvent* oldAnimationEvent =
-        static_cast<InternalAnimationEvent*>(mEvent);
+      InternalAnimationEvent* oldAnimationEvent = mEvent->AsAnimationEvent();
       InternalAnimationEvent* animationEvent =
         new InternalAnimationEvent(false, msg,
                                    oldAnimationEvent->animationName,
                                    oldAnimationEvent->elapsedTime,
                                    oldAnimationEvent->pseudoElement);
       animationEvent->AssignAnimationEventData(*oldAnimationEvent, true);
       newEvent = animationEvent;
       break;
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -744,17 +744,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_TOUCH_EVENT:
       return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
                                  static_cast<WidgetTouchEvent*>(aEvent));
     case NS_TRANSITION_EVENT:
       return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
                                       aEvent->AsTransitionEvent());
     case NS_ANIMATION_EVENT:
       return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
-               static_cast<InternalAnimationEvent*>(aEvent));
+                                     aEvent->AsAnimationEvent());
     default:
       // For all other types of events, create a vanilla event object.
       return NS_NewDOMEvent(aDOMEvent, aOwner, aPresContext, aEvent);
     }
   }
 
   // And if we didn't get an event, check the type argument.