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/. */
13 #include "mozilla/ScrollTypes.h"
14 #include "mozilla/DefineEnum.h"
15 #include "mozilla/EventForwards.h"
16 #include "mozilla/TimeStamp.h"
17 #include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
18 #include "mozilla/gfx/MatrixFwd.h"
19 #include "mozilla/layers/APZPublicUtils.h"
20 #include "mozilla/layers/KeyboardScrollAction.h"
21 #include "mozilla/TextEvents.h"
24 struct already_AddRefed
;
30 class APZInputBridgeChild
;
31 class PAPZInputBridgeParent
;
51 class MultiTouchInput
;
53 class PanGestureInput
;
54 class PinchGestureInput
;
55 class TapGestureInput
;
56 class ScrollWheelInput
;
59 // This looks unnecessary now, but as we add more and more classes that derive
60 // from InputType (eventually probably almost as many as *Events.h has), it
61 // will be more and more clear what's going on with a macro that shortens the
62 // definition of the RTTI functions.
63 #define INPUTDATA_AS_CHILD_TYPE(type, enumID) \
64 const type& As##type() const { \
65 MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
66 return (const type&)*this; \
69 MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
70 return (type&)*this; \
73 /** Base input data class. Should never be instantiated. */
76 // Warning, this class is serialized and sent over IPC. Any change to its
77 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
79 // Time in milliseconds that this data is relevant to. This only really
80 // matters when this data is used as an event. We use uint32_t instead of
81 // TimeStamp because it is easier to convert from WidgetInputEvent. The time
82 // is platform-specific but it in the case of B2G and Fennec it is since
85 // Set in parallel to mTime until we determine it is safe to drop
86 // platform-specific event times (see bug 77992).
88 // The sequence number of the last potentially focus changing event handled
89 // by APZ. This is used to track when that event has been processed by
90 // content, and focus can be reconfirmed for async keyboard scrolling.
91 uint64_t mFocusSequenceNumber
;
93 // The LayersId of the content process that the corresponding WidgetEvent
94 // should be dispatched to.
95 layers::LayersId mLayersId
;
99 INPUTDATA_AS_CHILD_TYPE(MultiTouchInput
, MULTITOUCH_INPUT
)
100 INPUTDATA_AS_CHILD_TYPE(MouseInput
, MOUSE_INPUT
)
101 INPUTDATA_AS_CHILD_TYPE(PanGestureInput
, PANGESTURE_INPUT
)
102 INPUTDATA_AS_CHILD_TYPE(PinchGestureInput
, PINCHGESTURE_INPUT
)
103 INPUTDATA_AS_CHILD_TYPE(TapGestureInput
, TAPGESTURE_INPUT
)
104 INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput
, SCROLLWHEEL_INPUT
)
105 INPUTDATA_AS_CHILD_TYPE(KeyboardInput
, KEYBOARD_INPUT
)
107 virtual ~InputData();
108 explicit InputData(InputType aInputType
);
111 InputData(InputType aInputType
, uint32_t aTime
, TimeStamp aTimeStamp
,
112 Modifiers aModifiers
);
116 * Data container for a single touch input. Similar to dom::Touch, but used in
117 * off-main-thread situations. This is more for just storing touch data, whereas
118 * dom::Touch is more useful for dispatching through the DOM (which can only
119 * happen on the main thread). dom::Touch also bears the problem of storing
120 * pointers to nsIWidget instances which can only be used on the main thread,
121 * so if instead we used dom::Touch and ever set these pointers
122 * off-main-thread, Bad Things Can Happen(tm).
124 * Note that this doesn't inherit from InputData because this itself is not an
125 * event. It is only a container/struct that should have any number of instances
126 * within a MultiTouchInput.
128 * fixme/bug 775746: Make dom::Touch inherit from this class.
130 class SingleTouchData
{
132 // Construct a SingleTouchData from a Screen point.
133 // mLocalScreenPoint remains (0,0) unless it's set later.
134 SingleTouchData(int32_t aIdentifier
, ScreenIntPoint aScreenPoint
,
135 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
137 // Construct a SingleTouchData from a ParentLayer point.
138 // mScreenPoint remains (0,0) unless it's set later.
139 // Note: if APZ starts using the radius for anything, we should add a local
140 // version of that too, and have this constructor take it as a
142 SingleTouchData(int32_t aIdentifier
, ParentLayerPoint aLocalScreenPoint
,
143 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
147 already_AddRefed
<dom::Touch
> ToNewDOMTouch() const;
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
152 // Historical data of this touch, which was coalesced into this event.
153 // Touch event coalescing can happen at the system level when the touch
154 // screen's sampling frequency is higher than the vsync rate, or when the
155 // UI thread is busy. When multiple "samples" of touch data are coalesced into
156 // one touch event, the touch event's regular position information is the
157 // information from the last sample. And the previous, "coalesced-away"
158 // samples are stored in mHistoricalData.
160 struct HistoricalTouchData
{
161 // The timestamp at which the information in this "sample" was originally
163 TimeStamp mTimeStamp
;
165 // The touch data of this historical sample.
166 ScreenIntPoint mScreenPoint
;
167 ParentLayerPoint mLocalScreenPoint
;
169 float mRotationAngle
= 0.0f
;
172 CopyableTArray
<HistoricalTouchData
> mHistoricalData
;
174 // A unique number assigned to each SingleTouchData within a MultiTouchInput
175 // so that they can be easily distinguished when handling a touch
179 // Point on the screen that the touch hit, in device pixels. They are
180 // coordinates on the screen.
181 ScreenIntPoint mScreenPoint
;
183 // |mScreenPoint| transformed to the local coordinates of the APZC targeted
184 // by the hit. This is set and used by APZ.
185 ParentLayerPoint mLocalScreenPoint
;
187 // Radius that the touch covers, i.e. if you're using your thumb it will
188 // probably be larger than using your pinky, even with the same force.
189 // Radius can be different along x and y. For example, if you press down with
190 // your entire finger vertically, the y radius will be much larger than the x
194 float mRotationAngle
;
196 // How hard the screen is being pressed.
205 * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
206 * screen touch point instead of the many different coordinate spaces
207 * WidgetTouchEvent stores its touch point in. This includes a way to initialize
208 * itself from a WidgetTouchEvent by copying all relevant data over. Note that
209 * this copying from WidgetTouchEvent functionality can only be used on the main
212 * Stores an array of SingleTouchData.
214 class MultiTouchInput
: public InputData
{
217 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
226 MultiTouchInput(MultiTouchType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
227 Modifiers aModifiers
);
229 MultiTouchInput(MultiTouchInput
&&) = default;
230 MultiTouchInput(const MultiTouchInput
& aOther
);
231 explicit MultiTouchInput(const WidgetTouchEvent
& aTouchEvent
);
233 MultiTouchInput
& operator=(MultiTouchInput
&&) = default;
234 MultiTouchInput
& operator=(const MultiTouchInput
&) = default;
236 void Translate(const ScreenPoint
& aTranslation
);
238 WidgetTouchEvent
ToWidgetEvent(
240 uint16_t aInputSource
=
241 /* MouseEvent_Binding::MOZ_SOURCE_TOUCH = */ 5) const;
243 // Return the index into mTouches of the SingleTouchData with the given
244 // identifier, or -1 if there is no such SingleTouchData.
245 int32_t IndexOfTouch(int32_t aTouchIdentifier
);
247 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
249 // Warning, this class is serialized and sent over IPC. Any change to its
250 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
251 MultiTouchType mType
;
252 CopyableTArray
<SingleTouchData
> mTouches
;
253 // The screen offset of the root widget. This can be changing along with
254 // the touch interaction, so we sstore it in the event.
255 ExternalPoint mScreenOffset
;
259 class MouseInput
: public InputData
{
261 friend mozilla::layers::APZInputBridgeChild
;
262 friend mozilla::layers::PAPZInputBridgeParent
;
268 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
281 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
290 MouseInput(MouseType aType
, ButtonType aButtonType
, uint16_t aInputSource
,
291 int16_t aButtons
, const ScreenPoint
& aPoint
, uint32_t aTime
,
292 TimeStamp aTimeStamp
, Modifiers aModifiers
);
293 explicit MouseInput(const WidgetMouseEventBase
& aMouseEvent
);
295 bool IsLeftButton() const;
297 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
298 WidgetMouseEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
300 // Warning, this class is serialized and sent over IPC. Any change to its
301 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
303 ButtonType mButtonType
;
304 uint16_t mInputSource
;
307 ParentLayerPoint mLocalOrigin
;
310 * If click event should not be fired in the content after the "mousedown"
311 * event or following "mouseup", set to true.
313 bool mPreventClickEvent
;
317 * Encapsulation class for pan events, can be used off-main-thread.
318 * These events are currently only used for scrolling on desktop.
320 class PanGestureInput
: public InputData
{
322 friend mozilla::layers::APZInputBridgeChild
;
323 friend mozilla::layers::PAPZInputBridgeParent
;
329 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
331 // MayStart: Dispatched before any actual panning has occurred but when a
332 // pan gesture is probably about to start, for example when the user
333 // starts touching the touchpad. Should interrupt any ongoing APZ
334 // animation and can be used to trigger scrollability indicators (e.g.
335 // flashing overlay scrollbars).
338 // Cancelled: Dispatched after MayStart when no pan gesture is going to
339 // happen after all, for example when the user lifts their fingers from a
340 // touchpad without having done any scrolling.
341 PANGESTURE_CANCELLED
,
343 // Start: A pan gesture is starting.
344 // For devices that do not support the MayStart event type, this event can
345 // be used to interrupt ongoing APZ animations.
348 // Pan: The actual pan motion by mPanDisplacement.
351 // End: The pan gesture has ended, for example because the user has lifted
352 // their fingers from a touchpad after scrolling.
353 // Any potential momentum events fire after this event.
356 // The following momentum event types are used in order to control the pan
357 // momentum animation. Using these instead of our own animation ensures
358 // that the animation curve is OS native and that the animation stops
359 // reliably if it is cancelled by the user.
361 // MomentumStart: Dispatched between the End event of the actual
362 // user-controlled pan, and the first MomentumPan event of the momentum
364 PANGESTURE_MOMENTUMSTART
,
366 // MomentumPan: The actual momentum motion by mPanDisplacement.
367 PANGESTURE_MOMENTUMPAN
,
369 // MomentumEnd: The momentum animation has ended, for example because the
370 // momentum velocity has gone below the stopping threshold, or because the
371 // user has stopped the animation by putting their fingers on a touchpad.
372 PANGESTURE_MOMENTUMEND
,
374 // Interrupted:: A pan gesture started being handled by an APZC but
375 // subsequent pan events might have been consumed by other operations
376 // which haven't been handled by the APZC (e.g. full zoom).
377 PANGESTURE_INTERRUPTED
380 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
382 // There are three kinds of scroll delta modes in Gecko: "page", "line"
383 // and "pixel". Touchpad pan gestures only support "page" and "pixel".
385 // NOTE: PANDELTA_PAGE currently replicates Gtk behavior
386 // (see AsyncPanZoomController::OnPan).
392 PanGestureInput(PanGestureType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
393 const ScreenPoint
& aPanStartPoint
,
394 const ScreenPoint
& aPanDisplacement
, Modifiers aModifiers
);
396 bool IsMomentum() const;
398 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
400 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
402 ScreenPoint
UserMultipliedPanDisplacement() const;
403 ParentLayerPoint
UserMultipliedLocalPanDisplacement() const;
405 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
407 // Warning, this class is serialized and sent over IPC. Any change to its
408 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
409 PanGestureType mType
;
410 ScreenPoint mPanStartPoint
;
412 // The delta. This can be non-zero on any type of event.
413 ScreenPoint mPanDisplacement
;
415 // Versions of |mPanStartPoint| and |mPanDisplacement| in the local
416 // coordinates of the APZC receiving the pan. These are set and used by APZ.
417 ParentLayerPoint mLocalPanStartPoint
;
418 ParentLayerPoint mLocalPanDisplacement
;
420 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
421 int32_t mLineOrPageDeltaX
;
422 int32_t mLineOrPageDeltaY
;
424 // User-set delta multipliers.
425 double mUserDeltaMultiplierX
;
426 double mUserDeltaMultiplierY
;
428 PanDeltaType mDeltaType
= PANDELTA_PIXEL
;
430 bool mHandledByAPZ
: 1;
432 // true if this is a PANGESTURE_END event that will be followed by a
433 // PANGESTURE_MOMENTUMSTART event.
434 bool mFollowedByMomentum
: 1;
436 // If this is true, and this event started a new input block that couldn't
437 // find a scrollable target which is scrollable in the horizontal component
438 // of the scroll start direction, then this input block needs to be put on
439 // hold until a content response has arrived, even if the block has a
441 // This is used by events that can result in a swipe instead of a scroll.
442 bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection
: 1;
444 // This is used by APZ to communicate to the macOS widget code whether
445 // the overscroll-behavior of the scroll frame handling this swipe allows
446 // non-local overscroll behaviors in the horizontal direction (such as
447 // swipe navigation).
448 bool mOverscrollBehaviorAllowsSwipe
: 1;
450 // true if APZ should do a fling animation after this pan ends, like
451 // it would with touchscreens. (For platforms that don't emit momentum
453 bool mSimulateMomentum
: 1;
455 void SetHandledByAPZ(bool aHandled
) { mHandledByAPZ
= aHandled
; }
456 void SetFollowedByMomentum(bool aFollowed
) {
457 mFollowedByMomentum
= aFollowed
;
459 void SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(
461 mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection
=
464 void SetOverscrollBehaviorAllowsSwipe(bool aAllows
) {
465 mOverscrollBehaviorAllowsSwipe
= aAllows
;
467 void SetSimulateMomentum(bool aSimulate
) { mSimulateMomentum
= aSimulate
; }
471 * Encapsulation class for pinch events. In general, these will be generated by
472 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
473 * and determining whether or not the user was trying to do a gesture.
475 class PinchGestureInput
: public InputData
{
477 friend mozilla::layers::APZInputBridgeChild
;
478 friend mozilla::layers::PAPZInputBridgeParent
;
484 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
488 // The FINGERLIFTED state is used when a touch-based pinch gesture is
489 // terminated by lifting one of the two fingers. The position of the
490 // finger that's still down is populated as the focus point.
491 PINCHGESTURE_FINGERLIFTED
,
492 // The END state is used when the pinch gesture is completely terminated.
493 // In this state, the focus point should not be relied upon for having
498 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
499 PinchGestureSource
, (
500 UNKNOWN
, // Default initialization value. Should never actually be used.
501 TOUCH
, // From two-finger pinch gesture
502 ONE_TOUCH
, // From one-finger pinch gesture
503 TRACKPAD
, // From trackpad pinch gesture
504 MOUSEWHEEL
// Synthesized from modifier+mousewheel
506 // If adding more items here, increase n_values for the
507 // APZ_ZOOM_PINCHSOURCE Telemetry metric.
511 // Construct a pinch gesture from a Screen point.
512 PinchGestureInput(PinchGestureType aType
, PinchGestureSource aSource
,
513 uint32_t aTime
, TimeStamp aTimeStamp
,
514 const ExternalPoint
& aScreenOffset
,
515 const ScreenPoint
& aFocusPoint
, ScreenCoord aCurrentSpan
,
516 ScreenCoord aPreviousSpan
, Modifiers aModifiers
);
518 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
520 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
522 double ComputeDeltaY(nsIWidget
* aWidget
) const;
524 // Set mLineOrPageDeltaY based on ComputeDeltaY().
525 // Return false if the caller should drop this event to ensure
526 // that preventDefault() is respected. (More specifically, this will be
527 // true for event types other than PINCHGESTURE_END if the computed
528 // mLineOrPageDeltaY is zero. In such cases, the resulting DOMMouseScroll
529 // event will not be dispatched, which is a problem if the page is relying
530 // on DOMMouseScroll to prevent browser zooming).
531 // Note that even if the function returns false, the delta from the event
532 // is accumulated and available to be sent in a later event.
533 bool SetLineOrPageDeltaY(nsIWidget
* aWidget
);
535 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
537 // Warning, this class is serialized and sent over IPC. Any change to its
538 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
539 PinchGestureType mType
;
541 // Some indication of the input device that generated this pinch gesture.
542 PinchGestureSource mSource
;
544 // Center point of the pinch gesture. That is, if there are two fingers on the
545 // screen, it is their midpoint. In the case of more than two fingers, the
546 // point is implementation-specific, but can for example be the midpoint
547 // between the very first and very last touch. This is in device pixels and
548 // are the coordinates on the screen of this midpoint.
549 // For PINCHGESTURE_END events, this may hold the last known focus point or
550 // just be empty; in any case for END events it should not be relied upon.
551 // For PINCHGESTURE_FINGERLIFTED events, this holds the point of the finger
552 // that is still down.
553 ScreenPoint mFocusPoint
;
555 // The screen offset of the root widget. This can be changing along with
556 // the touch interaction, so we sstore it in the event.
557 ExternalPoint mScreenOffset
;
559 // |mFocusPoint| transformed to the local coordinates of the APZC targeted
560 // by the hit. This is set and used by APZ.
561 ParentLayerPoint mLocalFocusPoint
;
563 // The distance between the touches responsible for the pinch gesture.
564 ScreenCoord mCurrentSpan
;
566 // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
567 // This is only really relevant during a PINCHGESTURE_SCALE because when it is
568 // of this type then there must have been a history of spans.
569 ScreenCoord mPreviousSpan
;
571 // We accumulate (via GetIntegerDeltaForEvent) the deltaY that would be
572 // computed by ToWidgetEvent, and then whenever we get a whole integer
573 // value we put it in mLineOrPageDeltaY. Since we only ever use deltaY we
574 // don't need a mLineOrPageDeltaX. This field is used to dispatch legacy mouse
575 // events which are only dispatched when the corresponding field on
576 // WidgetWheelEvent is non-zero.
577 int32_t mLineOrPageDeltaY
;
583 * Encapsulation class for tap events. In general, these will be generated by
584 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
585 * and determining whether or not the user was trying to do a gesture.
587 class TapGestureInput
: public InputData
{
589 friend mozilla::layers::APZInputBridgeChild
;
590 friend mozilla::layers::PAPZInputBridgeParent
;
596 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
601 TAPGESTURE_CONFIRMED
,
603 TAPGESTURE_SECOND
, // See GeckoContentController::TapType::eSecondTap
608 // Construct a tap gesture from a Screen point.
609 // mLocalPoint remains (0,0) unless it's set later.
610 TapGestureInput(TapGestureType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
611 const ScreenIntPoint
& aPoint
, Modifiers aModifiers
);
613 // Construct a tap gesture from a ParentLayer point.
614 // mPoint remains (0,0) unless it's set later.
615 TapGestureInput(TapGestureType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
616 const ParentLayerPoint
& aLocalPoint
, Modifiers aModifiers
);
618 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
620 WidgetSimpleGestureEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
622 // Warning, this class is serialized and sent over IPC. Any change to its
623 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
624 TapGestureType mType
;
626 // The location of the tap in screen pixels.
627 ScreenIntPoint mPoint
;
629 // The location of the tap in the local coordinates of the APZC receiving it.
630 // This is set and used by APZ.
631 ParentLayerPoint mLocalPoint
;
634 // Encapsulation class for scroll-wheel events. These are generated by mice
635 // with physical scroll wheels, and on Windows by most touchpads when using
637 class ScrollWheelInput
: public InputData
{
639 friend mozilla::layers::APZInputBridgeChild
;
640 friend mozilla::layers::PAPZInputBridgeParent
;
642 typedef mozilla::layers::APZWheelAction APZWheelAction
;
648 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
650 // There are three kinds of scroll delta modes in Gecko: "page", "line"
657 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
665 ScrollWheelInput(uint32_t aTime
, TimeStamp aTimeStamp
, Modifiers aModifiers
,
666 ScrollMode aScrollMode
, ScrollDeltaType aDeltaType
,
667 const ScreenPoint
& aOrigin
, double aDeltaX
, double aDeltaY
,
668 bool aAllowToOverrideSystemScrollSpeed
,
669 WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy
);
670 explicit ScrollWheelInput(const WidgetWheelEvent
& aEvent
);
672 static ScrollDeltaType
DeltaTypeForDeltaMode(uint32_t aDeltaMode
);
673 static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType
);
674 static mozilla::ScrollUnit
ScrollUnitForDeltaType(ScrollDeltaType aDeltaType
);
676 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
677 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
679 bool IsCustomizedByUserPrefs() const;
681 // The following two functions are for auto-dir scrolling. For detailed
682 // information on auto-dir, @see mozilla::WheelDeltaAdjustmentStrategy
683 bool IsAutoDir() const {
684 switch (mWheelDeltaAdjustmentStrategy
) {
685 case WheelDeltaAdjustmentStrategy::eAutoDir
:
686 case WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
:
689 // Prevent compilation errors generated by -Werror=switch
694 // Indicates which element this scroll honours if it's an auto-dir scroll.
695 // If true, honour the root element; otherwise, honour the currently scrolling
697 // Note that if IsAutoDir() returns false, then this function also returns
698 // false, but false in this case is meaningless as IsAutoDir() indicates it's
699 // not an auto-dir scroll.
700 // For detailed information on auto-dir,
701 // @see mozilla::WheelDeltaAdjustmentStrategy
702 bool HonoursRoot() const {
703 return WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
==
704 mWheelDeltaAdjustmentStrategy
;
707 // Warning, this class is serialized and sent over IPC. Any change to its
708 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
709 ScrollDeltaType mDeltaType
;
710 ScrollMode mScrollMode
;
715 // Deltas are in units corresponding to the delta type. For line deltas, they
716 // are the number of line units to scroll. The number of device pixels for a
717 // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
718 // For pixel deltas, these values are in ScreenCoords.
720 // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
721 // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
726 // The number of scroll wheel ticks.
727 double mWheelTicksX
= 0.0;
728 double mWheelTicksY
= 0.0;
730 // The location of the scroll in local coordinates. This is set and used by
732 ParentLayerPoint mLocalOrigin
;
734 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
735 int32_t mLineOrPageDeltaX
;
736 int32_t mLineOrPageDeltaY
;
738 // Indicates the order in which this event was added to a transaction. The
739 // first event is 1; if not a member of a transaction, this is 0.
740 uint32_t mScrollSeriesNumber
;
742 // User-set delta multipliers.
743 double mUserDeltaMultiplierX
;
744 double mUserDeltaMultiplierY
;
746 bool mMayHaveMomentum
;
748 bool mAllowToOverrideSystemScrollSpeed
;
750 // Sometimes a wheel event input's wheel delta should be adjusted. This member
751 // specifies how to adjust the wheel delta.
752 WheelDeltaAdjustmentStrategy mWheelDeltaAdjustmentStrategy
;
754 APZWheelAction mAPZAction
;
757 class KeyboardInput
: public InputData
{
759 typedef mozilla::layers::KeyboardScrollAction KeyboardScrollAction
;
761 // Note that if you change the first member in this enum(I.e. KEY_DOWN) to one
762 // other member, don't forget to update the minimum value in
763 // ContiguousEnumSerializer for KeyboardEventType in widget/nsGUIEventIPC
765 enum KeyboardEventType
{
769 // Any other key event such as eKeyDownOnPlugin
772 // Used as an upper bound for ContiguousEnumSerializer
776 explicit KeyboardInput(const WidgetKeyboardEvent
& aEvent
);
778 // Warning, this class is serialized and sent over IPC. Any change to its
779 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
781 KeyboardEventType mType
;
784 CopyableTArray
<ShortcutKeyCandidate
> mShortcutCandidates
;
788 // The scroll action to perform on a layer for this keyboard input. This is
789 // only used in APZ and is NOT serialized over IPC.
790 KeyboardScrollAction mAction
;
793 friend mozilla::layers::APZInputBridgeChild
;
794 friend mozilla::layers::PAPZInputBridgeParent
;
799 } // namespace mozilla
801 #endif // InputData_h__