From db9ba3fb1b91b618efe5ecc13a8230c381837215 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 18 Oct 2013 15:10:23 +0900 Subject: [PATCH] Bug 920425 part.16 Use mozilla::WidgetEvent::AsSimpleGestureEvent() r=smaug --- content/events/src/nsDOMEvent.cpp | 2 +- .../events/src/nsDOMSimpleGestureEvent.cpp | 33 +++++++++++++++---- content/events/src/nsDOMSimpleGestureEvent.h | 26 +++------------ content/events/src/nsEventDispatcher.cpp | 2 +- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index d9a2159b132..a5b8dd789e2 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -698,7 +698,7 @@ nsDOMEvent::DuplicatePrivateData() case NS_SIMPLE_GESTURE_EVENT: { WidgetSimpleGestureEvent* oldSimpleGestureEvent = - static_cast(mEvent); + mEvent->AsSimpleGestureEvent(); WidgetSimpleGestureEvent* simpleGestureEvent = new WidgetSimpleGestureEvent(false, msg, nullptr, 0, 0.0); simpleGestureEvent-> diff --git a/content/events/src/nsDOMSimpleGestureEvent.cpp b/content/events/src/nsDOMSimpleGestureEvent.cpp index 5232f97b14e..46c8ef48948 100644 --- a/content/events/src/nsDOMSimpleGestureEvent.cpp +++ b/content/events/src/nsDOMSimpleGestureEvent.cpp @@ -38,24 +38,34 @@ NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent) 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(mEvent)->allowedDirections; + *aAllowedDirections = AllowedDirections(); return NS_OK; } NS_IMETHODIMP nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections) { - static_cast(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) { @@ -65,6 +75,12 @@ nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection) } /* readonly attribute float delta; */ +double +nsDOMSimpleGestureEvent::Delta() +{ + return mEvent->AsSimpleGestureEvent()->delta; +} + NS_IMETHODIMP nsDOMSimpleGestureEvent::GetDelta(double *aDelta) { @@ -74,6 +90,12 @@ nsDOMSimpleGestureEvent::GetDelta(double *aDelta) } /* readonly attribute unsigned long clickCount; */ +uint32_t +nsDOMSimpleGestureEvent::ClickCount() +{ + return mEvent->AsSimpleGestureEvent()->clickCount; +} + NS_IMETHODIMP nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount) { @@ -120,8 +142,7 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg, aRelatedTarget); NS_ENSURE_SUCCESS(rv, rv); - WidgetSimpleGestureEvent* simpleGestureEvent = - static_cast(mEvent); + WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent(); simpleGestureEvent->allowedDirections = aAllowedDirectionsArg; simpleGestureEvent->direction = aDirectionArg; simpleGestureEvent->delta = aDeltaArg; diff --git a/content/events/src/nsDOMSimpleGestureEvent.h b/content/events/src/nsDOMSimpleGestureEvent.h index a6c18012e21..e67c6b25f0f 100644 --- a/content/events/src/nsDOMSimpleGestureEvent.h +++ b/content/events/src/nsDOMSimpleGestureEvent.h @@ -7,7 +7,7 @@ #include "nsIDOMSimpleGestureEvent.h" #include "nsDOMMouseEvent.h" -#include "mozilla/TouchEvents.h" +#include "mozilla/EventForwards.h" #include "mozilla/dom/SimpleGestureEventBinding.h" class nsPresContext; @@ -32,26 +32,10 @@ public: return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this); } - uint32_t AllowedDirections() - { - return static_cast(mEvent)-> - allowedDirections; - } - - uint32_t Direction() - { - return static_cast(mEvent)->direction; - } - - double Delta() - { - return static_cast(mEvent)->delta; - } - - uint32_t ClickCount() - { - return static_cast(mEvent)->clickCount; - } + uint32_t AllowedDirections(); + uint32_t Direction(); + double Delta(); + uint32_t ClickCount(); void InitSimpleGestureEvent(const nsAString& aType, bool aCanBubble, diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index 9d73e9416d5..d06cd75c2b4 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -740,7 +740,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner, aEvent->AsCommandEvent()); case NS_SIMPLE_GESTURE_EVENT: return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + aEvent->AsSimpleGestureEvent()); case NS_TOUCH_EVENT: return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext, aEvent->AsTouchEvent());