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"
22 #include "mozilla/ipc/IPCForwards.h"
25 struct already_AddRefed
;
31 class APZInputBridgeChild
;
32 class PAPZInputBridgeParent
;
52 class MultiTouchInput
;
54 class PanGestureInput
;
55 class PinchGestureInput
;
56 class TapGestureInput
;
57 class ScrollWheelInput
;
60 // This looks unnecessary now, but as we add more and more classes that derive
61 // from InputType (eventually probably almost as many as *Events.h has), it
62 // will be more and more clear what's going on with a macro that shortens the
63 // definition of the RTTI functions.
64 #define INPUTDATA_AS_CHILD_TYPE(type, enumID) \
65 const type& As##type() const { \
66 MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
67 return (const type&)*this; \
70 MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
71 return (type&)*this; \
74 /** Base input data class. Should never be instantiated. */
77 // Warning, this class is serialized and sent over IPC. Any change to its
78 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
80 // Time that this data is relevant to. This only really matters when this data
81 // is used as an event.
83 // The sequence number of the last potentially focus changing event handled
84 // by APZ. This is used to track when that event has been processed by
85 // content, and focus can be reconfirmed for async keyboard scrolling.
86 uint64_t mFocusSequenceNumber
;
88 // The LayersId of the content process that the corresponding WidgetEvent
89 // should be dispatched to.
90 layers::LayersId mLayersId
;
94 INPUTDATA_AS_CHILD_TYPE(MultiTouchInput
, MULTITOUCH_INPUT
)
95 INPUTDATA_AS_CHILD_TYPE(MouseInput
, MOUSE_INPUT
)
96 INPUTDATA_AS_CHILD_TYPE(PanGestureInput
, PANGESTURE_INPUT
)
97 INPUTDATA_AS_CHILD_TYPE(PinchGestureInput
, PINCHGESTURE_INPUT
)
98 INPUTDATA_AS_CHILD_TYPE(TapGestureInput
, TAPGESTURE_INPUT
)
99 INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput
, SCROLLWHEEL_INPUT
)
100 INPUTDATA_AS_CHILD_TYPE(KeyboardInput
, KEYBOARD_INPUT
)
102 virtual ~InputData();
103 explicit InputData(InputType aInputType
);
106 InputData(InputType aInputType
, TimeStamp aTimeStamp
, Modifiers aModifiers
);
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).
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.
122 * fixme/bug 775746: Make dom::Touch inherit from this class.
124 class SingleTouchData
{
126 // Construct a SingleTouchData from a Screen point.
127 // mLocalScreenPoint remains (0,0) unless it's set later.
128 SingleTouchData(int32_t aIdentifier
, ScreenIntPoint aScreenPoint
,
129 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
131 // Construct a SingleTouchData from a ParentLayer point.
132 // mScreenPoint remains (0,0) unless it's set later.
133 // Note: if APZ starts using the radius for anything, we should add a local
134 // version of that too, and have this constructor take it as a
136 SingleTouchData(int32_t aIdentifier
, ParentLayerPoint aLocalScreenPoint
,
137 ScreenSize aRadius
, float aRotationAngle
, float aForce
);
141 already_AddRefed
<dom::Touch
> ToNewDOMTouch() const;
143 // Warning, this class is serialized and sent over IPC. Any change to its
144 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
146 // Historical data of this touch, which was coalesced into this event.
147 // Touch event coalescing can happen at the system level when the touch
148 // screen's sampling frequency is higher than the vsync rate, or when the
149 // UI thread is busy. When multiple "samples" of touch data are coalesced into
150 // one touch event, the touch event's regular position information is the
151 // information from the last sample. And the previous, "coalesced-away"
152 // samples are stored in mHistoricalData.
154 struct HistoricalTouchData
{
155 // The timestamp at which the information in this "sample" was originally
157 TimeStamp mTimeStamp
;
159 // The touch data of this historical sample.
160 ScreenIntPoint mScreenPoint
;
161 ParentLayerPoint mLocalScreenPoint
;
163 float mRotationAngle
= 0.0f
;
166 CopyableTArray
<HistoricalTouchData
> mHistoricalData
;
168 // A unique number assigned to each SingleTouchData within a MultiTouchInput
169 // so that they can be easily distinguished when handling a touch
173 // Point on the screen that the touch hit, in device pixels. They are
174 // coordinates on the screen.
175 ScreenIntPoint mScreenPoint
;
177 // |mScreenPoint| transformed to the local coordinates of the APZC targeted
178 // by the hit. This is set and used by APZ.
179 ParentLayerPoint mLocalScreenPoint
;
181 // Radius that the touch covers, i.e. if you're using your thumb it will
182 // probably be larger than using your pinky, even with the same force.
183 // Radius can be different along x and y. For example, if you press down with
184 // your entire finger vertically, the y radius will be much larger than the x
188 float mRotationAngle
;
190 // How hard the screen is being pressed.
199 * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
200 * screen touch point instead of the many different coordinate spaces
201 * WidgetTouchEvent stores its touch point in. This includes a way to initialize
202 * itself from a WidgetTouchEvent by copying all relevant data over. Note that
203 * this copying from WidgetTouchEvent functionality can only be used on the main
206 * Stores an array of SingleTouchData.
208 class MultiTouchInput
: public InputData
{
211 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
220 MultiTouchInput(MultiTouchType aType
, uint32_t aTime
, TimeStamp aTimeStamp
,
221 Modifiers aModifiers
);
223 MultiTouchInput(MultiTouchInput
&&) = default;
224 MultiTouchInput(const MultiTouchInput
&) = default;
225 explicit MultiTouchInput(const WidgetTouchEvent
& aTouchEvent
);
227 MultiTouchInput
& operator=(MultiTouchInput
&&) = default;
228 MultiTouchInput
& operator=(const MultiTouchInput
&) = default;
230 void Translate(const ScreenPoint
& aTranslation
);
232 WidgetTouchEvent
ToWidgetEvent(
234 uint16_t aInputSource
=
235 /* MouseEvent_Binding::MOZ_SOURCE_TOUCH = */ 5) const;
237 // Return the index into mTouches of the SingleTouchData with the given
238 // identifier, or -1 if there is no such SingleTouchData.
239 int32_t IndexOfTouch(int32_t aTouchIdentifier
);
241 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
243 // Warning, this class is serialized and sent over IPC. Any change to its
244 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
245 MultiTouchType mType
;
246 CopyableTArray
<SingleTouchData
> mTouches
;
247 // The screen offset of the root widget. This can be changing along with
248 // the touch interaction, so we sstore it in the event.
249 ExternalPoint mScreenOffset
;
251 // These button fields match to the corresponding fields in
252 // WidgetMouseEventBase, except mButton defaults to -1 to follow PointerEvent.
253 int16_t mButton
= eNotPressed
;
254 int16_t mButtons
= 0;
257 class MouseInput
: public InputData
{
259 friend mozilla::layers::APZInputBridgeChild
;
260 friend mozilla::layers::PAPZInputBridgeParent
;
261 ALLOW_DEPRECATED_READPARAM
267 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
282 MOUSE_EXPLORE_BY_TOUCH
,
286 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
295 MouseInput(MouseType aType
, ButtonType aButtonType
, uint16_t aInputSource
,
296 int16_t aButtons
, const ScreenPoint
& aPoint
, TimeStamp aTimeStamp
,
297 Modifiers aModifiers
);
298 explicit MouseInput(const WidgetMouseEventBase
& aMouseEvent
);
300 bool IsLeftButton() const;
302 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
303 [[nodiscard
]] bool IsPointerEventType() const;
304 template <typename WidgetMouseOrPointerEvent
>
305 WidgetMouseOrPointerEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
307 // Warning, this class is serialized and sent over IPC. Any change to its
308 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
310 ButtonType mButtonType
;
311 uint16_t mInputSource
;
314 ParentLayerPoint mLocalOrigin
;
317 * If click event should not be fired in the content after the "mousedown"
318 * event or following "mouseup", set to true.
320 bool mPreventClickEvent
;
321 bool mIgnoreCapturingContent
;
322 bool mSynthesizeMoveAfterDispatch
;
326 * Encapsulation class for pan events, can be used off-main-thread.
327 * These events are currently only used for scrolling on desktop.
329 class PanGestureInput
: public InputData
{
330 friend struct IPC::ParamTraits
<PanGestureInput
>;
333 friend mozilla::layers::APZInputBridgeChild
;
334 friend mozilla::layers::PAPZInputBridgeParent
;
335 ALLOW_DEPRECATED_READPARAM
341 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
343 // MayStart: Dispatched before any actual panning has occurred but when a
344 // pan gesture is probably about to start, for example when the user
345 // starts touching the touchpad. Should interrupt any ongoing APZ
346 // animation and can be used to trigger scrollability indicators (e.g.
347 // flashing overlay scrollbars).
350 // Cancelled: Dispatched after MayStart when no pan gesture is going to
351 // happen after all, for example when the user lifts their fingers from a
352 // touchpad without having done any scrolling.
353 PANGESTURE_CANCELLED
,
355 // Start: A pan gesture is starting.
356 // For devices that do not support the MayStart event type, this event can
357 // be used to interrupt ongoing APZ animations.
360 // Pan: The actual pan motion by mPanDisplacement.
363 // End: The pan gesture has ended, for example because the user has lifted
364 // their fingers from a touchpad after scrolling.
365 // Any potential momentum events fire after this event.
368 // The following momentum event types are used in order to control the pan
369 // momentum animation. Using these instead of our own animation ensures
370 // that the animation curve is OS native and that the animation stops
371 // reliably if it is cancelled by the user.
373 // MomentumStart: Dispatched between the End event of the actual
374 // user-controlled pan, and the first MomentumPan event of the momentum
376 PANGESTURE_MOMENTUMSTART
,
378 // MomentumPan: The actual momentum motion by mPanDisplacement.
379 PANGESTURE_MOMENTUMPAN
,
381 // MomentumEnd: The momentum animation has ended, for example because the
382 // momentum velocity has gone below the stopping threshold, or because the
383 // user has stopped the animation by putting their fingers on a touchpad.
384 PANGESTURE_MOMENTUMEND
,
386 // Interrupted:: A pan gesture started being handled by an APZC but
387 // subsequent pan events might have been consumed by other operations
388 // which haven't been handled by the APZC (e.g. full zoom).
389 PANGESTURE_INTERRUPTED
392 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
394 // There are three kinds of scroll delta modes in Gecko: "page", "line"
395 // and "pixel". Touchpad pan gestures only support "page" and "pixel".
397 // NOTE: PANDELTA_PAGE currently replicates Gtk behavior
398 // (see AsyncPanZoomController::OnPan).
404 PanGestureInput(PanGestureType aType
, TimeStamp aTimeStamp
,
405 const ScreenPoint
& aPanStartPoint
,
406 const ScreenPoint
& aPanDisplacement
, Modifiers aModifiers
);
408 enum class IsEligibleForSwipe
: bool { No
, Yes
};
409 PanGestureInput(PanGestureType aType
, TimeStamp aTimeStamp
,
410 const ScreenPoint
& aPanStartPoint
,
411 const ScreenPoint
& aPanDisplacement
, Modifiers aModifiers
,
412 IsEligibleForSwipe aIsEligibleForSwipe
);
414 void SetLineOrPageDeltas(int32_t aLineOrPageDeltaX
,
415 int32_t aLineOrPageDeltaY
);
417 bool IsMomentum() const;
419 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
421 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
423 ScreenPoint
UserMultipliedPanDisplacement() const;
424 ParentLayerPoint
UserMultipliedLocalPanDisplacement() const;
426 void SetHandledByAPZ(bool aHandled
) { mHandledByAPZ
= aHandled
; }
427 void SetOverscrollBehaviorAllowsSwipe(bool aAllows
) {
428 mOverscrollBehaviorAllowsSwipe
= aAllows
;
430 void SetSimulateMomentum(bool aSimulate
) { mSimulateMomentum
= aSimulate
; }
431 void SetIsNoLineOrPageDelta(bool aIsNoLineOrPageDelta
) {
432 mIsNoLineOrPageDelta
= aIsNoLineOrPageDelta
;
435 // Returns true if this pan gesture event is elligible for browser swipe
436 // gesture considering the overscroll-behavior property of the target
438 bool AllowsSwipe() const {
439 MOZ_ASSERT(mHandledByAPZ
);
440 return mMayTriggerSwipe
&& mOverscrollBehaviorAllowsSwipe
;
443 // Similar to above AllowsSwipe() but this doesn't care the
444 // overscroll-behavior property, this function should be only used for cases
445 // where APZ isn't involved.
446 bool MayTriggerSwipe() const { return mMayTriggerSwipe
; }
447 bool RequiresContentResponseIfCannotScrollHorizontallyInStartDirection();
449 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
451 // Warning, this class is serialized and sent over IPC. Any change to its
452 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
453 PanGestureType mType
;
454 ScreenPoint mPanStartPoint
;
456 // The delta. This can be non-zero on any type of event.
457 ScreenPoint mPanDisplacement
;
459 // Versions of |mPanStartPoint| and |mPanDisplacement| in the local
460 // coordinates of the APZC receiving the pan. These are set and used by APZ.
461 ParentLayerPoint mLocalPanStartPoint
;
462 ParentLayerPoint mLocalPanDisplacement
;
464 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
465 int32_t mLineOrPageDeltaX
;
466 int32_t mLineOrPageDeltaY
;
468 // User-set delta multipliers.
469 double mUserDeltaMultiplierX
;
470 double mUserDeltaMultiplierY
;
472 PanDeltaType mDeltaType
= PANDELTA_PIXEL
;
474 bool mHandledByAPZ
: 1;
476 // This is used by APZ to communicate to widget code whether the
477 // overscroll-behavior of the scroll frame handling this swipe allows
478 // non-local overscroll behaviors in the horizontal direction (such as
479 // swipe navigation).
480 bool mOverscrollBehaviorAllowsSwipe
: 1;
482 // true if APZ should do a fling animation after this pan ends, like
483 // it would with touchscreens. (For platforms that don't emit momentum
485 bool mSimulateMomentum
: 1;
487 // true if the creator of this object does not set the mLineOrPageDeltaX/Y
488 // fields and when/if WidgetWheelEvent's are generated from this object wants
489 // the corresponding mLineOrPageDeltaX/Y fields in the WidgetWheelEvent to be
490 // automatically calculated (upon event dispatch by the EventStateManager
492 bool mIsNoLineOrPageDelta
: 1;
495 // If this is true, and this event started a new input block that couldn't
496 // find a scrollable target which is scrollable in the horizontal component
497 // of the scroll start direction, then this input block needs to be put on
498 // hold until a content response has arrived, even if the block has a
500 // This is used by events that can result in a swipe instead of a scroll.
501 bool mMayTriggerSwipe
: 1;
502 void SetMayTriggerSwipe(bool aValue
) { mMayTriggerSwipe
= aValue
; }
506 * Encapsulation class for pinch events. In general, these will be generated by
507 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
508 * and determining whether or not the user was trying to do a gesture.
510 class PinchGestureInput
: public InputData
{
512 friend mozilla::layers::APZInputBridgeChild
;
513 friend mozilla::layers::PAPZInputBridgeParent
;
514 ALLOW_DEPRECATED_READPARAM
520 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
524 // The FINGERLIFTED state is used when a touch-based pinch gesture is
525 // terminated by lifting one of the two fingers. The position of the
526 // finger that's still down is populated as the focus point.
527 PINCHGESTURE_FINGERLIFTED
,
528 // The END state is used when the pinch gesture is completely terminated.
529 // In this state, the focus point should not be relied upon for having
534 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
535 PinchGestureSource
, (
536 UNKNOWN
, // Default initialization value. Should never actually be used.
537 TOUCH
, // From two-finger pinch gesture
538 ONE_TOUCH
, // From one-finger pinch gesture
539 TRACKPAD
, // From trackpad pinch gesture
540 MOUSEWHEEL
// Synthesized from modifier+mousewheel
542 // If adding more items here, increase n_values for the
543 // APZ_ZOOM_PINCHSOURCE Telemetry metric.
547 // Construct a pinch gesture from a Screen point.
548 PinchGestureInput(PinchGestureType aType
, PinchGestureSource aSource
,
549 TimeStamp aTimeStamp
, const ExternalPoint
& aScreenOffset
,
550 const ScreenPoint
& aFocusPoint
, ScreenCoord aCurrentSpan
,
551 ScreenCoord aPreviousSpan
, Modifiers aModifiers
);
553 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
555 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
557 double ComputeDeltaY(nsIWidget
* aWidget
) const;
559 // Set mLineOrPageDeltaY based on ComputeDeltaY().
560 // Return false if the caller should drop this event to ensure
561 // that preventDefault() is respected. (More specifically, this will be
562 // true for event types other than PINCHGESTURE_END if the computed
563 // mLineOrPageDeltaY is zero. In such cases, the resulting DOMMouseScroll
564 // event will not be dispatched, which is a problem if the page is relying
565 // on DOMMouseScroll to prevent browser zooming).
566 // Note that even if the function returns false, the delta from the event
567 // is accumulated and available to be sent in a later event.
568 bool SetLineOrPageDeltaY(nsIWidget
* aWidget
);
570 static gfx::IntPoint
GetIntegerDeltaForEvent(bool aIsStart
, float x
, float y
);
572 // Warning, this class is serialized and sent over IPC. Any change to its
573 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
574 PinchGestureType mType
;
576 // Some indication of the input device that generated this pinch gesture.
577 PinchGestureSource mSource
;
579 // Center point of the pinch gesture. That is, if there are two fingers on the
580 // screen, it is their midpoint. In the case of more than two fingers, the
581 // point is implementation-specific, but can for example be the midpoint
582 // between the very first and very last touch. This is in device pixels and
583 // are the coordinates on the screen of this midpoint.
584 // For PINCHGESTURE_END events, this may hold the last known focus point or
585 // just be empty; in any case for END events it should not be relied upon.
586 // For PINCHGESTURE_FINGERLIFTED events, this holds the point of the finger
587 // that is still down.
588 ScreenPoint mFocusPoint
;
590 // The screen offset of the root widget. This can be changing along with
591 // the touch interaction, so we sstore it in the event.
592 ExternalPoint mScreenOffset
;
594 // |mFocusPoint| transformed to the local coordinates of the APZC targeted
595 // by the hit. This is set and used by APZ.
596 ParentLayerPoint mLocalFocusPoint
;
598 // The distance between the touches responsible for the pinch gesture.
599 ScreenCoord mCurrentSpan
;
601 // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
602 // This is only really relevant during a PINCHGESTURE_SCALE because when it is
603 // of this type then there must have been a history of spans.
604 ScreenCoord mPreviousSpan
;
606 // We accumulate (via GetIntegerDeltaForEvent) the deltaY that would be
607 // computed by ToWidgetEvent, and then whenever we get a whole integer
608 // value we put it in mLineOrPageDeltaY. Since we only ever use deltaY we
609 // don't need a mLineOrPageDeltaX. This field is used to dispatch legacy mouse
610 // events which are only dispatched when the corresponding field on
611 // WidgetWheelEvent is non-zero.
612 int32_t mLineOrPageDeltaY
;
618 * Encapsulation class for tap events. In general, these will be generated by
619 * a gesture listener by looking at SingleTouchData/MultiTouchInput instances
620 * and determining whether or not the user was trying to do a gesture.
622 class TapGestureInput
: public InputData
{
624 friend mozilla::layers::APZInputBridgeChild
;
625 friend mozilla::layers::PAPZInputBridgeParent
;
626 ALLOW_DEPRECATED_READPARAM
632 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
637 TAPGESTURE_CONFIRMED
,
639 TAPGESTURE_SECOND
, // See GeckoContentController::TapType::eSecondTap
644 // Construct a tap gesture from a Screen point.
645 // mLocalPoint remains (0,0) unless it's set later.
646 TapGestureInput(TapGestureType aType
, TimeStamp aTimeStamp
,
647 const ScreenIntPoint
& aPoint
, Modifiers aModifiers
);
649 // Construct a tap gesture from a ParentLayer point.
650 // mPoint remains (0,0) unless it's set later.
651 TapGestureInput(TapGestureType aType
, TimeStamp aTimeStamp
,
652 const ParentLayerPoint
& aLocalPoint
, Modifiers aModifiers
);
654 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
656 WidgetSimpleGestureEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
658 // Warning, this class is serialized and sent over IPC. Any change to its
659 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
660 TapGestureType mType
;
662 // The location of the tap in screen pixels.
663 ScreenIntPoint mPoint
;
665 // The location of the tap in the local coordinates of the APZC receiving it.
666 // This is set and used by APZ.
667 ParentLayerPoint mLocalPoint
;
670 // Encapsulation class for scroll-wheel events. These are generated by mice
671 // with physical scroll wheels, and on Windows by most touchpads when using
673 class ScrollWheelInput
: public InputData
{
675 friend mozilla::layers::APZInputBridgeChild
;
676 friend mozilla::layers::PAPZInputBridgeParent
;
677 ALLOW_DEPRECATED_READPARAM
679 typedef mozilla::layers::APZWheelAction APZWheelAction
;
685 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
687 // There are three kinds of scroll delta modes in Gecko: "page", "line"
694 MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
702 ScrollWheelInput(TimeStamp aTimeStamp
, Modifiers aModifiers
,
703 ScrollMode aScrollMode
, ScrollDeltaType aDeltaType
,
704 const ScreenPoint
& aOrigin
, double aDeltaX
, double aDeltaY
,
705 bool aAllowToOverrideSystemScrollSpeed
,
706 WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy
);
707 explicit ScrollWheelInput(const WidgetWheelEvent
& aEvent
);
709 static ScrollDeltaType
DeltaTypeForDeltaMode(uint32_t aDeltaMode
);
710 static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType
);
711 static mozilla::ScrollUnit
ScrollUnitForDeltaType(ScrollDeltaType aDeltaType
);
713 WidgetWheelEvent
ToWidgetEvent(nsIWidget
* aWidget
) const;
714 bool TransformToLocal(const ScreenToParentLayerMatrix4x4
& aTransform
);
716 bool IsCustomizedByUserPrefs() const;
718 // The following two functions are for auto-dir scrolling. For detailed
719 // information on auto-dir, @see mozilla::WheelDeltaAdjustmentStrategy
720 bool IsAutoDir(bool aForce
= false) const {
725 switch (mWheelDeltaAdjustmentStrategy
) {
726 case WheelDeltaAdjustmentStrategy::eAutoDir
:
727 case WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
:
730 // Prevent compilation errors generated by -Werror=switch
735 // Indicates which element this scroll honours if it's an auto-dir scroll.
736 // If true, honour the root element; otherwise, honour the currently scrolling
738 // Note that if IsAutoDir() returns false, then this function also returns
739 // false, but false in this case is meaningless as IsAutoDir() indicates it's
740 // not an auto-dir scroll.
741 // For detailed information on auto-dir,
742 // @see mozilla::WheelDeltaAdjustmentStrategy
743 bool HonoursRoot(bool aForce
= false) const {
744 return WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour
==
745 mWheelDeltaAdjustmentStrategy
||
749 // Warning, this class is serialized and sent over IPC. Any change to its
750 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
751 ScrollDeltaType mDeltaType
;
752 ScrollMode mScrollMode
;
757 // Deltas are in units corresponding to the delta type. For line deltas, they
758 // are the number of line units to scroll. The number of device pixels for a
759 // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
760 // For pixel deltas, these values are in ScreenCoords.
762 // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
763 // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
768 // The number of scroll wheel ticks.
769 double mWheelTicksX
= 0.0;
770 double mWheelTicksY
= 0.0;
772 // The location of the scroll in local coordinates. This is set and used by
774 ParentLayerPoint mLocalOrigin
;
776 // See lineOrPageDeltaX/Y on WidgetWheelEvent.
777 int32_t mLineOrPageDeltaX
;
778 int32_t mLineOrPageDeltaY
;
780 // Indicates the order in which this event was added to a transaction. The
781 // first event is 1; if not a member of a transaction, this is 0.
782 uint32_t mScrollSeriesNumber
;
784 // User-set delta multipliers.
785 double mUserDeltaMultiplierX
;
786 double mUserDeltaMultiplierY
;
788 bool mMayHaveMomentum
;
790 bool mAllowToOverrideSystemScrollSpeed
;
792 // Sometimes a wheel event input's wheel delta should be adjusted. This member
793 // specifies how to adjust the wheel delta.
794 WheelDeltaAdjustmentStrategy mWheelDeltaAdjustmentStrategy
;
796 APZWheelAction mAPZAction
;
799 class KeyboardInput
: public InputData
{
801 typedef mozilla::layers::KeyboardScrollAction KeyboardScrollAction
;
803 // Note that if you change the first member in this enum(I.e. KEY_DOWN) to one
804 // other member, don't forget to update the minimum value in
805 // ContiguousEnumSerializer for KeyboardEventType in widget/nsGUIEventIPC
807 enum KeyboardEventType
{
811 // Any other key event such as eAccessKeyNotFound
814 // Used as an upper bound for ContiguousEnumSerializer
818 explicit KeyboardInput(const WidgetKeyboardEvent
& aEvent
);
820 // Warning, this class is serialized and sent over IPC. Any change to its
821 // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
823 KeyboardEventType mType
;
826 CopyableTArray
<ShortcutKeyCandidate
> mShortcutCandidates
;
830 // The scroll action to perform on a layer for this keyboard input. This is
831 // only used in APZ and is NOT serialized over IPC.
832 KeyboardScrollAction mAction
;
835 friend mozilla::layers::APZInputBridgeChild
;
836 friend mozilla::layers::PAPZInputBridgeParent
;
837 ALLOW_DEPRECATED_READPARAM
842 } // namespace mozilla
844 #endif // InputData_h__