Bug 920377 part.14 Get rid of nsSimpleGestureEvent r=roc

This commit is contained in:
Masayuki Nakano 2013-09-27 15:20:57 +09:00
Родитель d3aa0d67cf
Коммит 79047aba97
15 изменённых файлов: 70 добавлений и 61 удалений

Просмотреть файл

@ -704,10 +704,10 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_SIMPLE_GESTURE_EVENT:
{
nsSimpleGestureEvent* oldSimpleGestureEvent =
static_cast<nsSimpleGestureEvent*>(mEvent);
nsSimpleGestureEvent* simpleGestureEvent =
new nsSimpleGestureEvent(false, msg, nullptr, 0, 0.0);
WidgetSimpleGestureEvent* oldSimpleGestureEvent =
static_cast<WidgetSimpleGestureEvent*>(mEvent);
WidgetSimpleGestureEvent* simpleGestureEvent =
new WidgetSimpleGestureEvent(false, msg, nullptr, 0, 0.0);
simpleGestureEvent->
AssignSimpleGestureEventData(*oldSimpleGestureEvent, true);
newEvent = simpleGestureEvent;

Просмотреть файл

@ -7,11 +7,15 @@
#include "prtime.h"
#include "mozilla/TouchEvents.h"
using namespace mozilla;
nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsSimpleGestureEvent* aEvent)
WidgetSimpleGestureEvent* aEvent)
: nsDOMMouseEvent(aOwner, aPresContext,
aEvent ? aEvent : new nsSimpleGestureEvent(false, 0, nullptr, 0, 0.0))
aEvent ? aEvent :
new WidgetSimpleGestureEvent(false, 0, nullptr,
0, 0.0))
{
NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
@ -28,7 +32,7 @@ nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwn
nsDOMSimpleGestureEvent::~nsDOMSimpleGestureEvent()
{
if (mEventIsInternal) {
delete static_cast<nsSimpleGestureEvent*>(mEvent);
delete static_cast<WidgetSimpleGestureEvent*>(mEvent);
mEvent = nullptr;
}
}
@ -46,14 +50,14 @@ nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
{
NS_ENSURE_ARG_POINTER(aAllowedDirections);
*aAllowedDirections =
static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections;
static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections;
return NS_OK;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
{
static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections =
static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections =
aAllowedDirections;
return NS_OK;
}
@ -123,7 +127,8 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
aRelatedTarget);
NS_ENSURE_SUCCESS(rv, rv);
nsSimpleGestureEvent* simpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);
WidgetSimpleGestureEvent* simpleGestureEvent =
static_cast<WidgetSimpleGestureEvent*>(mEvent);
simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
simpleGestureEvent->direction = aDirectionArg;
simpleGestureEvent->delta = aDeltaArg;
@ -135,7 +140,7 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
nsresult NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsSimpleGestureEvent *aEvent)
WidgetSimpleGestureEvent* aEvent)
{
nsDOMSimpleGestureEvent* it =
new nsDOMSimpleGestureEvent(aOwner, aPresContext, aEvent);

Просмотреть файл

@ -17,7 +17,7 @@ class nsDOMSimpleGestureEvent : public nsDOMMouseEvent,
{
public:
nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext*, nsSimpleGestureEvent*);
nsPresContext*, mozilla::WidgetSimpleGestureEvent*);
virtual ~nsDOMSimpleGestureEvent();
NS_DECL_ISUPPORTS_INHERITED
@ -35,22 +35,23 @@ public:
uint32_t AllowedDirections()
{
return static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections;
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->
allowedDirections;
}
uint32_t Direction()
{
return static_cast<nsSimpleGestureEvent*>(mEvent)->direction;
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->direction;
}
double Delta()
{
return static_cast<nsSimpleGestureEvent*>(mEvent)->delta;
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->delta;
}
uint32_t ClickCount()
{
return static_cast<nsSimpleGestureEvent*>(mEvent)->clickCount;
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->clickCount;
}
void InitSimpleGestureEvent(const nsAString& aType,

Просмотреть файл

@ -738,7 +738,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
static_cast<WidgetCommandEvent*>(aEvent));
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsSimpleGestureEvent*>(aEvent));
static_cast<WidgetSimpleGestureEvent*>(aEvent));
case NS_TOUCH_EVENT:
return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetTouchEvent*>(aEvent));

Просмотреть файл

