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"
21 class PBrowserBridgeParent
;
24 class WidgetPointerEvent
;
25 } // namespace mozilla
28 class WidgetPointerEventHolder final
{
30 nsTArray
<WidgetPointerEvent
> mEvents
;
31 NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder
)
34 virtual ~WidgetPointerEventHolder() = default;
37 /******************************************************************************
38 * mozilla::WidgetPointerHelper
39 ******************************************************************************/
41 class WidgetPointerHelper
{
47 float tangentialPressure
;
48 bool convertToPointer
;
49 RefPtr
<WidgetPointerEventHolder
> mCoalescedWidgetEvents
;
56 tangentialPressure(0),
57 convertToPointer(true) {}
59 WidgetPointerHelper(uint32_t aPointerId
, uint32_t aTiltX
, uint32_t aTiltY
,
60 uint32_t aTwist
= 0, float aTangentialPressure
= 0)
61 : pointerId(aPointerId
),
65 tangentialPressure(aTangentialPressure
),
66 convertToPointer(true) {}
68 explicit WidgetPointerHelper(const WidgetPointerHelper
& aHelper
) = default;
70 void AssignPointerHelperData(const WidgetPointerHelper
& aEvent
,
71 bool aCopyCoalescedEvents
= false) {
72 pointerId
= aEvent
.pointerId
;
76 tangentialPressure
= aEvent
.tangentialPressure
;
77 convertToPointer
= aEvent
.convertToPointer
;
78 if (aCopyCoalescedEvents
) {
79 mCoalescedWidgetEvents
= aEvent
.mCoalescedWidgetEvents
;
84 /******************************************************************************
85 * mozilla::WidgetMouseEventBase
86 ******************************************************************************/
88 class WidgetMouseEventBase
: public WidgetInputEvent
{
90 friend class dom::PBrowserParent
;
91 friend class dom::PBrowserChild
;
92 friend class dom::PBrowserBridgeParent
;
95 WidgetMouseEventBase()
99 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
100 // Including MouseEventBinding.h here leads to an include loop, so
101 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
103 WidgetMouseEventBase(bool aIsTrusted
, EventMessage aMessage
,
104 nsIWidget
* aWidget
, EventClassID aEventClassID
)
105 : WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
109 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
110 // Including MouseEventBinding.h here leads to an include loop, so
111 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
114 virtual WidgetMouseEventBase
* AsMouseEventBase() override
{ return this; }
116 virtual WidgetEvent
* Duplicate() const override
{
117 MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
120 // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
123 // Pressed button ID of mousedown or mouseup event.
124 // This is set only when pressing a button causes the event.
127 // Flags of all pressed buttons at the event fired.
128 // This is set at any mouse event, don't be confused with |mButton|.
131 // Possible values a in MouseEvent
132 uint16_t mInputSource
;
134 bool IsLeftButtonPressed() const {
135 return !!(mButtons
& MouseButtonsFlag::ePrimaryFlag
);
137 bool IsRightButtonPressed() const {
138 return !!(mButtons
& MouseButtonsFlag::eSecondaryFlag
);
140 bool IsMiddleButtonPressed() const {
141 return !!(mButtons
& MouseButtonsFlag::eMiddleFlag
);
143 bool Is4thButtonPressed() const {
144 return !!(mButtons
& MouseButtonsFlag::e4thFlag
);
146 bool Is5thButtonPressed() const {
147 return !!(mButtons
& MouseButtonsFlag::e5thFlag
);
150 void AssignMouseEventBaseData(const WidgetMouseEventBase
& aEvent
,
152 AssignInputEventData(aEvent
, aCopyTargets
);
154 mButton
= aEvent
.mButton
;
155 mButtons
= aEvent
.mButtons
;
156 mPressure
= aEvent
.mPressure
;
157 mInputSource
= aEvent
.mInputSource
;
161 * Returns true if left click event.
163 bool IsLeftClickEvent() const {
164 return mMessage
== eMouseClick
&& mButton
== MouseButton::ePrimary
;
168 /******************************************************************************
169 * mozilla::WidgetMouseEvent
170 ******************************************************************************/
172 class WidgetMouseEvent
: public WidgetMouseEventBase
,
173 public WidgetPointerHelper
{
175 friend class dom::PBrowserParent
;
176 friend class dom::PBrowserChild
;
177 friend class dom::PBrowserBridgeParent
;
180 typedef bool ReasonType
;
181 enum Reason
: ReasonType
{ eReal
, eSynthesized
};
183 typedef uint8_t ContextMenuTriggerType
;
184 enum ContextMenuTrigger
: ContextMenuTriggerType
{
190 typedef uint8_t ExitFromType
;
191 enum ExitFrom
: ExitFromType
{
195 ePuppetParentToPuppetChild
201 mContextMenuTrigger(eNormal
),
203 mIgnoreRootScrollFrame(false),
204 mUseLegacyNonPrimaryDispatch(false),
205 mClickEventPrevented(false) {}
207 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
208 EventClassID aEventClassID
, Reason aReason
)
209 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
211 mContextMenuTrigger(eNormal
),
213 mIgnoreRootScrollFrame(false),
214 mUseLegacyNonPrimaryDispatch(false),
215 mClickEventPrevented(false) {}
218 void AssertContextMenuEventButtonConsistency() const;
222 virtual WidgetMouseEvent
* AsMouseEvent() override
{ return this; }
224 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
226 ContextMenuTrigger aContextMenuTrigger
= eNormal
)
227 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eMouseEventClass
),
229 mContextMenuTrigger(aContextMenuTrigger
),
231 mIgnoreRootScrollFrame(false),
232 mUseLegacyNonPrimaryDispatch(false),
233 mClickEventPrevented(false) {
234 if (aMessage
== eContextMenu
) {
235 mButton
= (mContextMenuTrigger
== eNormal
) ? MouseButton::eSecondary
236 : MouseButton::ePrimary
;
241 virtual ~WidgetMouseEvent() { AssertContextMenuEventButtonConsistency(); }
244 virtual WidgetEvent
* Duplicate() const override
{
245 MOZ_ASSERT(mClass
== eMouseEventClass
,
246 "Duplicate() must be overridden by sub class");
247 // Not copying widget, it is a weak reference.
248 WidgetMouseEvent
* result
= new WidgetMouseEvent(
249 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
);
250 result
->AssignMouseEventData(*this, true);
251 result
->mFlags
= mFlags
;
255 // If during mouseup handling we detect that click event might need to be
256 // dispatched, this is setup to be the target of the click event.
257 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
259 // mReason indicates the reason why the event is fired:
260 // - Representing mouse operation.
261 // - Synthesized for emulating mousemove event when the content under the
262 // mouse cursor is scrolled.
265 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
266 // This indicates if the context menu event is caused by context menu key or
267 // other reasons (typically, a click of right mouse button).
268 ContextMenuTrigger mContextMenuTrigger
;
270 // mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
271 // This indicates if the mouse cursor exits from a top level platform widget,
272 // a child widget or a puppet widget.
273 Maybe
<ExitFrom
> mExitFrom
;
275 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
276 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
277 // Otherwise, this must be 0.
278 uint32_t mClickCount
;
280 // Whether the event should ignore scroll frame bounds during dispatch.
281 bool mIgnoreRootScrollFrame
;
283 // Indicates whether the event should dispatch click events for non-primary
284 // mouse buttons on window and document.
285 bool mUseLegacyNonPrimaryDispatch
;
287 // Whether the event shouldn't cause click event.
288 bool mClickEventPrevented
;
290 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
291 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
292 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
294 mExitFrom
= aEvent
.mExitFrom
;
295 mClickCount
= aEvent
.mClickCount
;
296 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
297 mUseLegacyNonPrimaryDispatch
= aEvent
.mUseLegacyNonPrimaryDispatch
;
298 mClickEventPrevented
= aEvent
.mClickEventPrevented
;
302 * Returns true if the event is a context menu event caused by key.
304 bool IsContextMenuKeyEvent() const {
305 return mMessage
== eContextMenu
&& mContextMenuTrigger
== eContextMenuKey
;
309 * Returns true if the event is a real mouse event. Otherwise, i.e., it's
310 * a synthesized event by scroll or something, returns false.
312 bool IsReal() const { return mReason
== eReal
; }
315 * Returns true if middle click paste is enabled.
317 static bool IsMiddleClickPasteEnabled();
320 /******************************************************************************
321 * mozilla::WidgetDragEvent
322 ******************************************************************************/
324 class WidgetDragEvent
: public WidgetMouseEvent
{
326 friend class mozilla::dom::PBrowserParent
;
327 friend class mozilla::dom::PBrowserChild
;
331 : mUserCancelled(false), mDefaultPreventedOnContent(false) {}
334 virtual WidgetDragEvent
* AsDragEvent() override
{ return this; }
336 WidgetDragEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
337 : WidgetMouseEvent(aIsTrusted
, aMessage
, aWidget
, eDragEventClass
, eReal
),
338 mUserCancelled(false),
339 mDefaultPreventedOnContent(false) {}
341 virtual WidgetEvent
* Duplicate() const override
{
342 MOZ_ASSERT(mClass
== eDragEventClass
,
343 "Duplicate() must be overridden by sub class");
344 // Not copying widget, it is a weak reference.
345 WidgetDragEvent
* result
= new WidgetDragEvent(false, mMessage
, nullptr);
346 result
->AssignDragEventData(*this, true);
347 result
->mFlags
= mFlags
;
351 // The dragging data.
352 nsCOMPtr
<dom::DataTransfer
> mDataTransfer
;
354 // If this is true, user has cancelled the drag operation.
356 // If this is true, the drag event's preventDefault() is called on content.
357 bool mDefaultPreventedOnContent
;
359 // XXX Not tested by test_assign_event_data.html
360 void AssignDragEventData(const WidgetDragEvent
& aEvent
, bool aCopyTargets
) {
361 AssignMouseEventData(aEvent
, aCopyTargets
);
363 mDataTransfer
= aEvent
.mDataTransfer
;
364 // XXX mUserCancelled isn't copied, is this intentionally?
365 mUserCancelled
= false;
366 mDefaultPreventedOnContent
= aEvent
.mDefaultPreventedOnContent
;
370 * Should be called before dispatching the DOM tree if this event is
371 * synthesized for tests because drop effect is initialized before
372 * dispatching from widget if it's not synthesized event, but synthesized
373 * events are not initialized in the path.
375 void InitDropEffectForTests();
378 /******************************************************************************
379 * mozilla::WidgetMouseScrollEvent
381 * This is used for legacy DOM mouse scroll events, i.e.,
382 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
383 * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
384 ******************************************************************************/
386 class WidgetMouseScrollEvent
: public WidgetMouseEventBase
{
388 WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
391 virtual WidgetMouseScrollEvent
* AsMouseScrollEvent() override
{ return this; }
393 WidgetMouseScrollEvent(bool aIsTrusted
, EventMessage aMessage
,
395 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
396 eMouseScrollEventClass
),
398 mIsHorizontal(false) {}
400 virtual WidgetEvent
* Duplicate() const override
{
401 MOZ_ASSERT(mClass
== eMouseScrollEventClass
,
402 "Duplicate() must be overridden by sub class");
403 // Not copying widget, it is a weak reference.
404 WidgetMouseScrollEvent
* result
=
405 new WidgetMouseScrollEvent(false, mMessage
, nullptr);
406 result
->AssignMouseScrollEventData(*this, true);
407 result
->mFlags
= mFlags
;
411 // The delta value of mouse scroll event.
412 // If the event message is eLegacyMouseLineOrPageScroll, the value indicates
413 // scroll amount in lines. However, if the value is
414 // UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
415 // value inducates one page scroll. If the event message is
416 // eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
419 // If this is true, it may cause to scroll horizontally.
420 // Otherwise, vertically.
423 void AssignMouseScrollEventData(const WidgetMouseScrollEvent
& aEvent
,
425 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
427 mDelta
= aEvent
.mDelta
;
428 mIsHorizontal
= aEvent
.mIsHorizontal
;
432 /******************************************************************************
433 * mozilla::WidgetWheelEvent
434 ******************************************************************************/
436 class WidgetWheelEvent
: public WidgetMouseEventBase
{
438 friend class mozilla::dom::PBrowserParent
;
439 friend class mozilla::dom::PBrowserChild
;
445 mOverflowDeltaX(0.0),
447 // Including WheelEventBinding.h here leads to an include loop, so
448 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
450 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
451 mLineOrPageDeltaX(0),
452 mLineOrPageDeltaY(0),
453 mScrollType(SCROLL_DEFAULT
),
454 mCustomizedByUserPrefs(false),
455 mMayHaveMomentum(false),
457 mIsNoLineOrPageDelta(false),
458 mViewPortIsOverscrolled(false),
459 mCanTriggerSwipe(false),
460 mAllowToOverrideSystemScrollSpeed(false),
461 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
464 virtual WidgetWheelEvent
* AsWheelEvent() override
{ return this; }
466 WidgetWheelEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
467 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eWheelEventClass
),
471 mOverflowDeltaX(0.0),
473 // Including WheelEventBinding.h here leads to an include loop, so
474 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
476 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
477 mLineOrPageDeltaX(0),
478 mLineOrPageDeltaY(0),
479 mScrollType(SCROLL_DEFAULT
),
480 mCustomizedByUserPrefs(false),
481 mMayHaveMomentum(false),
483 mIsNoLineOrPageDelta(false),
484 mViewPortIsOverscrolled(false),
485 mCanTriggerSwipe(false),
486 mAllowToOverrideSystemScrollSpeed(true),
487 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
489 virtual WidgetEvent
* Duplicate() const override
{
490 MOZ_ASSERT(mClass
== eWheelEventClass
,
491 "Duplicate() must be overridden by sub class");
492 // Not copying widget, it is a weak reference.
493 WidgetWheelEvent
* result
= new WidgetWheelEvent(false, mMessage
, nullptr);
494 result
->AssignWheelEventData(*this, true);
495 result
->mFlags
= mFlags
;
499 // On OS X, scroll gestures that start at the edge of the scrollable range
500 // can result in a swipe gesture. For the first wheel event of such a
501 // gesture, call TriggersSwipe() after the event has been processed
502 // in order to find out whether a swipe should be started.
503 bool TriggersSwipe() const {
504 return mCanTriggerSwipe
&& mViewPortIsOverscrolled
&&
505 this->mOverflowDeltaX
!= 0.0;
508 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
509 // mousewheel.*.delta_multiplier_* prefs which are applied by
510 // EventStateManager. So, after widget dispatches this event,
511 // these delta values may have different values than before.
516 // The mousewheel tick counts.
517 double mWheelTicksX
= 0.0;
518 double mWheelTicksY
= 0.0;
520 enum class DeltaModeCheckingState
: uint8_t {
521 // Neither deltaMode nor the delta values have been accessed.
523 // The delta values have been accessed, without checking deltaMode first.
525 // The deltaMode has been checked.
529 // For compat reasons, we might expose a DOM_DELTA_LINE event as
530 // DOM_DELTA_PIXEL instead. Whether we do that depends on whether the event
531 // has been asked for the deltaMode before the deltas. If it has, we assume
532 // that the page will correctly handle DOM_DELTA_LINE. This variable tracks
533 // that state. See bug 1392460.
534 DeltaModeCheckingState mDeltaModeCheckingState
=
535 DeltaModeCheckingState::Unknown
;
537 // The amount of scrolling per line or page, without accounting for mouse
538 // wheel transactions etc.
540 // Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
541 nsSize mScrollAmount
;
543 // overflowed delta values for scroll, these values are set by
544 // EventStateManger. If the default action of the wheel event isn't scroll,
545 // these values are always zero. Otherwise, remaining delta values which are
546 // not used by scroll are set.
547 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
548 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
549 // delta values which are not applied the delta_multiplier prefs.
550 // So, if widget wanted to know the actual direction to be scrolled,
551 // it would need to check the mDeltaX and mDeltaY.
552 double mOverflowDeltaX
;
553 double mOverflowDeltaY
;
555 // Should be one of WheelEvent_Binding::DOM_DELTA_*
558 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
559 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
560 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
561 int32_t mLineOrPageDeltaX
;
562 int32_t mLineOrPageDeltaY
;
564 // When the default action for an wheel event is moving history or zooming,
565 // need to chose a delta value for doing it.
566 int32_t GetPreferredIntDelta() {
567 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
570 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
571 return mLineOrPageDeltaY
;
573 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
574 return mLineOrPageDeltaX
;
576 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
577 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
578 return 0; // We cannot guess the answer in this case.
580 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
586 // The default value is SCROLL_DEFAULT, which means EventStateManager will
587 // select preferred scroll type automatically.
588 enum ScrollType
: uint8_t {
590 SCROLL_SYNCHRONOUSLY
,
591 SCROLL_ASYNCHRONOUSLY
,
594 ScrollType mScrollType
;
596 // If the delta values are computed from prefs, this value is true.
597 // Otherwise, i.e., they are computed from native events, false.
598 bool mCustomizedByUserPrefs
;
600 // true if the momentum events directly tied to this event may follow it.
601 bool mMayHaveMomentum
;
602 // true if the event is caused by momentum.
605 // If device event handlers don't know when they should set mLineOrPageDeltaX
606 // and mLineOrPageDeltaY, this is true. Otherwise, false.
607 // If mIsNoLineOrPageDelta is true, ESM will generate
608 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
610 bool mIsNoLineOrPageDelta
;
612 // Whether or not the parent of the currently overscrolled frame is the
613 // ViewPort. This is false in situations when an element on the page is being
614 // overscrolled (such as a text field), but true when the 'page' is being
616 bool mViewPortIsOverscrolled
;
618 // The wheel event can trigger a swipe to start if it's overscrolling the
620 bool mCanTriggerSwipe
;
622 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
623 // overridden. Otherwise, the scroll speed won't be overridden even if
624 // it's enabled by the pref.
625 bool mAllowToOverrideSystemScrollSpeed
;
627 // After the event's default action handler has adjusted its delta's values
628 // for horizontalizing a vertical wheel scroll, this variable will be set to
630 bool mDeltaValuesHorizontalizedForDefaultHandler
;
632 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
633 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
635 mDeltaX
= aEvent
.mDeltaX
;
636 mDeltaY
= aEvent
.mDeltaY
;
637 mDeltaZ
= aEvent
.mDeltaZ
;
638 mDeltaMode
= aEvent
.mDeltaMode
;
639 mScrollAmount
= aEvent
.mScrollAmount
;
640 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
641 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
642 mIsMomentum
= aEvent
.mIsMomentum
;
643 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
644 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
645 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
646 mScrollType
= aEvent
.mScrollType
;
647 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
648 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
649 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
650 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
651 mAllowToOverrideSystemScrollSpeed
=
652 aEvent
.mAllowToOverrideSystemScrollSpeed
;
653 mDeltaValuesHorizontalizedForDefaultHandler
=
654 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
657 // System scroll speed settings may be too slow at using Gecko. In such
658 // case, we should override the scroll speed computed with system settings.
659 // Following methods return preferred delta values which are multiplied by
660 // factors specified by prefs. If system scroll speed shouldn't be
661 // overridden (e.g., this feature is disabled by pref), they return raw
663 double OverriddenDeltaX() const;
664 double OverriddenDeltaY() const;
666 // Compute the overridden delta value. This may be useful for suppressing
667 // too fast scroll by system scroll speed overriding when widget sets
668 // mAllowToOverrideSystemScrollSpeed.
669 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
672 static bool sInitialized
;
673 static bool sIsSystemScrollSpeedOverrideEnabled
;
674 static int32_t sOverrideFactorX
;
675 static int32_t sOverrideFactorY
;
676 static void Initialize();
679 /******************************************************************************
680 * mozilla::WidgetPointerEvent
681 ******************************************************************************/
683 class WidgetPointerEvent
: public WidgetMouseEvent
{
684 friend class mozilla::dom::PBrowserParent
;
685 friend class mozilla::dom::PBrowserChild
;
688 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
690 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
)
691 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
),
695 mFromTouchEvent(false) {}
697 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
698 : WidgetMouseEvent(aEvent
),
702 mFromTouchEvent(false) {
703 mClass
= ePointerEventClass
;
706 virtual WidgetEvent
* Duplicate() const override
{
707 MOZ_ASSERT(mClass
== ePointerEventClass
,
708 "Duplicate() must be overridden by sub class");
709 // Not copying widget, it is a weak reference.
710 WidgetPointerEvent
* result
=
711 new WidgetPointerEvent(false, mMessage
, nullptr);
712 result
->AssignPointerEventData(*this, true);
713 result
->mFlags
= mFlags
;
720 bool mFromTouchEvent
;
722 // XXX Not tested by test_assign_event_data.html
723 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
725 AssignMouseEventData(aEvent
, aCopyTargets
);
727 mWidth
= aEvent
.mWidth
;
728 mHeight
= aEvent
.mHeight
;
729 mIsPrimary
= aEvent
.mIsPrimary
;
730 mFromTouchEvent
= aEvent
.mFromTouchEvent
;
734 } // namespace mozilla
736 #endif // mozilla_MouseEvents_h__