Bug 920425 part.16 Use mozilla::WidgetEvent::AsSimpleGestureEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:23 +0900
changeset 151312 8cdc23bb6bc4b818d69744d4fa0e2a2e6855010c
parent 151311 3b3805db4d2c207f2f8019a6ac90afa9b1368f84
child 151313 ea4c8fcc6d8f7eabac4a408f3ecd8be2a2143127
push id25484
push userryanvm@gmail.com
push dateFri, 18 Oct 2013 19:14:25 +0000
treeherdermozilla-central@3daff401c7ab [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.16 Use mozilla::WidgetEvent::AsSimpleGestureEvent() r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMSimpleGestureEvent.cpp
content/events/src/nsDOMSimpleGestureEvent.h
content/events/src/nsEventDispatcher.cpp
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -693,17 +693,17 @@ nsDOMEvent::DuplicatePrivateData()
       uiEvent->eventStructType = NS_SMIL_TIME_EVENT;
       uiEvent->AssignUIEventData(*oldUIEvent, true);
       newEvent = uiEvent;
       break;
     }
     case NS_SIMPLE_GESTURE_EVENT:
     {
       WidgetSimpleGestureEvent* oldSimpleGestureEvent =
-        static_cast<WidgetSimpleGestureEvent*>(mEvent);
+        mEvent->AsSimpleGestureEvent();
       WidgetSimpleGestureEvent* simpleGestureEvent = 
         new WidgetSimpleGestureEvent(false, msg, nullptr, 0, 0.0);
       simpleGestureEvent->
         AssignSimpleGestureEventData(*oldSimpleGestureEvent, true);
       newEvent = simpleGestureEvent;
       break;
     }
     case NS_TRANSITION_EVENT:
--- a/content/events/src/nsDOMSimpleGestureEvent.cpp
+++ b/content/events/src/nsDOMSimpleGestureEvent.cpp
@@ -33,52 +33,74 @@ nsDOMSimpleGestureEvent::nsDOMSimpleGest
 NS_IMPL_ADDREF_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
 
 /* attribute unsigned long allowedDirections; */
+uint32_t
+nsDOMSimpleGestureEvent::AllowedDirections()
+{
+  return mEvent->AsSimpleGestureEvent()->allowedDirections;
+}
+
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
 {
   NS_ENSURE_ARG_POINTER(aAllowedDirections);
-  *aAllowedDirections =
-    static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections;
+  *aAllowedDirections = AllowedDirections();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
 {
-  static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections =
-    aAllowedDirections;
+  mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
   return NS_OK;
 }
 
 /* readonly attribute unsigned long direction; */
+uint32_t
+nsDOMSimpleGestureEvent::Direction()
+{
+  return mEvent->AsSimpleGestureEvent()->direction;
+}
+
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
 {
   NS_ENSURE_ARG_POINTER(aDirection);
   *aDirection = Direction();
   return NS_OK;
 }
 
 /* readonly attribute float delta; */
+double
+nsDOMSimpleGestureEvent::Delta()
+{
+  return mEvent->AsSimpleGestureEvent()->delta;
+}
+
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
 {
   NS_ENSURE_ARG_POINTER(aDelta);
   *aDelta = Delta();
   return NS_OK;
 }
 
 /* readonly attribute unsigned long clickCount; */
+uint32_t
+nsDOMSimpleGestureEvent::ClickCount()
+{
+  return mEvent->AsSimpleGestureEvent()->clickCount;
+}
+
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount)
 {
   NS_ENSURE_ARG_POINTER(aClickCount);
   *aClickCount = ClickCount();
   return NS_OK;
 }
 
@@ -115,18 +137,17 @@ nsDOMSimpleGestureEvent::InitSimpleGestu
                                                 aCtrlKeyArg,
                                                 aAltKeyArg,
                                                 aShiftKeyArg,
                                                 aMetaKeyArg,
                                                 aButton,
                                                 aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  WidgetSimpleGestureEvent* simpleGestureEvent =
-    static_cast<WidgetSimpleGestureEvent*>(mEvent);
+  WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
   simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
   simpleGestureEvent->direction = aDirectionArg;
   simpleGestureEvent->delta = aDeltaArg;
   simpleGestureEvent->clickCount = aClickCountArg;
 
   return NS_OK;
 }
 
--- a/content/events/src/nsDOMSimpleGestureEvent.h
+++ b/content/events/src/nsDOMSimpleGestureEvent.h
@@ -2,17 +2,17 @@
  * 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 nsDOMSimpleGestureEvent_h__
 #define nsDOMSimpleGestureEvent_h__
 
 #include "nsIDOMSimpleGestureEvent.h"
 #include "nsDOMMouseEvent.h"
-#include "mozilla/TouchEvents.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/dom/SimpleGestureEventBinding.h"
 
 class nsPresContext;
 
 class nsDOMSimpleGestureEvent : public nsDOMMouseEvent,
                                 public nsIDOMSimpleGestureEvent
 {
 public:
@@ -27,36 +27,20 @@ public:
   NS_FORWARD_TO_NSDOMMOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
 			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this);
   }
 
-  uint32_t AllowedDirections()
-  {
-    return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->
-             allowedDirections;
-  }
-
-  uint32_t Direction()
-  {
-    return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->direction;
-  }
-
-  double Delta()
-  {
-    return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->delta;
-  }
-
-  uint32_t ClickCount()
-  {
-    return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->clickCount;
-  }
+  uint32_t AllowedDirections();
+  uint32_t Direction();
+  double Delta();
+  uint32_t ClickCount();
 
   void InitSimpleGestureEvent(const nsAString& aType,
                               bool aCanBubble,
                               bool aCancelable,
                               nsIDOMWindow* aView,
                               int32_t aDetail,
                               int32_t aScreenX,
                               int32_t aScreenY,
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -735,17 +735,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_SMIL_TIME_EVENT:
       return NS_NewDOMTimeEvent(aDOMEvent, aOwner, aPresContext, aEvent);
 
     case NS_COMMAND_EVENT:
       return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
                                    aEvent->AsCommandEvent());
     case NS_SIMPLE_GESTURE_EVENT:
       return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
-               static_cast<WidgetSimpleGestureEvent*>(aEvent));
+                                         aEvent->AsSimpleGestureEvent());
     case NS_TOUCH_EVENT:
       return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
                                  aEvent->AsTouchEvent());
     case NS_TRANSITION_EVENT:
       return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
                                       aEvent->AsTransitionEvent());
     case NS_ANIMATION_EVENT:
       return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,