@ -1263,7 +1263,7 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
else
return NS_ERROR_FAILURE;
nsSimpleGestureEvent event(true, msg, widget, aDirection, aDelta);
WidgetSimpleGestureEvent event(true, msg, widget, aDirection, aDelta);
event.modifiers = GetWidgetModifiers(aModifiers);
event.clickCount = aClickCount;
event.time = PR_IntervalNow();

Просмотреть файл

@ -355,7 +355,7 @@ nsresult
NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsSimpleGestureEvent* aEvent);
mozilla::WidgetSimpleGestureEvent* aEvent);
nsresult
NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,

Просмотреть файл

@ -126,6 +126,5 @@ typedef WidgetWheelEvent WheelEvent;
}
typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
#endif // mozilla_EventForwards_h__

Просмотреть файл

@ -76,7 +76,7 @@ public:
{
}
WidgetSimpleGestureEvent(const nsSimpleGestureEvent& aOther) :
WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther) :
WidgetMouseEventBase(aOther.mFlags.mIsTrusted,
aOther.message, aOther.widget,
NS_SIMPLE_GESTURE_EVENT),
@ -153,6 +153,5 @@ public:
// TODO: Remove following typedefs
typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
#endif // mozilla_TouchEvents_h__

Просмотреть файл

@ -1303,7 +1303,7 @@ void
nsWindow::DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
const nsIntPoint &refPoint, uint64_t time)
{
nsSimpleGestureEvent event(true, msg, this, direction, delta);
WidgetSimpleGestureEvent event(true, msg, this, direction, delta);
event.modifiers = 0;
event.time = time;

Просмотреть файл

@ -3843,7 +3843,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
float deltaY = [anEvent deltaY]; // up=1.0, down=-1.0
// Setup the "swipe" event.
nsSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_SWIPE, mGeckoChild, 0, 0.0);
WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_SWIPE,
mGeckoChild, 0, 0.0);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
// Record the left/right direction.
@ -3912,7 +3913,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
}
// Setup the event.
nsSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, deltaZ);
WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, deltaZ);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
// Send the event.
@ -3935,8 +3936,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
nsAutoRetainCocoaObject kungFuDeathGrip(self);
// Setup the "double tap" event.
nsSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_TAP,
mGeckoChild, 0, 0.0);
WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_TAP,
mGeckoChild, 0, 0.0);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
geckoEvent.clickCount = 1;
@ -3978,7 +3979,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
}
// Setup the event.
nsSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, 0.0);
WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, 0.0);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
geckoEvent.delta = -rotation;
if (rotation > 0.0) {
@ -4014,8 +4015,9 @@ NSEvent* gLastDragMouseDownEvent = nil;
case eGestureState_MagnifyGesture:
{
// Setup the "magnify" event.
nsSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_MAGNIFY,
mGeckoChild, 0, mCumulativeMagnification);
WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_MAGNIFY,
mGeckoChild, 0,
mCumulativeMagnification);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
// Send the event.
@ -4026,7 +4028,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
case eGestureState_RotateGesture:
{
// Setup the "rotate" event.
nsSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_ROTATE, mGeckoChild, 0, 0.0);
WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_ROTATE,
mGeckoChild, 0, 0.0);
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
geckoEvent.delta = -mCumulativeRotation;
if (mCumulativeRotation > 0.0) {
@ -4080,7 +4083,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (!mGeckoChild)
return false;
nsSimpleGestureEvent geckoEvent(true, aMsg, mGeckoChild, aDirection, aDelta);
WidgetSimpleGestureEvent geckoEvent(true, aMsg, mGeckoChild,
aDirection, aDelta);
geckoEvent.allowedDirections = *aAllowedDirections;
[self convertCocoaMouseEvent:aEvent toGeckoEvent:&geckoEvent];
bool eventCancelled = mGeckoChild->DispatchWindowEvent(geckoEvent);

Просмотреть файл

@ -2077,7 +2077,7 @@ nsEventStatus
nsWindow::DispatchGestureEvent(uint32_t aMsg, uint32_t aDirection,
double aDelta, const nsIntPoint& aRefPoint)
{
nsSimpleGestureEvent mozGesture(true, aMsg, this, 0, 0.0);
WidgetSimpleGestureEvent mozGesture(true, aMsg, this, 0, 0.0);
mozGesture.direction = aDirection;
mozGesture.delta = aDelta;
mozGesture.refPoint = LayoutDeviceIntPoint::FromUntyped(aRefPoint);

Просмотреть файл

@ -297,7 +297,8 @@ bool nsWinGesture::IsPanEvent(LPARAM lParam)
/* Gesture event processing */
bool
nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsSimpleGestureEvent& evt)
nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam,
WidgetSimpleGestureEvent& evt)
{
GESTUREINFO gi;

Просмотреть файл

@ -207,7 +207,7 @@ public:
bool IsAvailable();
// Simple gesture process
bool ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsSimpleGestureEvent& evt);
bool ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, mozilla::WidgetSimpleGestureEvent& evt);
// Pan processing
bool IsPanEvent(LPARAM lParam);

