Bug 920425 part.30 Use mozilla::WidgetEvent::AsWheelEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 22 Oct 2013 17:55:21 +0900
changeset 166411 0dc6eccf8c776a4905ca9ffcb6bf1282f2b1b633
parent 166410 cd05abee0fcaec29f693f274982778945f09ffa8
child 166412 ececa191d8b5c87f8862d23916b5dc7cb24335e5
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.30 Use mozilla::WidgetEvent::AsWheelEvent() r=smaug
content/events/src/DOMWheelEvent.cpp
content/events/src/DOMWheelEvent.h
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventStateManager.cpp
layout/base/nsPresShell.cpp
--- a/content/events/src/DOMWheelEvent.cpp
+++ b/content/events/src/DOMWheelEvent.cpp
@@ -19,18 +19,17 @@ DOMWheelEvent::DOMWheelEvent(EventTarget
                                   new WidgetWheelEvent(false, 0, nullptr))
 {
   if (aWheelEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
-    static_cast<WidgetWheelEvent*>(mEvent)->inputSource =
-      nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    mEvent->AsWheelEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
 NS_IMPL_ADDREF_INHERITED(DOMWheelEvent, nsDOMMouseEvent)
 NS_IMPL_RELEASE_INHERITED(DOMWheelEvent, nsDOMMouseEvent)
 
 NS_INTERFACE_MAP_BEGIN(DOMWheelEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWheelEvent)
@@ -56,52 +55,76 @@ DOMWheelEvent::InitWheelEvent(const nsAS
 {
   nsresult rv =
     nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView,
                                     aDetail, aScreenX, aScreenY,
                                     aClientX, aClientY, aButton,
                                     aRelatedTarget, aModifiersList);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  WidgetWheelEvent* wheelEvent = static_cast<WidgetWheelEvent*>(mEvent);
+  WidgetWheelEvent* wheelEvent = mEvent->AsWheelEvent();
   wheelEvent->deltaX = aDeltaX;
   wheelEvent->deltaY = aDeltaY;
   wheelEvent->deltaZ = aDeltaZ;
   wheelEvent->deltaMode = aDeltaMode;
 
   return NS_OK;
 }
 
+double
+DOMWheelEvent::DeltaX()
+{
+  return mEvent->AsWheelEvent()->deltaX;
+}
+
 NS_IMETHODIMP
 DOMWheelEvent::GetDeltaX(double* aDeltaX)
 {
   NS_ENSURE_ARG_POINTER(aDeltaX);
 
   *aDeltaX = DeltaX();
   return NS_OK;
 }
 
+double
+DOMWheelEvent::DeltaY()
+{
+  return mEvent->AsWheelEvent()->deltaY;
+}
+
 NS_IMETHODIMP
 DOMWheelEvent::GetDeltaY(double* aDeltaY)
 {
   NS_ENSURE_ARG_POINTER(aDeltaY);
 
   *aDeltaY = DeltaY();
   return NS_OK;
 }
 
+double
+DOMWheelEvent::DeltaZ()
+{
+  return mEvent->AsWheelEvent()->deltaZ;
+}
+
 NS_IMETHODIMP
 DOMWheelEvent::GetDeltaZ(double* aDeltaZ)
 {
   NS_ENSURE_ARG_POINTER(aDeltaZ);
 
   *aDeltaZ = DeltaZ();
   return NS_OK;
 }
 
+uint32_t
+DOMWheelEvent::DeltaMode()
+{
+  return mEvent->AsWheelEvent()->deltaMode;
+}
+
 NS_IMETHODIMP
 DOMWheelEvent::GetDeltaMode(uint32_t* aDeltaMode)
 {
   NS_ENSURE_ARG_POINTER(aDeltaMode);
 
   *aDeltaMode = DeltaMode();
   return NS_OK;
 }
@@ -148,17 +171,17 @@ DOMWheelEvent::Constructor(const GlobalO
                   modifierList);
   aRv = e->InitWheelEvent(aType, aParam.mBubbles, aParam.mCancelable,
                           aParam.mView, aParam.mDetail,
                           aParam.mScreenX, aParam.mScreenY,
                           aParam.mClientX, aParam.mClientY,
                           aParam.mButton, aParam.mRelatedTarget,
                           modifierList, aParam.mDeltaX,
                           aParam.mDeltaY, aParam.mDeltaZ, aParam.mDeltaMode);
-  static_cast<WidgetWheelEvent*>(e->mEvent)->buttons = aParam.mButtons;
+  e->mEvent->AsWheelEvent()->buttons = aParam.mButtons;
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 } // namespace dom
 } // namespace mozilla
 
 using namespace mozilla;
--- a/content/events/src/DOMWheelEvent.h
+++ b/content/events/src/DOMWheelEvent.h
@@ -4,17 +4,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 mozilla_dom_DOMWheelEvent_h__
 #define mozilla_dom_DOMWheelEvent_h__
 
 #include "nsIDOMWheelEvent.h"
 #include "nsDOMMouseEvent.h"
-#include "mozilla/MouseEvents.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/dom/WheelEventBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 class DOMWheelEvent : public nsDOMMouseEvent,
                       public nsIDOMWheelEvent
 {
@@ -38,33 +38,18 @@ public:
                                               mozilla::ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::WheelEventBinding::Wrap(aCx, aScope, this);
   }
 
