1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_MouseEvents_h__
7 #define mozilla_MouseEvents_h__
11 #include "mozilla/BasicEvents.h"
12 #include "mozilla/MathAlgorithms.h"
13 #include "mozilla/dom/DataTransfer.h"
14 #include "mozilla/ipc/IPCForwards.h"
22 class PBrowserBridgeParent
;
25 class WidgetPointerEvent
;
26 } // namespace mozilla
29 class WidgetPointerEventHolder final
{
31 nsTArray
<WidgetPointerEvent
> mEvents
;
32 NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder
)
35 virtual ~WidgetPointerEventHolder() = default;
38 /******************************************************************************
39 * mozilla::WidgetPointerHelper
40 ******************************************************************************/
42 class WidgetPointerHelper
{
48 float tangentialPressure
;
49 bool convertToPointer
;
50 RefPtr
<WidgetPointerEventHolder
> mCoalescedWidgetEvents
;
57 tangentialPressure(0),
58 convertToPointer(true) {}
60 WidgetPointerHelper(uint32_t aPointerId
, uint32_t aTiltX
, uint32_t aTiltY
,
61 uint32_t aTwist
= 0, float aTangentialPressure
= 0)
62 : pointerId(aPointerId
),
66 tangentialPressure(aTangentialPressure
),
67 convertToPointer(true) {}
69 explicit WidgetPointerHelper(const WidgetPointerHelper
& aHelper
) = default;
71 void AssignPointerHelperData(const WidgetPointerHelper
& aEvent
,
72 bool aCopyCoalescedEvents
= false) {
73 pointerId
= aEvent
.pointerId
;
77 tangentialPressure
= aEvent
.tangentialPressure
;
78 convertToPointer
= aEvent
.convertToPointer
;
79 if (aCopyCoalescedEvents
) {
80 mCoalescedWidgetEvents
= aEvent
.mCoalescedWidgetEvents
;
85 /******************************************************************************
86 * mozilla::WidgetMouseEventBase
87 ******************************************************************************/
89 class WidgetMouseEventBase
: public WidgetInputEvent
{
91 friend class dom::PBrowserParent
;
92 friend class dom::PBrowserChild
;
93 friend class dom::PBrowserBridgeParent
;
94 ALLOW_DEPRECATED_READPARAM
97 WidgetMouseEventBase()
101 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
102 // Including MouseEventBinding.h here leads to an include loop, so
103 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
105 WidgetMouseEventBase(bool aIsTrusted
, EventMessage aMessage
,
106 nsIWidget
* aWidget
, EventClassID aEventClassID
,
107 const WidgetEventTime
* aTime
= nullptr)
108 : WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, aEventClassID
, aTime
),
112 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
113 // Including MouseEventBinding.h here leads to an include loop, so
114 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
117 virtual WidgetMouseEventBase
* AsMouseEventBase() override
{ return this; }
119 virtual WidgetEvent
* Duplicate() const override
{
120 MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
123 // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
126 // Pressed button ID of mousedown or mouseup event.
127 // This is set only when pressing a button causes the event.
130 // Flags of all pressed buttons at the event fired.
131 // This is set at any mouse event, don't be confused with |mButton|.
134 // Possible values a in MouseEvent
135 uint16_t mInputSource
;
137 bool IsLeftButtonPressed() const {
138 return !!(mButtons
& MouseButtonsFlag::ePrimaryFlag
);
140 bool IsRightButtonPressed() const {
141 return !!(mButtons
& MouseButtonsFlag::eSecondaryFlag
);
143 bool IsMiddleButtonPressed() const {
144 return !!(mButtons
& MouseButtonsFlag::eMiddleFlag
);
146 bool Is4thButtonPressed() const {
147 return !!(mButtons
& MouseButtonsFlag::e4thFlag
);
149 bool Is5thButtonPressed() const {
150 return !!(mButtons
& MouseButtonsFlag::e5thFlag
);
153 void AssignMouseEventBaseData(const WidgetMouseEventBase
& aEvent
,
155 AssignInputEventData(aEvent
, aCopyTargets
);
157 mButton
= aEvent
.mButton
;
158 mButtons
= aEvent
.mButtons
;
159 mPressure
= aEvent
.mPressure
;
160 mInputSource
= aEvent
.mInputSource
;
164 * Returns true if left click event.
166 bool IsLeftClickEvent() const {
167 return mMessage
== eMouseClick
&& mButton
== MouseButton::ePrimary
;
171 /******************************************************************************
172 * mozilla::WidgetMouseEvent
173 ******************************************************************************/
175 class WidgetMouseEvent
: public WidgetMouseEventBase
,
176 public WidgetPointerHelper
{
178 friend class dom::PBrowserParent
;
179 friend class dom::PBrowserChild
;
180 friend class dom::PBrowserBridgeParent
;
181 ALLOW_DEPRECATED_READPARAM
184 typedef bool ReasonType
;
185 enum Reason
: ReasonType
{ eReal
, eSynthesized
};
187 typedef uint8_t ContextMenuTriggerType
;
188 enum ContextMenuTrigger
: ContextMenuTriggerType
{
194 typedef uint8_t ExitFromType
;
195 enum ExitFrom
: ExitFromType
{
199 ePuppetParentToPuppetChild
205 mContextMenuTrigger(eNormal
),
207 mIgnoreRootScrollFrame(false),
208 mUseLegacyNonPrimaryDispatch(false),
209 mClickEventPrevented(false) {}
211 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
212 EventClassID aEventClassID
, Reason aReason
,
213 const WidgetEventTime
* aTime
= nullptr)
214 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
,
217 mContextMenuTrigger(eNormal
),
219 mIgnoreRootScrollFrame(false),
220 mUseLegacyNonPrimaryDispatch(false),
221 mClickEventPrevented(false) {}
224 void AssertContextMenuEventButtonConsistency() const;
228 virtual WidgetMouseEvent
* AsMouseEvent() override
{ return this; }
230 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
232 ContextMenuTrigger aContextMenuTrigger
= eNormal
,
233 const WidgetEventTime
* aTime
= nullptr)
234 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eMouseEventClass
,
237 mContextMenuTrigger(aContextMenuTrigger
),
239 mIgnoreRootScrollFrame(false),
240 mUseLegacyNonPrimaryDispatch(false),
241 mClickEventPrevented(false) {
242 if (aMessage
== eContextMenu
) {
243 mButton
= (mContextMenuTrigger
== eNormal
) ? MouseButton::eSecondary
244 : MouseButton::ePrimary
;
249 virtual ~WidgetMouseEvent() { AssertContextMenuEventButtonConsistency(); }
252 virtual WidgetEvent
* Duplicate() const override
{
253 MOZ_ASSERT(mClass
== eMouseEventClass
,
254 "Duplicate() must be overridden by sub class");
255 // Not copying widget, it is a weak reference.
256 WidgetMouseEvent
* result
= new WidgetMouseEvent(
257 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
, this);
258 result
->AssignMouseEventData(*this, true);
259 result
->mFlags
= mFlags
;
263 // If during mouseup handling we detect that click event might need to be
264 // dispatched, this is setup to be the target of the click event.
265 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
267 // mReason indicates the reason why the event is fired:
268 // - Representing mouse operation.
269 // - Synthesized for emulating mousemove event when the content under the
270 // mouse cursor is scrolled.
273 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
274 // This indicates if the context menu event is caused by context menu key or
275 // other reasons (typically, a click of right mouse button).
276 ContextMenuTrigger mContextMenuTrigger
;
278 // mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
279 // This indicates if the mouse cursor exits from a top level platform widget,
280 // a child widget or a puppet widget.
281 Maybe
<ExitFrom
> mExitFrom
;
283 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
284 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
285 // Otherwise, this must be 0.
286 uint32_t mClickCount
;
288 // Whether the event should ignore scroll frame bounds during dispatch.
289 bool mIgnoreRootScrollFrame
;
291 // Indicates whether the event should dispatch click events for non-primary
292 // mouse buttons on window and document.
293 bool mUseLegacyNonPrimaryDispatch
;
295 // Whether the event shouldn't cause click event.
296 bool mClickEventPrevented
;
298 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
299 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
300 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
302 mExitFrom
= aEvent
.mExitFrom
;
303 mClickCount
= aEvent
.mClickCount
;
304 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
305 mUseLegacyNonPrimaryDispatch
= aEvent
.mUseLegacyNonPrimaryDispatch
;
306 mClickEventPrevented
= aEvent
.mClickEventPrevented
;
310 * Returns true if the event is a context menu event caused by key.
312 bool IsContextMenuKeyEvent() const {
313 return mMessage
== eContextMenu
&& mContextMenuTrigger
== eContextMenuKey
;
317 * Returns true if the event is a real mouse event. Otherwise, i.e., it's
318 * a synthesized event by scroll or something, returns false.
320 bool IsReal() const { return mReason
== eReal
; }
323 * Returns true if middle click paste is enabled.
325 static bool IsMiddleClickPasteEnabled();
328 /******************************************************************************
329 * mozilla::WidgetDragEvent
330 ******************************************************************************/
332 class WidgetDragEvent
: public WidgetMouseEvent
{
334 friend class mozilla::dom::PBrowserParent
;
335 friend class mozilla::dom::PBrowserChild
;
336 ALLOW_DEPRECATED_READPARAM
340 : mUserCancelled(false), mDefaultPreventedOnContent(false) {}
343 virtual WidgetDragEvent
* AsDragEvent() override
{ return this; }
345 WidgetDragEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
346 const WidgetEventTime
* aTime
= nullptr)
347 : WidgetMouseEvent(aIsTrusted
, aMessage
, aWidget
, eDragEventClass
, eReal
,
349 mUserCancelled(false),
350 mDefaultPreventedOnContent(false),
351 mInHTMLEditorEventListener(false) {}
353 virtual WidgetEvent
* Duplicate() const override
{
354 MOZ_ASSERT(mClass
== eDragEventClass
,
355 "Duplicate() must be overridden by sub class");
356 // Not copying widget, it is a weak reference.
357 WidgetDragEvent
* result
=
358 new WidgetDragEvent(false, mMessage
, nullptr, this);
359 result
->AssignDragEventData(*this, true);
360 result
->mFlags
= mFlags
;
364 // The dragging data.
365 nsCOMPtr
<dom::DataTransfer
> mDataTransfer
;
367 // If this is true, user has cancelled the drag operation.
369 // If this is true, the drag event's preventDefault() is called on content.
370 bool mDefaultPreventedOnContent
;
371 // If this event is currently being handled by HTMLEditorEventListener.
372 bool mInHTMLEditorEventListener
;
374 // XXX Not tested by test_assign_event_data.html
375 void AssignDragEventData(const WidgetDragEvent
& aEvent
, bool aCopyTargets
) {
376 AssignMouseEventData(aEvent
, aCopyTargets
);
378 mDataTransfer
= aEvent
.mDataTransfer
;
379 // XXX mUserCancelled isn't copied, is this intentionally?
380 mUserCancelled
= false;
381 mDefaultPreventedOnContent
= aEvent
.mDefaultPreventedOnContent
;
385 * Should be called before dispatching the DOM tree if this event is
386 * synthesized for tests because drop effect is initialized before
387 * dispatching from widget if it's not synthesized event, but synthesized
388 * events are not initialized in the path.
390 void InitDropEffectForTests();
393 /******************************************************************************
394 * mozilla::WidgetMouseScrollEvent
396 * This is used for legacy DOM mouse scroll events, i.e.,
397 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
398 * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
399 ******************************************************************************/
401 class WidgetMouseScrollEvent
: public WidgetMouseEventBase
{
403 WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
406 virtual WidgetMouseScrollEvent
* AsMouseScrollEvent() override
{ return this; }
408 WidgetMouseScrollEvent(bool aIsTrusted
, EventMessage aMessage
,
410 const WidgetEventTime
* aTime
= nullptr)
411 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
412 eMouseScrollEventClass
, aTime
),
414 mIsHorizontal(false) {}
416 virtual WidgetEvent
* Duplicate() const override
{
417 MOZ_ASSERT(mClass
== eMouseScrollEventClass
,
418 "Duplicate() must be overridden by sub class");
419 // Not copying widget, it is a weak reference.
420 WidgetMouseScrollEvent
* result
=
421 new WidgetMouseScrollEvent(false, mMessage
, nullptr, this);
422 result
->AssignMouseScrollEventData(*this, true);
423 result
->mFlags
= mFlags
;
427 // The delta value of mouse scroll event.
428 // If the event message is eLegacyMouseLineOrPageScroll, the value indicates
429 // scroll amount in lines. However, if the value is
430 // UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
431 // value inducates one page scroll. If the event message is
432 // eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
435 // If this is true, it may cause to scroll horizontally.
436 // Otherwise, vertically.
439 void AssignMouseScrollEventData(const WidgetMouseScrollEvent
& aEvent
,
441 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
443 mDelta
= aEvent
.mDelta
;
444 mIsHorizontal
= aEvent
.mIsHorizontal
;
448 /******************************************************************************
449 * mozilla::WidgetWheelEvent
450 ******************************************************************************/
452 class WidgetWheelEvent
: public WidgetMouseEventBase
{
454 friend class mozilla::dom::PBrowserParent
;
455 friend class mozilla::dom::PBrowserChild
;
456 ALLOW_DEPRECATED_READPARAM
462 mOverflowDeltaX(0.0),
464 // Including WheelEventBinding.h here leads to an include loop, so
465 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
467 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
468 mLineOrPageDeltaX(0),
469 mLineOrPageDeltaY(0),
470 mScrollType(SCROLL_DEFAULT
),
471 mCustomizedByUserPrefs(false),
472 mMayHaveMomentum(false),
474 mIsNoLineOrPageDelta(false),
475 mViewPortIsOverscrolled(false),
476 mCanTriggerSwipe(false),
477 mAllowToOverrideSystemScrollSpeed(false),
478 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
481 virtual WidgetWheelEvent
* AsWheelEvent() override
{ return this; }
483 WidgetWheelEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
484 const WidgetEventTime
* aTime
= nullptr)
485 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eWheelEventClass
,
490 mOverflowDeltaX(0.0),
492 // Including WheelEventBinding.h here leads to an include loop, so
493 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
495 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
496 mLineOrPageDeltaX(0),
497 mLineOrPageDeltaY(0),
498 mScrollType(SCROLL_DEFAULT
),
499 mCustomizedByUserPrefs(false),
500 mMayHaveMomentum(false),
502 mIsNoLineOrPageDelta(false),
503 mViewPortIsOverscrolled(false),
504 mCanTriggerSwipe(false),
505 mAllowToOverrideSystemScrollSpeed(true),
506 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
508 virtual WidgetEvent
* Duplicate() const override
{
509 MOZ_ASSERT(mClass
== eWheelEventClass
,
510 "Duplicate() must be overridden by sub class");
511 // Not copying widget, it is a weak reference.
512 WidgetWheelEvent
* result
=
513 new WidgetWheelEvent(false, mMessage
, nullptr, this);
514 result
->AssignWheelEventData(*this, true);
515 result
->mFlags
= mFlags
;
519 // Scroll gestures that start at the edge of the scrollable range can result
520 // in a swipe gesture. For the first wheel event of such a gesture, call
521 // TriggersSwipe() after the event has been processed in order to find out
522 // whether a swipe should be started.
523 bool TriggersSwipe() const {
524 return mCanTriggerSwipe
&& mViewPortIsOverscrolled
&&
525 this->mOverflowDeltaX
!= 0.0;
528 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
529 // mousewheel.*.delta_multiplier_* prefs which are applied by
530 // EventStateManager. So, after widget dispatches this event,
531 // these delta values may have different values than before.
536 // The mousewheel tick counts.
537 double mWheelTicksX
= 0.0;
538 double mWheelTicksY
= 0.0;
540 enum class DeltaModeCheckingState
: uint8_t {
541 // Neither deltaMode nor the delta values have been accessed.
543 // The delta values have been accessed, without checking deltaMode first.
545 // The deltaMode has been checked.
549 // For compat reasons, we might expose a DOM_DELTA_LINE event as
550 // DOM_DELTA_PIXEL instead. Whether we do that depends on whether the event
551 // has been asked for the deltaMode before the deltas. If it has, we assume
552 // that the page will correctly handle DOM_DELTA_LINE. This variable tracks
553 // that state. See bug 1392460.
554 DeltaModeCheckingState mDeltaModeCheckingState
=
555 DeltaModeCheckingState::Unknown
;
557 // The amount of scrolling per line or page, without accounting for mouse
558 // wheel transactions etc.
560 // Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
561 nsSize mScrollAmount
;
563 // overflowed delta values for scroll, these values are set by
564 // EventStateManger. If the default action of the wheel event isn't scroll,
565 // these values are always zero. Otherwise, remaining delta values which are
566 // not used by scroll are set.
567 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
568 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
569 // delta values which are not applied the delta_multiplier prefs.
570 // So, if widget wanted to know the actual direction to be scrolled,
571 // it would need to check the mDeltaX and mDeltaY.
572 double mOverflowDeltaX
;
573 double mOverflowDeltaY
;
575 // Should be one of WheelEvent_Binding::DOM_DELTA_*
578 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
579 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
580 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
581 int32_t mLineOrPageDeltaX
;
582 int32_t mLineOrPageDeltaY
;
584 // When the default action for an wheel event is moving history or zooming,
585 // need to chose a delta value for doing it.
586 int32_t GetPreferredIntDelta() {
587 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
590 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
591 return mLineOrPageDeltaY
;
593 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
594 return mLineOrPageDeltaX
;
596 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
597 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
598 return 0; // We cannot guess the answer in this case.
600 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
606 // The default value is SCROLL_DEFAULT, which means EventStateManager will
607 // select preferred scroll type automatically.
608 enum ScrollType
: uint8_t {
610 SCROLL_SYNCHRONOUSLY
,
611 SCROLL_ASYNCHRONOUSLY
,
614 ScrollType mScrollType
;
616 // If the delta values are computed from prefs, this value is true.
617 // Otherwise, i.e., they are computed from native events, false.
618 bool mCustomizedByUserPrefs
;
620 // true if the momentum events directly tied to this event may follow it.
621 bool mMayHaveMomentum
;
622 // true if the event is caused by momentum.
625 // If device event handlers don't know when they should set mLineOrPageDeltaX
626 // and mLineOrPageDeltaY, this is true. Otherwise, false.
627 // If mIsNoLineOrPageDelta is true, ESM will generate
628 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
630 bool mIsNoLineOrPageDelta
;
632 // Whether or not the parent of the currently overscrolled frame is the
633 // ViewPort. This is false in situations when an element on the page is being
634 // overscrolled (such as a text field), but true when the 'page' is being
636 bool mViewPortIsOverscrolled
;
638 // The wheel event can trigger a swipe to start if it's overscrolling the
640 bool mCanTriggerSwipe
;
642 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
643 // overridden. Otherwise, the scroll speed won't be overridden even if
644 // it's enabled by the pref.
645 bool mAllowToOverrideSystemScrollSpeed
;
647 // After the event's default action handler has adjusted its delta's values
648 // for horizontalizing a vertical wheel scroll, this variable will be set to
650 bool mDeltaValuesHorizontalizedForDefaultHandler
;
652 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
653 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
655 mDeltaX
= aEvent
.mDeltaX
;
656 mDeltaY
= aEvent
.mDeltaY
;
657 mDeltaZ
= aEvent
.mDeltaZ
;
658 mDeltaMode
= aEvent
.mDeltaMode
;
659 mScrollAmount
= aEvent
.mScrollAmount
;
660 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
661 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
662 mIsMomentum
= aEvent
.mIsMomentum
;
663 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
664 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
665 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
666 mScrollType
= aEvent
.mScrollType
;
667 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
668 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
669 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
670 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
671 mAllowToOverrideSystemScrollSpeed
=
672 aEvent
.mAllowToOverrideSystemScrollSpeed
;
673 mDeltaValuesHorizontalizedForDefaultHandler
=
674 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
677 // System scroll speed settings may be too slow at using Gecko. In such
678 // case, we should override the scroll speed computed with system settings.
679 // Following methods return preferred delta values which are multiplied by
680 // factors specified by prefs. If system scroll speed shouldn't be
681 // overridden (e.g., this feature is disabled by pref), they return raw
683 double OverriddenDeltaX() const;
684 double OverriddenDeltaY() const;
686 // Compute the overridden delta value. This may be useful for suppressing
687 // too fast scroll by system scroll speed overriding when widget sets
688 // mAllowToOverrideSystemScrollSpeed.
689 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
692 static bool sInitialized
;
693 static bool sIsSystemScrollSpeedOverrideEnabled
;
694 static int32_t sOverrideFactorX
;
695 static int32_t sOverrideFactorY
;
696 static void Initialize();
699 /******************************************************************************
700 * mozilla::WidgetPointerEvent
701 ******************************************************************************/
703 class WidgetPointerEvent
: public WidgetMouseEvent
{
704 friend class mozilla::dom::PBrowserParent
;
705 friend class mozilla::dom::PBrowserChild
;
706 ALLOW_DEPRECATED_READPARAM
709 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
711 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
,
712 const WidgetEventTime
* aTime
= nullptr)
713 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
, aTime
),
717 mFromTouchEvent(false) {}
719 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
720 : WidgetMouseEvent(aEvent
),
724 mFromTouchEvent(false) {
725 mClass
= ePointerEventClass
;
728 virtual WidgetEvent
* Duplicate() const override
{
729 MOZ_ASSERT(mClass
== ePointerEventClass
,
730 "Duplicate() must be overridden by sub class");
731 // Not copying widget, it is a weak reference.
732 WidgetPointerEvent
* result
=
733 new WidgetPointerEvent(false, mMessage
, nullptr, this);
734 result
->AssignPointerEventData(*this, true);
735 result
->mFlags
= mFlags
;
742 bool mFromTouchEvent
;
744 // XXX Not tested by test_assign_event_data.html
745 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
747 AssignMouseEventData(aEvent
, aCopyTargets
);
749 mWidth
= aEvent
.mWidth
;
750 mHeight
= aEvent
.mHeight
;
751 mIsPrimary
= aEvent
.mIsPrimary
;
752 mFromTouchEvent
= aEvent
.mFromTouchEvent
;
756 } // namespace mozilla
758 #endif // mozilla_MouseEvents_h__