Просмотреть файл

@ -6211,7 +6211,7 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam)
}
// Other gestures translate into simple gesture events:
nsSimpleGestureEvent event(true, 0, this, 0, 0.0);
WidgetSimpleGestureEvent event(true, 0, this, 0, 0.0);
if ( !mGesture.ProcessGestureMessage(mWnd, wParam, lParam, event) ) {
return false; // fall through to DefWndProc
}

Просмотреть файл

@ -255,11 +255,11 @@ MetroInput::OnEdgeGestureStarted(UI::Input::IEdgeGesture* sender,
#ifdef DEBUG_INPUT
LogFunction();
#endif
nsSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_STARTED,
mWidget.Get(),
0,
0.0);
WidgetSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_STARTED,
mWidget.Get(),
0,
0.0);
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(geckoEvent);
geckoEvent.time = ::GetMessageTime();
@ -287,11 +287,11 @@ MetroInput::OnEdgeGestureCanceled(UI::Input::IEdgeGesture* sender,
#ifdef DEBUG_INPUT
LogFunction();
#endif
nsSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_CANCELED,
mWidget.Get(),
0,
0.0);
WidgetSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_CANCELED,
mWidget.Get(),
0,
0.0);
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(geckoEvent);
geckoEvent.time = ::GetMessageTime();
@ -318,11 +318,11 @@ MetroInput::OnEdgeGestureCompleted(UI::Input::IEdgeGesture* sender,
#ifdef DEBUG_INPUT
LogFunction();
#endif
nsSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_COMPLETED,
mWidget.Get(),
0,
0.0);
WidgetSimpleGestureEvent geckoEvent(true,
NS_SIMPLE_GESTURE_EDGE_COMPLETED,
mWidget.Get(),
0,
0.0);
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(geckoEvent);
geckoEvent.time = ::GetMessageTime();
@ -821,8 +821,8 @@ MetroInput::ProcessManipulationDelta(
}
// Send a gecko event indicating the magnification since the last update.
nsSimpleGestureEvent* magEvent =
new nsSimpleGestureEvent(true, aMagEventType, mWidget.Get(), 0, 0.0);
WidgetSimpleGestureEvent* magEvent =
new WidgetSimpleGestureEvent(true, aMagEventType, mWidget.Get(), 0, 0.0);
magEvent->delta = aDelta.Expansion;
magEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
@ -830,8 +830,8 @@ MetroInput::ProcessManipulationDelta(
DispatchAsyncEventIgnoreStatus(magEvent);
// Send a gecko event indicating the rotation since the last update.
nsSimpleGestureEvent* rotEvent =
new nsSimpleGestureEvent(true, aRotEventType, mWidget.Get(), 0, 0.0);
WidgetSimpleGestureEvent* rotEvent =
new WidgetSimpleGestureEvent(true, aRotEventType, mWidget.Get(), 0, 0.0);
rotEvent->delta = aDelta.Rotation;
rotEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
@ -961,9 +961,9 @@ MetroInput::OnManipulationCompleted(
}
if (isHorizontalSwipe) {
nsSimpleGestureEvent* swipeEvent =
new nsSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
mWidget.Get(), 0, 0.0);
WidgetSimpleGestureEvent* swipeEvent =
new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
mWidget.Get(), 0, 0.0);
swipeEvent->direction = delta.Translation.X > 0
? nsIDOMSimpleGestureEvent::DIRECTION_RIGHT
: nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
@ -974,9 +974,9 @@ MetroInput::OnManipulationCompleted(
}
if (isVerticalSwipe) {
nsSimpleGestureEvent* swipeEvent =
new nsSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
mWidget.Get(), 0, 0.0);
WidgetSimpleGestureEvent* swipeEvent =
new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
mWidget.Get(), 0, 0.0);
swipeEvent->direction = delta.Translation.Y > 0
? nsIDOMSimpleGestureEvent::DIRECTION_DOWN
: nsIDOMSimpleGestureEvent::DIRECTION_UP;