-  double DeltaX()
-  {
-    return static_cast<WidgetWheelEvent*>(mEvent)->deltaX;
-  }
-
-  double DeltaY()
-  {
-    return static_cast<WidgetWheelEvent*>(mEvent)->deltaY;
-  }
-
-  double DeltaZ()
-  {
-    return static_cast<WidgetWheelEvent*>(mEvent)->deltaZ;
-  }
-
-  uint32_t DeltaMode()
-  {
-    return static_cast<WidgetWheelEvent*>(mEvent)->deltaMode;
-  }
+  double DeltaX();
+  double DeltaY();
+  double DeltaZ();
+  uint32_t DeltaMode();
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_DOMWheelEvent_h__
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -602,17 +602,17 @@ nsDOMEvent::DuplicatePrivateData()
       WidgetMouseScrollEvent* mouseScrollEvent =
         new WidgetMouseScrollEvent(false, msg, nullptr);
       mouseScrollEvent->AssignMouseScrollEventData(*oldMouseScrollEvent, true);
       newEvent = mouseScrollEvent;
       break;
     }
     case NS_WHEEL_EVENT:
     {
-      WidgetWheelEvent* oldWheelEvent = static_cast<WidgetWheelEvent*>(mEvent);
+      WidgetWheelEvent* oldWheelEvent = mEvent->AsWheelEvent();
       WidgetWheelEvent* wheelEvent = new WidgetWheelEvent(false, msg, nullptr);
       wheelEvent->AssignWheelEventData(*oldWheelEvent, true);
       newEvent = wheelEvent;
       break;
     }
     case NS_SCROLLPORT_EVENT:
     {
       InternalScrollPortEvent* oldScrollPortEvent = mEvent->AsScrollPortEvent();
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -713,17 +713,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_FOCUS_EVENT:
       return NS_NewDOMFocusEvent(aDOMEvent, aOwner, aPresContext,
                                  aEvent->AsFocusEvent());
     case NS_MOUSE_SCROLL_EVENT:
       return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext,
                                        aEvent->AsMouseScrollEvent());
     case NS_WHEEL_EVENT:
       return NS_NewDOMWheelEvent(aDOMEvent, aOwner, aPresContext,
-                                 static_cast<WidgetWheelEvent*>(aEvent));
+                                 aEvent->AsWheelEvent());
     case NS_DRAG_EVENT:
       return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
                                 aEvent->AsDragEvent());
     case NS_TEXT_EVENT:
       return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext,
                                 aEvent->AsTextEvent());
     case NS_CLIPBOARD_EVENT:
       return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1183,17 +1183,17 @@ nsEventStateManager::PreHandleEvent(nsPr
       if (content) {
         mCurrentTargetContent = content;
       }
 
       if (aEvent->message != NS_WHEEL_WHEEL) {
         break;
       }
 
-      WidgetWheelEvent* wheelEvent = static_cast<WidgetWheelEvent*>(aEvent);
+      WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
       WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(wheelEvent);
 
       // If we won't dispatch a DOM event for this event, nothing to do anymore.
       if (!wheelEvent->IsAllowedToDispatchDOMEvent()) {
         break;
       }
 
       // Init lineOrPageDelta values for line scroll events for some devices
@@ -1594,18 +1594,17 @@ nsEventStateManager::DispatchCrossProces
   switch (aEvent->eventStructType) {
   case NS_MOUSE_EVENT: {
     return remote->SendRealMouseEvent(*aEvent->AsMouseEvent());
   }
   case NS_KEY_EVENT: {
     return remote->SendRealKeyEvent(*aEvent->AsKeyboardEvent());
   }
   case NS_WHEEL_EVENT: {
-    WidgetWheelEvent* wheelEvent = static_cast<WidgetWheelEvent*>(aEvent);
-    return remote->SendMouseWheelEvent(*wheelEvent);
+    return remote->SendMouseWheelEvent(*aEvent->AsWheelEvent());
   }
   case NS_TOUCH_EVENT: {
     // Let the child process synthesize a mouse event if needed, and
     // ensure we don't synthesize one in this process.
     *aStatus = nsEventStatus_eConsumeNoDefault;
     return remote->SendRealTouchEvent(*aEvent->AsTouchEvent());
   }
   default: {
@@ -3386,17 +3385,17 @@ nsEventStateManager::PostHandleEvent(nsP
     {
       MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
 
       if (*aStatus == nsEventStatus_eConsumeNoDefault) {
         nsScrollbarsForWheel::Inactivate();
         break;
       }
 
-      WidgetWheelEvent* wheelEvent = static_cast<WidgetWheelEvent*>(aEvent);
+      WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
       switch (WheelPrefs::GetInstance()->ComputeActionFor(wheelEvent)) {
         case WheelPrefs::ACTION_SCROLL: {
           // For scrolling of default action, we should honor the mouse wheel
           // transaction.
 
           nsScrollbarsForWheel::PrepareToScrollText(this, aTargetFrame, wheelEvent);
 
           if (aEvent->message != NS_WHEEL_WHEEL ||
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -456,18 +456,18 @@ public:
         if (frame) {
           // chrome (including addons) should be able to know if content
           // handles both D3E "wheel" event and legacy mouse scroll events.
           // We should dispatch legacy mouse events before dispatching the
           // "wheel" event into system group.
           nsRefPtr<nsEventStateManager> esm =
             aVisitor.mPresContext->EventStateManager();
           esm->DispatchLegacyMouseScrollEvents(frame,
-                 static_cast<WidgetWheelEvent*>(aVisitor.mEvent),
-                 &aVisitor.mEventStatus);
+                                               aVisitor.mEvent->AsWheelEvent(),
+                                               &aVisitor.mEventStatus);
         }
       }
       nsIFrame* frame = mPresShell->GetCurrentEventFrame();
       if (!frame &&
           (aVisitor.mEvent->message == NS_MOUSE_BUTTON_UP ||
            aVisitor.mEvent->message == NS_TOUCH_END)) {
         // Redirect BUTTON_UP and TOUCH_END events to the root frame to ensure
         // that capturing is released.