1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_TouchEvents_h__
7 #define mozilla_TouchEvents_h__
11 #include "mozilla/dom/Touch.h"
12 #include "mozilla/MouseEvents.h"
13 #include "nsAutoPtr.h"
14 #include "nsIDOMSimpleGestureEvent.h"
19 /******************************************************************************
20 * mozilla::WidgetGestureNotifyEvent
22 * This event is the first event generated when the user touches
23 * the screen with a finger, and it's meant to decide what kind
24 * of action we'll use for that touch interaction.
26 * The event is dispatched to the layout and based on what is underneath
27 * the initial contact point it's then decided if we should pan
28 * (finger scrolling) or drag the target element.
29 ******************************************************************************/
31 class WidgetGestureNotifyEvent
: public WidgetGUIEvent
34 virtual WidgetGestureNotifyEvent
* AsGestureNotifyEvent() MOZ_OVERRIDE
39 WidgetGestureNotifyEvent(bool aIsTrusted
, uint32_t aMessage
,
41 WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, NS_GESTURENOTIFY_EVENT
),
42 panDirection(ePanNone
), displayPanFeedback(false)
54 ePanDirection panDirection
;
55 bool displayPanFeedback
;
57 // XXX Not tested by test_assign_event_data.html
58 void AssignGestureNotifyEventData(const WidgetGestureNotifyEvent
& aEvent
,
61 AssignGUIEventData(aEvent
, aCopyTargets
);
63 panDirection
= aEvent
.panDirection
;
64 displayPanFeedback
= aEvent
.displayPanFeedback
;
68 /******************************************************************************
69 * mozilla::WidgetTouchEvent
70 ******************************************************************************/
72 class WidgetSimpleGestureEvent
: public WidgetMouseEventBase
75 virtual WidgetSimpleGestureEvent
* AsSimpleGestureEvent() MOZ_OVERRIDE
80 WidgetSimpleGestureEvent(bool aIsTrusted
, uint32_t aMessage
,
81 nsIWidget
* aWidget
, uint32_t aDirection
,
83 WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
84 NS_SIMPLE_GESTURE_EVENT
),
85 allowedDirections(0), direction(aDirection
), delta(aDelta
), clickCount(0)
89 WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent
& aOther
) :
90 WidgetMouseEventBase(aOther
.mFlags
.mIsTrusted
,
91 aOther
.message
, aOther
.widget
,
92 NS_SIMPLE_GESTURE_EVENT
),
93 allowedDirections(aOther
.allowedDirections
), direction(aOther
.direction
),
94 delta(aOther
.delta
), clickCount(0)
98 // See nsIDOMSimpleGestureEvent for values
99 uint32_t allowedDirections
;
100 // See nsIDOMSimpleGestureEvent for values
102 // Delta for magnify and rotate events
104 // The number of taps for tap events
107 // XXX Not tested by test_assign_event_data.html
108 void AssignSimpleGestureEventData(const WidgetSimpleGestureEvent
& aEvent
,
111 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
113 // allowedDirections isn't copied
114 direction
= aEvent
.direction
;
115 delta
= aEvent
.delta
;
116 clickCount
= aEvent
.clickCount
;
120 /******************************************************************************
121 * mozilla::WidgetTouchEvent
122 ******************************************************************************/
124 class WidgetTouchEvent
: public WidgetInputEvent
127 virtual WidgetTouchEvent
* AsTouchEvent() MOZ_OVERRIDE
{ return this; }
133 WidgetTouchEvent(const WidgetTouchEvent
& aOther
) :
134 WidgetInputEvent(aOther
.mFlags
.mIsTrusted
, aOther
.message
, aOther
.widget
,
137 modifiers
= aOther
.modifiers
;
139 touches
.AppendElements(aOther
.touches
);
140 MOZ_COUNT_CTOR(WidgetTouchEvent
);
143 WidgetTouchEvent(bool aIsTrusted
, WidgetTouchEvent
* aEvent
) :
144 WidgetInputEvent(aIsTrusted
, aEvent
->message
, aEvent
->widget
,
147 modifiers
= aEvent
->modifiers
;
149 touches
.AppendElements(aEvent
->touches
);
150 MOZ_COUNT_CTOR(WidgetTouchEvent
);
153 WidgetTouchEvent(bool aIsTrusted
, uint32_t aMessage
, nsIWidget
* aWidget
) :
154 WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, NS_TOUCH_EVENT
)
156 MOZ_COUNT_CTOR(WidgetTouchEvent
);
159 virtual ~WidgetTouchEvent()
161 MOZ_COUNT_DTOR(WidgetTouchEvent
);
164 nsTArray
<nsRefPtr
<mozilla::dom::Touch
>> touches
;
166 void AssignTouchEventData(const WidgetTouchEvent
& aEvent
, bool aCopyTargets
)
168 AssignInputEventData(aEvent
, aCopyTargets
);
170 // Currently, we don't need to copy touches.
174 } // namespace mozilla
176 #endif // mozilla_TouchEvents_h__