Bug 920425 part.30 Use mozilla::WidgetEvent::AsWheelEvent() r=smaug

This commit is contained in:
Masayuki Nakano 2013-10-22 17:55:21 +09:00
parent 9eb7021e62
commit 415c4b7638
6 changed files with 39 additions and 32 deletions

View File

@ -24,8 +24,7 @@ DOMWheelEvent::DOMWheelEvent(EventTarget* aOwner,
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;
}
}
@ -61,7 +60,7 @@ DOMWheelEvent::InitWheelEvent(const nsAString & aType,
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;
@ -70,6 +69,12 @@ DOMWheelEvent::InitWheelEvent(const nsAString & aType,
return NS_OK;
}
double
DOMWheelEvent::DeltaX()
{
return mEvent->AsWheelEvent()->deltaX;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaX(double* aDeltaX)
{
@ -79,6 +84,12 @@ DOMWheelEvent::GetDeltaX(double* aDeltaX)
return NS_OK;
}
double
DOMWheelEvent::DeltaY()
{
return mEvent->AsWheelEvent()->deltaY;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaY(double* aDeltaY)
{
@ -88,6 +99,12 @@ DOMWheelEvent::GetDeltaY(double* aDeltaY)
return NS_OK;
}
double
DOMWheelEvent::DeltaZ()
{
return mEvent->AsWheelEvent()->deltaZ;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaZ(double* aDeltaZ)
{
@ -97,6 +114,12 @@ DOMWheelEvent::GetDeltaZ(double* aDeltaZ)
return NS_OK;
}
uint32_t
DOMWheelEvent::DeltaMode()
{
return mEvent->AsWheelEvent()->deltaMode;
}
NS_IMETHODIMP
DOMWheelEvent::GetDeltaMode(uint32_t* aDeltaMode)
{
@ -153,7 +176,7 @@ DOMWheelEvent::Constructor(const GlobalObject& aGlobal,
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();
}

View File

@ -9,7 +9,7 @@
#include "nsIDOMWheelEvent.h"
#include "nsDOMMouseEvent.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/WheelEventBinding.h"
namespace mozilla {
@ -43,25 +43,10 @@ public:
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

View File

@ -607,7 +607,7 @@ nsDOMEvent::DuplicatePrivateData()
}
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;

View File

@ -718,7 +718,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
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());

View File

@ -1188,7 +1188,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
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.
@ -1599,8 +1599,7 @@ nsEventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
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
@ -3391,7 +3390,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
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

View File

@ -461,8 +461,8 @@ public:
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();