Line data Source code
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/. */
5 :
6 : #ifndef InputData_h__
7 : #define InputData_h__
8 :
9 : #include "nsDebug.h"
10 : #include "nsIDOMWheelEvent.h"
11 : #include "nsIScrollableFrame.h"
12 : #include "nsPoint.h"
13 : #include "nsTArray.h"
14 : #include "Units.h"
15 : #include "mozilla/DefineEnum.h"
16 : #include "mozilla/EventForwards.h"
17 : #include "mozilla/TimeStamp.h"
18 : #include "mozilla/gfx/MatrixFwd.h"
19 : #include "mozilla/layers/KeyboardScrollAction.h"
20 :
21 : template<class E> struct already_AddRefed;
22 : class nsIWidget;
23 :
24 : namespace mozilla {
25 :
26 : namespace layers {
27 : class PAPZCTreeManagerParent;
28 : class APZCTreeManagerChild;
29 : }
30 :
31 : namespace dom {
32 : class Touch;
33 : } // namespace dom
34 :
35 : MOZ_DEFINE_ENUM(
36 : InputType, (
37 : MULTITOUCH_INPUT,
38 : MOUSE_INPUT,
39 : PANGESTURE_INPUT,
40 : PINCHGESTURE_INPUT,
41 : TAPGESTURE_INPUT,
42 : SCROLLWHEEL_INPUT,
43 : KEYBOARD_INPUT
44 : ));
45 :
46 : class MultiTouchInput;
47 : class MouseInput;
48 : class PanGestureInput;
49 : class PinchGestureInput;
50 : class TapGestureInput;
51 : class ScrollWheelInput;
52 : class KeyboardInput;
53 :
54 : // This looks unnecessary now, but as we add more and more classes that derive
55 : // from InputType (eventually probably almost as many as *Events.h has), it
56 : // will be more and more clear what's going on with a macro that shortens the
57 : // definition of the RTTI functions.
58 : #define INPUTDATA_AS_CHILD_TYPE(type, enumID) \
59 : const type& As##type() const \
60 : { \
61 : MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
62 : return (const type&) *this; \
63 : } \
64 : type& As##type() \
65 : { \
66 : MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
67 : return (type&) *this; \
68 : }
69 :
70 : /** Base input data class. Should never be instantiated. */
71 0 : class InputData
72 : {
73 : public:
74 : // Warning, this class is serialized and sent over IPC. Any change to its
75 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
76 : InputType mInputType;
77 : // Time in milliseconds that this data is relevant to. This only really
78 : // matters when this data is used as an event. We use uint32_t instead of
79 : // TimeStamp because it is easier to convert from WidgetInputEvent. The time
80 : // is platform-specific but it in the case of B2G and Fennec it is since
81 : // startup.
82 : uint32_t mTime;
83 : // Set in parallel to mTime until we determine it is safe to drop
84 : // platform-specific event times (see bug 77992).
85 : TimeStamp mTimeStamp;
86 : // The sequence number of the last potentially focus changing event handled
87 : // by APZ. This is used to track when that event has been processed by content,
88 : // and focus can be reconfirmed for async keyboard scrolling.
89 : uint64_t mFocusSequenceNumber;
90 :
91 : Modifiers modifiers;
92 :
93 0 : INPUTDATA_AS_CHILD_TYPE(MultiTouchInput, MULTITOUCH_INPUT)
94 8 : INPUTDATA_AS_CHILD_TYPE(MouseInput, MOUSE_INPUT)
95 0 : INPUTDATA_AS_CHILD_TYPE(PanGestureInput, PANGESTURE_INPUT)
96 0 : INPUTDATA_AS_CHILD_TYPE(PinchGestureInput, PINCHGESTURE_INPUT)
97 0 : INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
98 0 : INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput, SCROLLWHEEL_INPUT)
99 0 : INPUTDATA_AS_CHILD_TYPE(KeyboardInput, KEYBOARD_INPUT)
100 :
101 : virtual ~InputData();
102 : explicit InputData(InputType aInputType);
103 :
104 : protected:
105 : InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp,
106 : Modifiers aModifiers);
107 : };
108 :
109 : /**
110 : * Data container for a single touch input. Similar to dom::Touch, but used in
111 : * off-main-thread situations. This is more for just storing touch data, whereas
112 : * dom::Touch is more useful for dispatching through the DOM (which can only
113 : * happen on the main thread). dom::Touch also bears the problem of storing
114 : * pointers to nsIWidget instances which can only be used on the main thread,
115 : * so if instead we used dom::Touch and ever set these pointers
116 : * off-main-thread, Bad Things Can Happen(tm).
117 : *
118 : * Note that this doesn't inherit from InputData because this itself is not an
119 : * event. It is only a container/struct that should have any number of instances
120 : * within a MultiTouchInput.
121 : *
122 : * fixme/bug 775746: Make dom::Touch inherit from this class.
123 : */
124 : class SingleTouchData
125 : {
126 : public:
127 : // Construct a SingleTouchData from a Screen point.
128 : // mLocalScreenPoint remains (0,0) unless it's set later.
129 : SingleTouchData(int32_t aIdentifier,
130 : ScreenIntPoint aScreenPoint,
131 : ScreenSize aRadius,
132 : float aRotationAngle,
133 : float aForce);
134 :
135 : // Construct a SingleTouchData from a ParentLayer point.
136 : // mScreenPoint remains (0,0) unless it's set later.
137 : // Note: if APZ starts using the radius for anything, we should add a local
138 : // version of that too, and have this constructor take it as a ParentLayerSize.
139 : SingleTouchData(int32_t aIdentifier,
140 : ParentLayerPoint aLocalScreenPoint,
141 : ScreenSize aRadius,
142 : float aRotationAngle,
143 : float aForce);
144 :
145 : SingleTouchData();
146 :
147 : already_AddRefed<dom::Touch> ToNewDOMTouch() const;
148 :
149 : // Warning, this class is serialized and sent over IPC. Any change to its
150 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
151 :
152 : // A unique number assigned to each SingleTouchData within a MultiTouchInput so
153 : // that they can be easily distinguished when handling a touch start/move/end.
154 : int32_t mIdentifier;
155 :
156 : // Point on the screen that the touch hit, in device pixels. They are
157 : // coordinates on the screen.
158 : ScreenIntPoint mScreenPoint;
159 :
160 : // |mScreenPoint| transformed to the local coordinates of the APZC targeted
161 : // by the hit. This is set and used by APZ.
162 : ParentLayerPoint mLocalScreenPoint;
163 :
164 : // Radius that the touch covers, i.e. if you're using your thumb it will
165 : // probably be larger than using your pinky, even with the same force.
166 : // Radius can be different along x and y. For example, if you press down with
167 : // your entire finger vertically, the y radius will be much larger than the x
168 : // radius.
169 : ScreenSize mRadius;
170 :
171 : float mRotationAngle;
172 :
173 : // How hard the screen is being pressed.
174 : float mForce;
175 : };
176 :
177 : /**
178 : * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
179 : * screen touch point instead of the many different coordinate spaces
180 : * WidgetTouchEvent stores its touch point in. This includes a way to initialize
181 : * itself from a WidgetTouchEvent by copying all relevant data over. Note that
182 : * this copying from WidgetTouchEvent functionality can only be used on the main
183 : * thread.
184 : *
185 : * Stores an array of SingleTouchData.
186 : */
187 0 : class MultiTouchInput : public InputData
188 : {
189 : public:
190 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
191 : MultiTouchType, (
192 : MULTITOUCH_START,
193 : MULTITOUCH_MOVE,
194 : MULTITOUCH_END,
195 : MULTITOUCH_CANCEL
196 : ));
197 :
198 : MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
199 : Modifiers aModifiers);
200 : MultiTouchInput();
201 : MultiTouchInput(const MultiTouchInput& aOther);
202 : explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
203 : // This conversion from WidgetMouseEvent to MultiTouchInput is needed because
204 : // on the B2G emulator we can only receive mouse events, but we need to be
205 : // able to pan correctly. To do this, we convert the events into a format that
206 : // the panning code can handle. This code is very limited and only supports
207 : // SingleTouchData. It also sends garbage for the identifier, radius, force
208 : // and rotation angle.
209 : explicit MultiTouchInput(const WidgetMouseEvent& aMouseEvent);
210 : void Translate(const ScreenPoint& aTranslation);
211 :
212 : WidgetTouchEvent ToWidgetTouchEvent(nsIWidget* aWidget) const;
213 : WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
214 :
215 : // Return the index into mTouches of the SingleTouchData with the given
216 : // identifier, or -1 if there is no such SingleTouchData.
217 : int32_t IndexOfTouch(int32_t aTouchIdentifier);
218 :
219 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
220 :
221 : // Warning, this class is serialized and sent over IPC. Any change to its
222 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
223 : MultiTouchType mType;
224 : nsTArray<SingleTouchData> mTouches;
225 : bool mHandledByAPZ;
226 : };
227 :
228 4 : class MouseInput : public InputData
229 : {
230 : protected:
231 : friend mozilla::layers::PAPZCTreeManagerParent;
232 : friend mozilla::layers::APZCTreeManagerChild;
233 :
234 : MouseInput();
235 :
236 : public:
237 :
238 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
239 : MouseType, (
240 : MOUSE_NONE,
241 : MOUSE_MOVE,
242 : MOUSE_DOWN,
243 : MOUSE_UP,
244 : MOUSE_DRAG_START,
245 : MOUSE_DRAG_END,
246 : MOUSE_WIDGET_ENTER,
247 : MOUSE_WIDGET_EXIT
248 : ));
249 :
250 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
251 : ButtonType, (
252 : LEFT_BUTTON,
253 : MIDDLE_BUTTON,
254 : RIGHT_BUTTON,
255 : NONE
256 : ));
257 :
258 : MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource,
259 : int16_t aButtons, const ScreenPoint& aPoint, uint32_t aTime,
260 : TimeStamp aTimeStamp, Modifiers aModifiers);
261 : explicit MouseInput(const WidgetMouseEventBase& aMouseEvent);
262 :
263 : bool IsLeftButton() const;
264 :
265 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
266 : WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
267 :
268 : // Warning, this class is serialized and sent over IPC. Any change to its
269 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
270 : MouseType mType;
271 : ButtonType mButtonType;
272 : uint16_t mInputSource;
273 : int16_t mButtons;
274 : ScreenPoint mOrigin;
275 : ParentLayerPoint mLocalOrigin;
276 : bool mHandledByAPZ;
277 : };
278 :
279 : /**
280 : * Encapsulation class for pan events, can be used off-main-thread.
281 : * These events are currently only used for scrolling on desktop.
282 : */
283 0 : class PanGestureInput : public InputData
284 : {
285 : protected:
286 : friend mozilla::layers::PAPZCTreeManagerParent;
287 : friend mozilla::layers::APZCTreeManagerChild;
288 :
289 : PanGestureInput();
290 :
291 : public:
292 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
293 : PanGestureType, (
294 : // MayStart: Dispatched before any actual panning has occurred but when a
295 : // pan gesture is probably about to start, for example when the user
296 : // starts touching the touchpad. Should interrupt any ongoing APZ
297 : // animation and can be used to trigger scrollability indicators (e.g.
298 : // flashing overlay scrollbars).
299 : PANGESTURE_MAYSTART,
300 :
301 : // Cancelled: Dispatched after MayStart when no pan gesture is going to
302 : // happen after all, for example when the user lifts their fingers from a
303 : // touchpad without having done any scrolling.
304 : PANGESTURE_CANCELLED,
305 :
306 : // Start: A pan gesture is starting.
307 : // For devices that do not support the MayStart event type, this event can
308 : // be used to interrupt ongoing APZ animations.
309 : PANGESTURE_START,
310 :
311 : // Pan: The actual pan motion by mPanDisplacement.
312 : PANGESTURE_PAN,
313 :
314 : // End: The pan gesture has ended, for example because the user has lifted
315 : // their fingers from a touchpad after scrolling.
316 : // Any potential momentum events fire after this event.
317 : PANGESTURE_END,
318 :
319 : // The following momentum event types are used in order to control the pan
320 : // momentum animation. Using these instead of our own animation ensures
321 : // that the animation curve is OS native and that the animation stops
322 : // reliably if it is cancelled by the user.
323 :
324 : // MomentumStart: Dispatched between the End event of the actual
325 : // user-controlled pan, and the first MomentumPan event of the momentum
326 : // animation.
327 : PANGESTURE_MOMENTUMSTART,
328 :
329 : // MomentumPan: The actual momentum motion by mPanDisplacement.
330 : PANGESTURE_MOMENTUMPAN,
331 :
332 : // MomentumEnd: The momentum animation has ended, for example because the
333 : // momentum velocity has gone below the stopping threshold, or because the
334 : // user has stopped the animation by putting their fingers on a touchpad.
335 : PANGESTURE_MOMENTUMEND
336 : ));
337 :
338 : PanGestureInput(PanGestureType aType,
339 : uint32_t aTime,
340 : TimeStamp aTimeStamp,
341 : const ScreenPoint& aPanStartPoint,
342 : const ScreenPoint& aPanDisplacement,
343 : Modifiers aModifiers);
344 :
345 : bool IsMomentum() const;
346 :
347 : WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
348 :
349 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
350 :
351 : ScreenPoint UserMultipliedPanDisplacement() const;
352 : ParentLayerPoint UserMultipliedLocalPanDisplacement() const;
353 :
354 : // Warning, this class is serialized and sent over IPC. Any change to its
355 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
356 : PanGestureType mType;
357 : ScreenPoint mPanStartPoint;
358 :
359 : // The delta. This can be non-zero on any type of event.
360 : ScreenPoint mPanDisplacement;
361 :
362 : // Versions of |mPanStartPoint| and |mPanDisplacement| in the local
363 : // coordinates of the APZC receiving the pan. These are set and used by APZ.
364 : ParentLayerPoint mLocalPanStartPoint;
365 : ParentLayerPoint mLocalPanDisplacement;
366 :
367 : // See lineOrPageDeltaX/Y on WidgetWheelEvent.
368 : int32_t mLineOrPageDeltaX;
369 : int32_t mLineOrPageDeltaY;
370 :
371 : // User-set delta multipliers.
372 : double mUserDeltaMultiplierX;
373 : double mUserDeltaMultiplierY;
374 :
375 : bool mHandledByAPZ;
376 :
377 : // true if this is a PANGESTURE_END event that will be followed by a
378 : // PANGESTURE_MOMENTUMSTART event.
379 : bool mFollowedByMomentum;
380 :
381 : // If this is true, and this event started a new input block that couldn't
382 : // find a scrollable target which is scrollable in the horizontal component
383 : // of the scroll start direction, then this input block needs to be put on
384 : // hold until a content response has arrived, even if the block has a
385 : // confirmed target.
386 : // This is used by events that can result in a swipe instead of a scroll.
387 : bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection;
388 : };
389 :
390 : /**
391 : * Encapsulation class for pinch events. In general, these will be generated by
392 : * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
393 : * determining whether or not the user was trying to do a gesture.
394 : */
395 0 : class PinchGestureInput : public InputData
396 : {
397 : protected:
398 : friend mozilla::layers::PAPZCTreeManagerParent;
399 : friend mozilla::layers::APZCTreeManagerChild;
400 :
401 : PinchGestureInput();
402 :
403 : public:
404 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
405 : PinchGestureType, (
406 : PINCHGESTURE_START,
407 : PINCHGESTURE_SCALE,
408 : PINCHGESTURE_END
409 : ));
410 :
411 : // Construct a pinch gesture from a ParentLayer point.
412 : // mFocusPoint remains (0,0) unless it's set later.
413 : PinchGestureInput(PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
414 : const ParentLayerPoint& aLocalFocusPoint,
415 : ParentLayerCoord aCurrentSpan,
416 : ParentLayerCoord aPreviousSpan, Modifiers aModifiers);
417 :
418 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
419 :
420 : // Warning, this class is serialized and sent over IPC. Any change to its
421 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
422 : PinchGestureType mType;
423 :
424 : // Center point of the pinch gesture. That is, if there are two fingers on the
425 : // screen, it is their midpoint. In the case of more than two fingers, the
426 : // point is implementation-specific, but can for example be the midpoint
427 : // between the very first and very last touch. This is in device pixels and
428 : // are the coordinates on the screen of this midpoint.
429 : // For PINCHGESTURE_END events, this instead will hold the coordinates of
430 : // the remaining finger, if there is one. If there isn't one then it will
431 : // store -1, -1.
432 : ScreenPoint mFocusPoint;
433 :
434 : // |mFocusPoint| transformed to the local coordinates of the APZC targeted
435 : // by the hit. This is set and used by APZ.
436 : ParentLayerPoint mLocalFocusPoint;
437 :
438 : // The distance between the touches responsible for the pinch gesture.
439 : ParentLayerCoord mCurrentSpan;
440 :
441 : // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
442 : // This is only really relevant during a PINCHGESTURE_SCALE because when it is
443 : // of this type then there must have been a history of spans.
444 : ParentLayerCoord mPreviousSpan;
445 : };
446 :
447 : /**
448 : * Encapsulation class for tap events. In general, these will be generated by
449 : * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
450 : * determining whether or not the user was trying to do a gesture.
451 : */
452 0 : class TapGestureInput : public InputData
453 : {
454 : protected:
455 : friend mozilla::layers::PAPZCTreeManagerParent;
456 : friend mozilla::layers::APZCTreeManagerChild;
457 :
458 : TapGestureInput();
459 :
460 : public:
461 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
462 : TapGestureType, (
463 : TAPGESTURE_LONG,
464 : TAPGESTURE_LONG_UP,
465 : TAPGESTURE_UP,
466 : TAPGESTURE_CONFIRMED,
467 : TAPGESTURE_DOUBLE,
468 : TAPGESTURE_SECOND, // See GeckoContentController::TapType::eSecondTap
469 : TAPGESTURE_CANCEL
470 : ));
471 :
472 : // Construct a tap gesture from a Screen point.
473 : // mLocalPoint remains (0,0) unless it's set later.
474 : TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
475 : const ScreenIntPoint& aPoint, Modifiers aModifiers);
476 :
477 : // Construct a tap gesture from a ParentLayer point.
478 : // mPoint remains (0,0) unless it's set later.
479 : TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
480 : const ParentLayerPoint& aLocalPoint, Modifiers aModifiers);
481 :
482 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
483 :
484 : // Warning, this class is serialized and sent over IPC. Any change to its
485 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
486 : TapGestureType mType;
487 :
488 : // The location of the tap in screen pixels.
489 : ScreenIntPoint mPoint;
490 :
491 : // The location of the tap in the local coordinates of the APZC receiving it.
492 : // This is set and used by APZ.
493 : ParentLayerPoint mLocalPoint;
494 : };
495 :
496 : // Encapsulation class for scroll-wheel events. These are generated by mice
497 : // with physical scroll wheels, and on Windows by most touchpads when using
498 : // scroll gestures.
499 0 : class ScrollWheelInput : public InputData
500 : {
501 : protected:
502 : friend mozilla::layers::PAPZCTreeManagerParent;
503 : friend mozilla::layers::APZCTreeManagerChild;
504 :
505 : ScrollWheelInput();
506 :
507 : public:
508 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
509 : ScrollDeltaType, (
510 : // There are three kinds of scroll delta modes in Gecko: "page", "line" and
511 : // "pixel".
512 : SCROLLDELTA_LINE,
513 : SCROLLDELTA_PAGE,
514 : SCROLLDELTA_PIXEL
515 : ));
516 :
517 : MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
518 : ScrollMode, (
519 : SCROLLMODE_INSTANT,
520 : SCROLLMODE_SMOOTH
521 : )
522 : );
523 :
524 : ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers,
525 : ScrollMode aScrollMode, ScrollDeltaType aDeltaType,
526 : const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY,
527 : bool aAllowToOverrideSystemScrollSpeed);
528 : explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
529 :
530 : static ScrollDeltaType DeltaTypeForDeltaMode(uint32_t aDeltaMode);
531 : static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType);
532 : static nsIScrollableFrame::ScrollUnit ScrollUnitForDeltaType(ScrollDeltaType aDeltaType);
533 :
534 : WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
535 : bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
536 :
537 : bool IsCustomizedByUserPrefs() const;
538 :
539 : // Warning, this class is serialized and sent over IPC. Any change to its
540 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
541 : ScrollDeltaType mDeltaType;
542 : ScrollMode mScrollMode;
543 : ScreenPoint mOrigin;
544 :
545 : bool mHandledByAPZ;
546 :
547 : // Deltas are in units corresponding to the delta type. For line deltas, they
548 : // are the number of line units to scroll. The number of device pixels for a
549 : // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
550 : // For pixel deltas, these values are in ScreenCoords.
551 : //
552 : // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
553 : // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
554 : // scrolling down.
555 : double mDeltaX;
556 : double mDeltaY;
557 :
558 : // The location of the scroll in local coordinates. This is set and used by
559 : // APZ.
560 : ParentLayerPoint mLocalOrigin;
561 :
562 : // See lineOrPageDeltaX/Y on WidgetWheelEvent.
563 : int32_t mLineOrPageDeltaX;
564 : int32_t mLineOrPageDeltaY;
565 :
566 : // Indicates the order in which this event was added to a transaction. The
567 : // first event is 1; if not a member of a transaction, this is 0.
568 : uint32_t mScrollSeriesNumber;
569 :
570 : // User-set delta multipliers.
571 : double mUserDeltaMultiplierX;
572 : double mUserDeltaMultiplierY;
573 :
574 : bool mMayHaveMomentum;
575 : bool mIsMomentum;
576 : bool mAllowToOverrideSystemScrollSpeed;
577 : };
578 :
579 0 : class KeyboardInput : public InputData
580 : {
581 : public:
582 : typedef mozilla::layers::KeyboardScrollAction KeyboardScrollAction;
583 :
584 : enum KeyboardEventType
585 : {
586 : KEY_DOWN,
587 : KEY_PRESS,
588 : KEY_UP,
589 : // Any other key event such as eKeyDownOnPlugin
590 : KEY_OTHER,
591 :
592 : // Used as an upper bound for ContiguousEnumSerializer
593 : KEY_SENTINEL,
594 : };
595 :
596 : explicit KeyboardInput(const WidgetKeyboardEvent& aEvent);
597 :
598 : // Warning, this class is serialized and sent over IPC. Any change to its
599 : // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
600 :
601 : KeyboardEventType mType;
602 : uint32_t mKeyCode;
603 : uint32_t mCharCode;
604 : nsTArray<ShortcutKeyCandidate> mShortcutCandidates;
605 :
606 : bool mHandledByAPZ;
607 :
608 : // The scroll action to perform on a layer for this keyboard input. This is
609 : // only used in APZ and is NOT serialized over IPC.
610 : KeyboardScrollAction mAction;
611 :
612 : protected:
613 : friend mozilla::layers::PAPZCTreeManagerParent;
614 : friend mozilla::layers::APZCTreeManagerChild;
615 :
616 : KeyboardInput();
617 : };
618 :
619 : } // namespace mozilla
620 :
621 : #endif // InputData_h__
|