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 : WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
111 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
112 // Including MouseEventBinding.h here leads to an include loop, so
113 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
116 virtual WidgetMouseEventBase
* AsMouseEventBase() override
{ return this; }
118 virtual WidgetEvent
* Duplicate() const override
{
119 MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
122 // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
125 // Pressed button ID of mousedown or mouseup event.
126 // This is set only when pressing a button causes the event.
129 // Flags of all pressed buttons at the event fired.
130 // This is set at any mouse event, don't be confused with |mButton|.
133 // Possible values a in MouseEvent
134 uint16_t mInputSource
;
136 bool IsLeftButtonPressed() const {
137 return !!(mButtons
& MouseButtonsFlag::ePrimaryFlag
);
139 bool IsRightButtonPressed() const {
140 return !!(mButtons
& MouseButtonsFlag::eSecondaryFlag
);
142 bool IsMiddleButtonPressed() const {
143 return !!(mButtons
& MouseButtonsFlag::eMiddleFlag
);
145 bool Is4thButtonPressed() const {
146 return !!(mButtons
& MouseButtonsFlag::e4thFlag
);
148 bool Is5thButtonPressed() const {
149 return !!(mButtons
& MouseButtonsFlag::e5thFlag
);
152 void AssignMouseEventBaseData(const WidgetMouseEventBase
& aEvent
,
154 AssignInputEventData(aEvent
, aCopyTargets
);
156 mButton
= aEvent
.mButton
;
157 mButtons
= aEvent
.mButtons
;
158 mPressure
= aEvent
.mPressure
;
159 mInputSource
= aEvent
.mInputSource
;
163 * Returns true if left click event.
165 bool IsLeftClickEvent() const {
166 return mMessage
== eMouseClick
&& mButton
== MouseButton::ePrimary
;
170 /******************************************************************************
171 * mozilla::WidgetMouseEvent
172 ******************************************************************************/
174 class WidgetMouseEvent
: public WidgetMouseEventBase
,
175 public WidgetPointerHelper
{
177 friend class dom::PBrowserParent
;
178 friend class dom::PBrowserChild
;
179 friend class dom::PBrowserBridgeParent
;
180 ALLOW_DEPRECATED_READPARAM
183 typedef bool ReasonType
;
184 enum Reason
: ReasonType
{ eReal
, eSynthesized
};
186 typedef uint8_t ContextMenuTriggerType
;
187 enum ContextMenuTrigger
: ContextMenuTriggerType
{
193 typedef uint8_t ExitFromType
;
194 enum ExitFrom
: ExitFromType
{
198 ePuppetParentToPuppetChild
204 mContextMenuTrigger(eNormal
),
206 mIgnoreRootScrollFrame(false),
207 mUseLegacyNonPrimaryDispatch(false),
208 mClickEventPrevented(false) {}
210 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
211 EventClassID aEventClassID
, Reason aReason
)
212 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
214 mContextMenuTrigger(eNormal
),
216 mIgnoreRootScrollFrame(false),
217 mUseLegacyNonPrimaryDispatch(false),
218 mClickEventPrevented(false) {}
221 void AssertContextMenuEventButtonConsistency() const;
225 virtual WidgetMouseEvent
* AsMouseEvent() override
{ return this; }
227 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
229 ContextMenuTrigger aContextMenuTrigger
= eNormal
)
230 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eMouseEventClass
),
232 mContextMenuTrigger(aContextMenuTrigger
),
234 mIgnoreRootScrollFrame(false),
235 mUseLegacyNonPrimaryDispatch(false),
236 mClickEventPrevented(false) {
237 if (aMessage
== eContextMenu
) {
238 mButton
= (mContextMenuTrigger
== eNormal
) ? MouseButton::eSecondary
239 : MouseButton::ePrimary
;
244 virtual ~WidgetMouseEvent() { AssertContextMenuEventButtonConsistency(); }
247 virtual WidgetEvent
* Duplicate() const override
{
248 MOZ_ASSERT(mClass
== eMouseEventClass
,
249 "Duplicate() must be overridden by sub class");
250 // Not copying widget, it is a weak reference.
251 WidgetMouseEvent
* result
= new WidgetMouseEvent(
252 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
);
253 result
->AssignMouseEventData(*this, true);
254 result
->mFlags
= mFlags
;
258 // If during mouseup handling we detect that click event might need to be
259 // dispatched, this is setup to be the target of the click event.
260 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
262 // mReason indicates the reason why the event is fired:
263 // - Representing mouse operation.
264 // - Synthesized for emulating mousemove event when the content under the
265 // mouse cursor is scrolled.
268 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
269 // This indicates if the context menu event is caused by context menu key or
270 // other reasons (typically, a click of right mouse button).
271 ContextMenuTrigger mContextMenuTrigger
;
273 // mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
274 // This indicates if the mouse cursor exits from a top level platform widget,
275 // a child widget or a puppet widget.
276 Maybe
<ExitFrom
> mExitFrom
;
278 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
279 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
280 // Otherwise, this must be 0.
281 uint32_t mClickCount
;
283 // Whether the event should ignore scroll frame bounds during dispatch.
284 bool mIgnoreRootScrollFrame
;
286 // Indicates whether the event should dispatch click events for non-primary
287 // mouse buttons on window and document.
288 bool mUseLegacyNonPrimaryDispatch
;
290 // Whether the event shouldn't cause click event.
291 bool mClickEventPrevented
;
293 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
294 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
295 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
297 mExitFrom
= aEvent
.mExitFrom
;
298 mClickCount
= aEvent
.mClickCount
;
299 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
300 mUseLegacyNonPrimaryDispatch
= aEvent
.mUseLegacyNonPrimaryDispatch
;
301 mClickEventPrevented
= aEvent
.mClickEventPrevented
;
305 * Returns true if the event is a context menu event caused by key.
307 bool IsContextMenuKeyEvent() const {
308 return mMessage
== eContextMenu
&& mContextMenuTrigger
== eContextMenuKey
;
312 * Returns true if the event is a real mouse event. Otherwise, i.e., it's
313 * a synthesized event by scroll or something, returns false.
315 bool IsReal() const { return mReason
== eReal
; }
318 * Returns true if middle click paste is enabled.
320 static bool IsMiddleClickPasteEnabled();
323 /******************************************************************************
324 * mozilla::WidgetDragEvent
325 ******************************************************************************/
327 class WidgetDragEvent
: public WidgetMouseEvent
{
329 friend class mozilla::dom::PBrowserParent
;
330 friend class mozilla::dom::PBrowserChild
;
331 ALLOW_DEPRECATED_READPARAM
335 : mUserCancelled(false), mDefaultPreventedOnContent(false) {}
338 virtual WidgetDragEvent
* AsDragEvent() override
{ return this; }
340 WidgetDragEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
341 : WidgetMouseEvent(aIsTrusted
, aMessage
, aWidget
, eDragEventClass
, eReal
),
342 mUserCancelled(false),
343 mDefaultPreventedOnContent(false) {}
345 virtual WidgetEvent
* Duplicate() const override
{
346 MOZ_ASSERT(mClass
== eDragEventClass
,
347 "Duplicate() must be overridden by sub class");
348 // Not copying widget, it is a weak reference.
349 WidgetDragEvent
* result
= new WidgetDragEvent(false, mMessage
, nullptr);
350 result
->AssignDragEventData(*this, true);
351 result
->mFlags
= mFlags
;
355 // The dragging data.
356 nsCOMPtr
<dom::DataTransfer
> mDataTransfer
;
358 // If this is true, user has cancelled the drag operation.
360 // If this is true, the drag event's preventDefault() is called on content.
361 bool mDefaultPreventedOnContent
;
363 // XXX Not tested by test_assign_event_data.html
364 void AssignDragEventData(const WidgetDragEvent
& aEvent
, bool aCopyTargets
) {
365 AssignMouseEventData(aEvent
, aCopyTargets
);
367 mDataTransfer
= aEvent
.mDataTransfer
;
368 // XXX mUserCancelled isn't copied, is this intentionally?
369 mUserCancelled
= false;
370 mDefaultPreventedOnContent
= aEvent
.mDefaultPreventedOnContent
;
373 void UpdateDefaultPreventedOnContent(dom::EventTarget
* aTarget
);
376 * Should be called before dispatching the DOM tree if this event is
377 * synthesized for tests because drop effect is initialized before
378 * dispatching from widget if it's not synthesized event, but synthesized
379 * events are not initialized in the path.
381 void InitDropEffectForTests();
384 /******************************************************************************
385 * mozilla::WidgetMouseScrollEvent
387 * This is used for legacy DOM mouse scroll events, i.e.,
388 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
389 * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
390 ******************************************************************************/
392 class WidgetMouseScrollEvent
: public WidgetMouseEventBase
{
394 WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
397 virtual WidgetMouseScrollEvent
* AsMouseScrollEvent() override
{ return this; }
399 WidgetMouseScrollEvent(bool aIsTrusted
, EventMessage aMessage
,
401 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
402 eMouseScrollEventClass
),
404 mIsHorizontal(false) {}
406 virtual WidgetEvent
* Duplicate() const override
{
407 MOZ_ASSERT(mClass
== eMouseScrollEventClass
,
408 "Duplicate() must be overridden by sub class");
409 // Not copying widget, it is a weak reference.
410 WidgetMouseScrollEvent
* result
=
411 new WidgetMouseScrollEvent(false, mMessage
, nullptr);
412 result
->AssignMouseScrollEventData(*this, true);
413 result
->mFlags
= mFlags
;
417 // The delta value of mouse scroll event.
418 // If the event message is eLegacyMouseLineOrPageScroll, the value indicates
419 // scroll amount in lines. However, if the value is
420 // UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
421 // value inducates one page scroll. If the event message is
422 // eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
425 // If this is true, it may cause to scroll horizontally.
426 // Otherwise, vertically.
429 void AssignMouseScrollEventData(const WidgetMouseScrollEvent
& aEvent
,
431 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
433 mDelta
= aEvent
.mDelta
;
434 mIsHorizontal
= aEvent
.mIsHorizontal
;
438 /******************************************************************************
439 * mozilla::WidgetWheelEvent
440 ******************************************************************************/
442 class WidgetWheelEvent
: public WidgetMouseEventBase
{
444 friend class mozilla::dom::PBrowserParent
;
445 friend class mozilla::dom::PBrowserChild
;
446 ALLOW_DEPRECATED_READPARAM
452 mOverflowDeltaX(0.0),
454 // Including WheelEventBinding.h here leads to an include loop, so
455 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
457 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
458 mLineOrPageDeltaX(0),
459 mLineOrPageDeltaY(0),
460 mScrollType(SCROLL_DEFAULT
),
461 mCustomizedByUserPrefs(false),
462 mMayHaveMomentum(false),
464 mIsNoLineOrPageDelta(false),
465 mViewPortIsOverscrolled(false),
466 mCanTriggerSwipe(false),
467 mAllowToOverrideSystemScrollSpeed(false),
468 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
471 virtual WidgetWheelEvent
* AsWheelEvent() override
{ return this; }
473 WidgetWheelEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
474 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eWheelEventClass
),
478 mOverflowDeltaX(0.0),
480 // Including WheelEventBinding.h here leads to an include loop, so
481 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
483 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
484 mLineOrPageDeltaX(0),
485 mLineOrPageDeltaY(0),
486 mScrollType(SCROLL_DEFAULT
),
487 mCustomizedByUserPrefs(false),
488 mMayHaveMomentum(false),
490 mIsNoLineOrPageDelta(false),
491 mViewPortIsOverscrolled(false),
492 mCanTriggerSwipe(false),
493 mAllowToOverrideSystemScrollSpeed(true),
494 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
496 virtual WidgetEvent
* Duplicate() const override
{
497 MOZ_ASSERT(mClass
== eWheelEventClass
,
498 "Duplicate() must be overridden by sub class");
499 // Not copying widget, it is a weak reference.
500 WidgetWheelEvent
* result
= new WidgetWheelEvent(false, mMessage
, nullptr);
501 result
->AssignWheelEventData(*this, true);
502 result
->mFlags
= mFlags
;
506 // Scroll gestures that start at the edge of the scrollable range can result
507 // in a swipe gesture. For the first wheel event of such a gesture, call
508 // TriggersSwipe() after the event has been processed in order to find out
509 // whether a swipe should be started.
510 bool TriggersSwipe() const {
511 return mCanTriggerSwipe
&& mViewPortIsOverscrolled
&&
512 this->mOverflowDeltaX
!= 0.0;
515 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
516 // mousewheel.*.delta_multiplier_* prefs which are applied by
517 // EventStateManager. So, after widget dispatches this event,
518 // these delta values may have different values than before.
523 // The mousewheel tick counts.
524 double mWheelTicksX
= 0.0;
525 double mWheelTicksY
= 0.0;
527 enum class DeltaModeCheckingState
: uint8_t {
528 // Neither deltaMode nor the delta values have been accessed.
530 // The delta values have been accessed, without checking deltaMode first.
532 // The deltaMode has been checked.
536 // For compat reasons, we might expose a DOM_DELTA_LINE event as
537 // DOM_DELTA_PIXEL instead. Whether we do that depends on whether the event
538 // has been asked for the deltaMode before the deltas. If it has, we assume
539 // that the page will correctly handle DOM_DELTA_LINE. This variable tracks
540 // that state. See bug 1392460.
541 DeltaModeCheckingState mDeltaModeCheckingState
=
542 DeltaModeCheckingState::Unknown
;
544 // The amount of scrolling per line or page, without accounting for mouse
545 // wheel transactions etc.
547 // Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
548 nsSize mScrollAmount
;
550 // overflowed delta values for scroll, these values are set by
551 // EventStateManger. If the default action of the wheel event isn't scroll,
552 // these values are always zero. Otherwise, remaining delta values which are
553 // not used by scroll are set.
554 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
555 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
556 // delta values which are not applied the delta_multiplier prefs.
557 // So, if widget wanted to know the actual direction to be scrolled,
558 // it would need to check the mDeltaX and mDeltaY.
559 double mOverflowDeltaX
;
560 double mOverflowDeltaY
;
562 // Should be one of WheelEvent_Binding::DOM_DELTA_*
565 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
566 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
567 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
568 int32_t mLineOrPageDeltaX
;
569 int32_t mLineOrPageDeltaY
;
571 // When the default action for an wheel event is moving history or zooming,
572 // need to chose a delta value for doing it.
573 int32_t GetPreferredIntDelta() {
574 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
577 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
578 return mLineOrPageDeltaY
;
580 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
581 return mLineOrPageDeltaX
;
583 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
584 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
585 return 0; // We cannot guess the answer in this case.
587 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
593 // The default value is SCROLL_DEFAULT, which means EventStateManager will
594 // select preferred scroll type automatically.
595 enum ScrollType
: uint8_t {
597 SCROLL_SYNCHRONOUSLY
,
598 SCROLL_ASYNCHRONOUSLY
,
601 ScrollType mScrollType
;
603 // If the delta values are computed from prefs, this value is true.
604 // Otherwise, i.e., they are computed from native events, false.
605 bool mCustomizedByUserPrefs
;
607 // true if the momentum events directly tied to this event may follow it.
608 bool mMayHaveMomentum
;
609 // true if the event is caused by momentum.
612 // If device event handlers don't know when they should set mLineOrPageDeltaX
613 // and mLineOrPageDeltaY, this is true. Otherwise, false.
614 // If mIsNoLineOrPageDelta is true, ESM will generate
615 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
617 bool mIsNoLineOrPageDelta
;
619 // Whether or not the parent of the currently overscrolled frame is the
620 // ViewPort. This is false in situations when an element on the page is being
621 // overscrolled (such as a text field), but true when the 'page' is being
623 bool mViewPortIsOverscrolled
;
625 // The wheel event can trigger a swipe to start if it's overscrolling the
627 bool mCanTriggerSwipe
;
629 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
630 // overridden. Otherwise, the scroll speed won't be overridden even if
631 // it's enabled by the pref.
632 bool mAllowToOverrideSystemScrollSpeed
;
634 // After the event's default action handler has adjusted its delta's values
635 // for horizontalizing a vertical wheel scroll, this variable will be set to
637 bool mDeltaValuesHorizontalizedForDefaultHandler
;
639 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
640 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
642 mDeltaX
= aEvent
.mDeltaX
;
643 mDeltaY
= aEvent
.mDeltaY
;
644 mDeltaZ
= aEvent
.mDeltaZ
;
645 mDeltaMode
= aEvent
.mDeltaMode
;
646 mScrollAmount
= aEvent
.mScrollAmount
;
647 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
648 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
649 mIsMomentum
= aEvent
.mIsMomentum
;
650 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
651 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
652 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
653 mScrollType
= aEvent
.mScrollType
;
654 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
655 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
656 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
657 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
658 mAllowToOverrideSystemScrollSpeed
=
659 aEvent
.mAllowToOverrideSystemScrollSpeed
;
660 mDeltaValuesHorizontalizedForDefaultHandler
=
661 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
664 // System scroll speed settings may be too slow at using Gecko. In such
665 // case, we should override the scroll speed computed with system settings.
666 // Following methods return preferred delta values which are multiplied by
667 // factors specified by prefs. If system scroll speed shouldn't be
668 // overridden (e.g., this feature is disabled by pref), they return raw
670 double OverriddenDeltaX() const;
671 double OverriddenDeltaY() const;
673 // Compute the overridden delta value. This may be useful for suppressing
674 // too fast scroll by system scroll speed overriding when widget sets
675 // mAllowToOverrideSystemScrollSpeed.
676 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
679 static bool sInitialized
;
680 static bool sIsSystemScrollSpeedOverrideEnabled
;
681 static int32_t sOverrideFactorX
;
682 static int32_t sOverrideFactorY
;
683 static void Initialize();
686 /******************************************************************************
687 * mozilla::WidgetPointerEvent
688 ******************************************************************************/
690 class WidgetPointerEvent
: public WidgetMouseEvent
{
691 friend class mozilla::dom::PBrowserParent
;
692 friend class mozilla::dom::PBrowserChild
;
693 ALLOW_DEPRECATED_READPARAM
696 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
698 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
)
699 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
),
703 mFromTouchEvent(false) {}
705 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
706 : WidgetMouseEvent(aEvent
),
710 mFromTouchEvent(false) {
711 mClass
= ePointerEventClass
;
714 virtual WidgetEvent
* Duplicate() const override
{
715 MOZ_ASSERT(mClass
== ePointerEventClass
,
716 "Duplicate() must be overridden by sub class");
717 // Not copying widget, it is a weak reference.
718 WidgetPointerEvent
* result
=
719 new WidgetPointerEvent(false, mMessage
, nullptr);
720 result
->AssignPointerEventData(*this, true);
721 result
->mFlags
= mFlags
;
728 bool mFromTouchEvent
;
730 // XXX Not tested by test_assign_event_data.html
731 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
733 AssignMouseEventData(aEvent
, aCopyTargets
);
735 mWidth
= aEvent
.mWidth
;
736 mHeight
= aEvent
.mHeight
;
737 mIsPrimary
= aEvent
.mIsPrimary
;
738 mFromTouchEvent
= aEvent
.mFromTouchEvent
;
742 } // namespace mozilla
744 #endif // mozilla_MouseEvents_h__