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 that this data is relevant to. This only really matters when this data
80 // is used as an event.
82 // The sequence number of the last potentially focus changing event handled
83 // by APZ. This is used to track when that event has been processed by
84 // content, and focus can be reconfirmed for async keyboard scrolling.
85 uint64_t mFocusSequenceNumber
;
87 // The LayersId of the content process that the corresponding WidgetEvent
88 // should be dispatched to.
89 layers::LayersId mLayersId
;
93 INPUTDATA_AS_CHILD_TYPE(MultiTouchInput
, MULTITOUCH_INPUT
)
94 INPUTDATA_AS_CHILD_TYPE(MouseInput
, MOUSE_INPUT
)
95 INPUTDATA_AS_CHILD_TYPE(PanGestureInput
, PANGESTURE_INPUT
)
96 INPUTDATA_AS_CHILD_TYPE(PinchGestureInput
, PINCHGESTURE_INPUT
)
97 INPUTDATA_AS_CHILD_TYPE(TapGestureInput
, TAPGESTURE_INPUT
)
98 INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput
, SCROLLWHEEL_INPUT
)
99 INPUTDATA_AS_CHILD_TYPE(KeyboardInput
, KEYBOARD_INPUT
)
101 virtual ~InputData();
102 explicit InputData(InputType aInputType
);
105 InputData(InputType aInputType
, TimeStamp aTimeStamp
, Modifiers aModifiers
);
109 * Data container for a single touch input. Similar to dom::Touch, but used in
110 * off-main-thread situations. This is more for just storing touch data, whereas
111 * dom::Touch is more useful for dispatching through the DOM (which can only
112 * happen on the main thread). dom::Touch also bears the problem of storing
113 * pointers to nsIWidget instances which can only be used on the main thread,
114 * so if instead we used dom::Touch and ever set these pointers
115 * off-main-thread, Bad Things Can Happen(tm).
117 * Note that this doesn't inherit from InputData because this itself is not an
118 * event. It is only a container/struct that should have any number of instances
119 * within a MultiTouchInput.
121 * fixme/bug 775746: Make dom::Touch inherit from this class.
123 class SingleTouchData
{
125 // Construct a SingleTouchData from a Screen point.
126 // mLocalScreenPoint remains (0,0) unless it's set later.
127 SingleTouchData(int32_t aIdentifier
, ScreenIntPoint aScreenPoint
,
128 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
130 // Construct a SingleTouchData from a ParentLayer point.
131 // mScreenPoint remains (0,0) unless it's set later.
132 // Note: if APZ starts using the radius for anything, we should add a local
133 // version of that too, and have this constructor take it as a
135 SingleTouchData(int32_t aIdentifier
, ParentLayerPoint aLocalScreenPoint
,
136 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
140 already_AddRefed
<dom::Touch
> ToNewDOMTouch() const;
142 // Warning, this class is serialized and sent over IPC. Any change to its
143 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
145 // Historical data of this touch, which was coalesced into this event.
146 // Touch event coalescing can happen at the system level when the touch
147 // screen's sampling frequency is higher than the vsync rate, or when the
148 // UI thread is busy. When multiple "samples" of touch data are coalesced into
149 // one touch event, the touch event's regular position information is the
150 // information from the last sample. And the previous, "coalesced-away"
151 // samples are stored in mHistoricalData.
153 struct HistoricalTouchData
{
154 // The timestamp at which the information in this "sample" was originally
156 TimeStamp mTimeStamp
;
158 // The touch data of this historical sample.
159 ScreenIntPoint mScreenPoint
;
160 ParentLayerPoint mLocalScreenPoint
;
162 float mRotationAngle
= 0.0f
;
165 CopyableTArray
<HistoricalTouchData
> mHistoricalData
;
167 // A unique number assigned to each SingleTouchData within a MultiTouchInput
168 // so that they can be easily distinguished when handling a touch
172 // Point on the screen that the touch hit, in device pixels. They are
173 // coordinates on the screen.
174 ScreenIntPoint mScreenPoint
;
176 // |mScreenPoint| transformed to the local coordinates of the APZC targeted
177 // by the hit. This is set and used by APZ.
178 ParentLayerPoint mLocalScreenPoint
;
180 // Radius that the touch covers, i.e. if you're using your thumb it will
181 // probably be larger than using your pinky, even with the same force.
182 // Radius can be different along x and y. For example, if you press down with
183 // your entire finger vertically, the y radius will be much larger than the x
187 float mRotationAngle
;
189 // How hard the screen is being pressed.
198 * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
199 * screen touch point instead of the many different coordinate spaces
200 * WidgetTouchEvent stores its touch point in. This includes a way to initialize
201 * itself from a WidgetTouchEvent by copying all relevant data over. Note that
202 * this copying from WidgetTouchEvent functionality can only be used on the main
205 * Stores an array of SingleTouchData.
207 class MultiTouchInput
: public InputData
{
210 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
219 MultiTouchInput(MultiTouchType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
220 Modifiers aModifiers
);
222 MultiTouchInput(MultiTouchInput
&&) = default;
223 MultiTouchInput(const MultiTouchInput
&) = default;
224 explicit MultiTouchInput(const WidgetTouchEvent
& aTouchEvent
);
226 MultiTouchInput
& operator=(MultiTouchInput
&&) = default;
227 MultiTouchInput
& operator=(const MultiTouchInput
&) = default;
229 void Translate(const ScreenPoint
& aTranslation
);
231 WidgetTouchEvent
ToWidgetEvent(
233 uint16_t aInputSource
=
234 /* MouseEvent_Binding::MOZ_SOURCE_TOUCH = */ 5) const;
236 // Return the index into mTouches of the SingleTouchData with the given
237 // identifier, or -1 if there is no such SingleTouchData.
238 int32_t IndexOfTouch(int32_t aTouchIdentifier
);
240 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
242 // Warning, this class is serialized and sent over IPC. Any change to its
243 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
244 MultiTouchType mType
;
245 CopyableTArray
<SingleTouchData
> mTouches
;
246 // The screen offset of the root widget. This can be changing along with
247 // the touch interaction, so we sstore it in the event.
248 ExternalPoint mScreenOffset
;
250 // These button fields match to the corresponding fields in
251 // WidgetMouseEventBase, except mButton defaults to -1 to follow PointerEvent.
252 int16_t mButton
= eNotPressed
;
253 int16_t mButtons
= 0;
256 class MouseInput
: public InputData
{
258 friend mozilla::layers::APZInputBridgeChild
;
259 friend mozilla::layers::PAPZInputBridgeParent
;
265 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
276 MOUSE_EXPLORE_BY_TOUCH
279 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
288 MouseInput(MouseType aType
, ButtonType aButtonType
, uint16_t aInputSource
,
289 int16_t aButtons
, const ScreenPoint
& aPoint
, TimeStamp aTimeStamp
,
290 Modifiers aModifiers
);
291 explicit MouseInput(const WidgetMouseEventBase
& aMouseEvent
);
293 bool IsLeftButton() const;
295 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
296 WidgetMouseEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
298 // Warning, this class is serialized and sent over IPC. Any change to its
299 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
301 ButtonType mButtonType
;
302 uint16_t mInputSource
;
305 ParentLayerPoint mLocalOrigin
;
308 * If click event should not be fired in the content after the "mousedown"
309 * event or following "mouseup", set to true.
311 bool mPreventClickEvent
;
315 * Encapsulation class for pan events, can be used off-main-thread.
316 * These events are currently only used for scrolling on desktop.
318 class PanGestureInput
: public InputData
{
319 friend struct IPC::ParamTraits
<PanGestureInput
>;
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
, TimeStamp aTimeStamp
,
393 const ScreenPoint
& aPanStartPoint
,
394 const ScreenPoint
& aPanDisplacement
, Modifiers aModifiers
);
396 enum class IsEligibleForSwipe
: bool { No
, Yes
};
397 PanGestureInput(PanGestureType aType
, TimeStamp aTimeStamp
,
398 const ScreenPoint
& aPanStartPoint
,
399 const ScreenPoint
& aPanDisplacement
, Modifiers aModifiers
,
400 IsEligibleForSwipe aIsEligibleForSwipe
);
402 void SetLineOrPageDeltas(int32_t aLineOrPageDeltaX
,
403 int32_t aLineOrPageDeltaY
);
405 bool IsMomentum() const;
407 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
409 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
411 ScreenPoint
UserMultipliedPanDisplacement() const;
412 ParentLayerPoint
UserMultipliedLocalPanDisplacement() const;
414 void SetHandledByAPZ(bool aHandled
) { mHandledByAPZ
= aHandled
; }
415 void SetOverscrollBehaviorAllowsSwipe(bool aAllows
) {
416 mOverscrollBehaviorAllowsSwipe
= aAllows
;
418 void SetSimulateMomentum(bool aSimulate
) { mSimulateMomentum
= aSimulate
; }
419 void SetIsNoLineOrPageDelta(bool aIsNoLineOrPageDelta
) {
420 mIsNoLineOrPageDelta
= aIsNoLineOrPageDelta
;
423 // Returns true if this pan gesture event is elligible for browser swipe
424 // gesture considering the overscroll-behavior property of the target
426 bool AllowsSwipe() const {
427 MOZ_ASSERT(mHandledByAPZ
);
428 return mMayTriggerSwipe
&& mOverscrollBehaviorAllowsSwipe
;
431 // Similar to above AllowsSwipe() but this doesn't care the
432 // overscroll-behavior property, this function should be only used for cases
433 // where APZ isn't involved.
434 bool MayTriggerSwipe() const { return mMayTriggerSwipe
; }
435 bool RequiresContentResponseIfCannotScrollHorizontallyInStartDirection();
437 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
439 // Warning, this class is serialized and sent over IPC. Any change to its
440 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
441 PanGestureType mType
;
442 ScreenPoint mPanStartPoint
;
444 // The delta. This can be non-zero on any type of event.
445 ScreenPoint mPanDisplacement
;
447 // Versions of |mPanStartPoint| and |mPanDisplacement| in the local
448 // coordinates of the APZC receiving the pan. These are set and used by APZ.
449 ParentLayerPoint mLocalPanStartPoint
;
450 ParentLayerPoint mLocalPanDisplacement
;
452 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
453 int32_t mLineOrPageDeltaX
;
454 int32_t mLineOrPageDeltaY
;
456 // User-set delta multipliers.
457 double mUserDeltaMultiplierX
;
458 double mUserDeltaMultiplierY
;
460 PanDeltaType mDeltaType
= PANDELTA_PIXEL
;
462 bool mHandledByAPZ
: 1;
464 // This is used by APZ to communicate to widget code whether the
465 // overscroll-behavior of the scroll frame handling this swipe allows
466 // non-local overscroll behaviors in the horizontal direction (such as
467 // swipe navigation).
468 bool mOverscrollBehaviorAllowsSwipe
: 1;
470 // true if APZ should do a fling animation after this pan ends, like
471 // it would with touchscreens. (For platforms that don't emit momentum
473 bool mSimulateMomentum
: 1;
475 // true if the creator of this object does not set the mLineOrPageDeltaX/Y
476 // fields and when/if WidgetWheelEvent's are generated from this object wants
477 // the corresponding mLineOrPageDeltaX/Y fields in the WidgetWheelEvent to be
478 // automatically calculated (upon event dispatch by the EventStateManager
480 bool mIsNoLineOrPageDelta
: 1;
483 // If this is true, and this event started a new input block that couldn't
484 // find a scrollable target which is scrollable in the horizontal component
485 // of the scroll start direction, then this input block needs to be put on
486 // hold until a content response has arrived, even if the block has a
488 // This is used by events that can result in a swipe instead of a scroll.
489 bool mMayTriggerSwipe
: 1;
490 void SetMayTriggerSwipe(bool aValue
) { mMayTriggerSwipe
= aValue
; }
494 * Encapsulation class for pinch events. In general, these will be generated by
495 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
496 * and determining whether or not the user was trying to do a gesture.
498 class PinchGestureInput
: public InputData
{
500 friend mozilla::layers::APZInputBridgeChild
;
501 friend mozilla::layers::PAPZInputBridgeParent
;
507 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
511 // The FINGERLIFTED state is used when a touch-based pinch gesture is
512 // terminated by lifting one of the two fingers. The position of the
513 // finger that's still down is populated as the focus point.
514 PINCHGESTURE_FINGERLIFTED
,
515 // The END state is used when the pinch gesture is completely terminated.
516 // In this state, the focus point should not be relied upon for having
521 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
522 PinchGestureSource
, (
523 UNKNOWN
, // Default initialization value. Should never actually be used.
524 TOUCH
, // From two-finger pinch gesture
525 ONE_TOUCH
, // From one-finger pinch gesture
526 TRACKPAD
, // From trackpad pinch gesture
527 MOUSEWHEEL
// Synthesized from modifier+mousewheel
529 // If adding more items here, increase n_values for the
530 // APZ_ZOOM_PINCHSOURCE Telemetry metric.
534 // Construct a pinch gesture from a Screen point.
535 PinchGestureInput(PinchGestureType aType
, PinchGestureSource aSource
,
536 TimeStamp aTimeStamp
, const ExternalPoint
& aScreenOffset
,
537 const ScreenPoint
& aFocusPoint
, ScreenCoord aCurrentSpan
,
538 ScreenCoord aPreviousSpan
, Modifiers aModifiers
);
540 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
542 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
544 double ComputeDeltaY(nsIWidget
* aWidget
) const;
546 // Set mLineOrPageDeltaY based on ComputeDeltaY().
547 // Return false if the caller should drop this event to ensure
548 // that preventDefault() is respected. (More specifically, this will be
549 // true for event types other than PINCHGESTURE_END if the computed
550 // mLineOrPageDeltaY is zero. In such cases, the resulting DOMMouseScroll
551 // event will not be dispatched, which is a problem if the page is relying
552 // on DOMMouseScroll to prevent browser zooming).
553 // Note that even if the function returns false, the delta from the event
554 // is accumulated and available to be sent in a later event.
555 bool SetLineOrPageDeltaY(nsIWidget
* aWidget
);
557 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
559 // Warning, this class is serialized and sent over IPC. Any change to its
560 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
561 PinchGestureType mType
;
563 // Some indication of the input device that generated this pinch gesture.
564 PinchGestureSource mSource
;
566 // Center point of the pinch gesture. That is, if there are two fingers on the
567 // screen, it is their midpoint. In the case of more than two fingers, the
568 // point is implementation-specific, but can for example be the midpoint
569 // between the very first and very last touch. This is in device pixels and
570 // are the coordinates on the screen of this midpoint.
571 // For PINCHGESTURE_END events, this may hold the last known focus point or
572 // just be empty; in any case for END events it should not be relied upon.
573 // For PINCHGESTURE_FINGERLIFTED events, this holds the point of the finger
574 // that is still down.
575 ScreenPoint mFocusPoint
;
577 // The screen offset of the root widget. This can be changing along with
578 // the touch interaction, so we sstore it in the event.
579 ExternalPoint mScreenOffset
;
581 // |mFocusPoint| transformed to the local coordinates of the APZC targeted
582 // by the hit. This is set and used by APZ.
583 ParentLayerPoint mLocalFocusPoint
;
585 // The distance between the touches responsible for the pinch gesture.
586 ScreenCoord mCurrentSpan
;
588 // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
589 // This is only really relevant during a PINCHGESTURE_SCALE because when it is
590 // of this type then there must have been a history of spans.
591 ScreenCoord mPreviousSpan
;
593 // We accumulate (via GetIntegerDeltaForEvent) the deltaY that would be
594 // computed by ToWidgetEvent, and then whenever we get a whole integer
595 // value we put it in mLineOrPageDeltaY. Since we only ever use deltaY we
596 // don't need a mLineOrPageDeltaX. This field is used to dispatch legacy mouse
597 // events which are only dispatched when the corresponding field on
598 // WidgetWheelEvent is non-zero.
599 int32_t mLineOrPageDeltaY
;
605 * Encapsulation class for tap events. In general, these will be generated by
606 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
607 * and determining whether or not the user was trying to do a gesture.
609 class TapGestureInput
: public InputData
{
611 friend mozilla::layers::APZInputBridgeChild
;
612 friend mozilla::layers::PAPZInputBridgeParent
;
618 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
623 TAPGESTURE_CONFIRMED
,
625 TAPGESTURE_SECOND
, // See GeckoContentController::TapType::eSecondTap
630 // Construct a tap gesture from a Screen point.
631 // mLocalPoint remains (0,0) unless it's set later.
632 TapGestureInput(TapGestureType aType
, TimeStamp aTimeStamp
,
633 const ScreenIntPoint
& aPoint
, Modifiers aModifiers
);
635 // Construct a tap gesture from a ParentLayer point.
636 // mPoint remains (0,0) unless it's set later.
637 TapGestureInput(TapGestureType aType
, TimeStamp aTimeStamp
,
638 const ParentLayerPoint
& aLocalPoint
, Modifiers aModifiers
);
640 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
642 WidgetSimpleGestureEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
644 // Warning, this class is serialized and sent over IPC. Any change to its
645 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
646 TapGestureType mType
;
648 // The location of the tap in screen pixels.
649 ScreenIntPoint mPoint
;
651 // The location of the tap in the local coordinates of the APZC receiving it.
652 // This is set and used by APZ.
653 ParentLayerPoint mLocalPoint
;
656 // Encapsulation class for scroll-wheel events. These are generated by mice
657 // with physical scroll wheels, and on Windows by most touchpads when using
659 class ScrollWheelInput
: public InputData
{
661 friend mozilla::layers::APZInputBridgeChild
;
662 friend mozilla::layers::PAPZInputBridgeParent
;
664 typedef mozilla::layers::APZWheelAction APZWheelAction
;
670 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
672 // There are three kinds of scroll delta modes in Gecko: "page", "line"
679 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
687 ScrollWheelInput(TimeStamp aTimeStamp
, Modifiers aModifiers
,
688 ScrollMode aScrollMode
, ScrollDeltaType aDeltaType
,
689 const ScreenPoint
& aOrigin
, double aDeltaX
, double aDeltaY
,
690 bool aAllowToOverrideSystemScrollSpeed
,
691 WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy
);
692 explicit ScrollWheelInput(const WidgetWheelEvent
& aEvent
);
694 static ScrollDeltaType
DeltaTypeForDeltaMode(uint32_t aDeltaMode
);
695 static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType
);
696 static mozilla::ScrollUnit
ScrollUnitForDeltaType(ScrollDeltaType aDeltaType
);
698 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
699 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
701 bool IsCustomizedByUserPrefs() const;
703 // The following two functions are for auto-dir scrolling. For detailed
704 // information on auto-dir, @see mozilla::WheelDeltaAdjustmentStrategy
705 bool IsAutoDir(bool aForce
= false) const {
710 switch (mWheelDeltaAdjustmentStrategy
) {
711 case WheelDeltaAdjustmentStrategy::eAutoDir
:
712 case WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
:
715 // Prevent compilation errors generated by -Werror=switch
720 // Indicates which element this scroll honours if it's an auto-dir scroll.
721 // If true, honour the root element; otherwise, honour the currently scrolling
723 // Note that if IsAutoDir() returns false, then this function also returns
724 // false, but false in this case is meaningless as IsAutoDir() indicates it's
725 // not an auto-dir scroll.
726 // For detailed information on auto-dir,
727 // @see mozilla::WheelDeltaAdjustmentStrategy
728 bool HonoursRoot(bool aForce
= false) const {
729 return WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
==
730 mWheelDeltaAdjustmentStrategy
||
734 // Warning, this class is serialized and sent over IPC. Any change to its
735 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
736 ScrollDeltaType mDeltaType
;
737 ScrollMode mScrollMode
;
742 // Deltas are in units corresponding to the delta type. For line deltas, they
743 // are the number of line units to scroll. The number of device pixels for a
744 // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
745 // For pixel deltas, these values are in ScreenCoords.
747 // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
748 // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
753 // The number of scroll wheel ticks.
754 double mWheelTicksX
= 0.0;
755 double mWheelTicksY
= 0.0;
757 // The location of the scroll in local coordinates. This is set and used by
759 ParentLayerPoint mLocalOrigin
;
761 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
762 int32_t mLineOrPageDeltaX
;
763 int32_t mLineOrPageDeltaY
;
765 // Indicates the order in which this event was added to a transaction. The
766 // first event is 1; if not a member of a transaction, this is 0.
767 uint32_t mScrollSeriesNumber
;
769 // User-set delta multipliers.
770 double mUserDeltaMultiplierX
;
771 double mUserDeltaMultiplierY
;
773 bool mMayHaveMomentum
;
775 bool mAllowToOverrideSystemScrollSpeed
;
777 // Sometimes a wheel event input's wheel delta should be adjusted. This member
778 // specifies how to adjust the wheel delta.
779 WheelDeltaAdjustmentStrategy mWheelDeltaAdjustmentStrategy
;
781 APZWheelAction mAPZAction
;
784 class KeyboardInput
: public InputData
{
786 typedef mozilla::layers::KeyboardScrollAction KeyboardScrollAction
;
788 // Note that if you change the first member in this enum(I.e. KEY_DOWN) to one
789 // other member, don't forget to update the minimum value in
790 // ContiguousEnumSerializer for KeyboardEventType in widget/nsGUIEventIPC
792 enum KeyboardEventType
{
796 // Any other key event such as eAccessKeyNotFound
799 // Used as an upper bound for ContiguousEnumSerializer
803 explicit KeyboardInput(const WidgetKeyboardEvent
& aEvent
);
805 // Warning, this class is serialized and sent over IPC. Any change to its
806 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
808 KeyboardEventType mType
;
811 CopyableTArray
<ShortcutKeyCandidate
> mShortcutCandidates
;
815 // The scroll action to perform on a layer for this keyboard input. This is
816 // only used in APZ and is NOT serialized over IPC.
817 KeyboardScrollAction mAction
;
820 friend mozilla::layers::APZInputBridgeChild
;
821 friend mozilla::layers::PAPZInputBridgeParent
;
826 } // namespace mozilla
828 #endif // InputData_h__