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 // ID of the canvas HitRegion
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
;
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
),
205 mIgnoreRootScrollFrame(false),
207 mUseLegacyNonPrimaryDispatch(false) {}
209 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
210 EventClassID aEventClassID
, Reason aReason
)
211 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
213 mContextMenuTrigger(eNormal
),
214 mIgnoreRootScrollFrame(false),
216 mUseLegacyNonPrimaryDispatch(false) {}
219 virtual WidgetMouseEvent
* AsMouseEvent() override
{ return this; }
221 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
223 ContextMenuTrigger aContextMenuTrigger
= eNormal
)
224 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eMouseEventClass
),
226 mContextMenuTrigger(aContextMenuTrigger
),
227 mIgnoreRootScrollFrame(false),
229 mUseLegacyNonPrimaryDispatch(false) {
230 if (aMessage
== eContextMenu
) {
231 mButton
= (mContextMenuTrigger
== eNormal
) ? MouseButton::eSecondary
232 : MouseButton::ePrimary
;
237 virtual ~WidgetMouseEvent() {
238 NS_WARNING_ASSERTION(
239 mMessage
!= eContextMenu
||
240 (mButton
== ((mContextMenuTrigger
== eNormal
)
241 ? MouseButton::eSecondary
242 : MouseButton::ePrimary
) &&
243 (mContextMenuTrigger
!= eControlClick
|| IsControl())),
244 "Wrong button set to eContextMenu event?");
248 virtual WidgetEvent
* Duplicate() const override
{
249 MOZ_ASSERT(mClass
== eMouseEventClass
,
250 "Duplicate() must be overridden by sub class");
251 // Not copying widget, it is a weak reference.
252 WidgetMouseEvent
* result
= new WidgetMouseEvent(
253 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
);
254 result
->AssignMouseEventData(*this, true);
255 result
->mFlags
= mFlags
;
259 // If during mouseup handling we detect that click event might need to be
260 // dispatched, this is setup to be the target of the click event.
261 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
263 // mReason indicates the reason why the event is fired:
264 // - Representing mouse operation.
265 // - Synthesized for emulating mousemove event when the content under the
266 // mouse cursor is scrolled.
269 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
270 // This indicates if the context menu event is caused by context menu key or
271 // other reasons (typically, a click of right mouse button).
272 ContextMenuTrigger mContextMenuTrigger
;
274 // mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
275 // This indicates if the mouse cursor exits from a top level platform widget,
276 // a child widget or a puppet widget.
277 Maybe
<ExitFrom
> mExitFrom
;
279 // Whether the event should ignore scroll frame bounds during dispatch.
280 bool mIgnoreRootScrollFrame
;
282 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
283 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
284 // Otherwise, this must be 0.
285 uint32_t mClickCount
;
287 // Indicates whether the event should dispatch click events for non-primary
288 // mouse buttons on window and document.
289 bool mUseLegacyNonPrimaryDispatch
;
291 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
292 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
293 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
295 mExitFrom
= aEvent
.mExitFrom
;
296 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
297 mClickCount
= aEvent
.mClickCount
;
298 mUseLegacyNonPrimaryDispatch
= aEvent
.mUseLegacyNonPrimaryDispatch
;
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 enum class DeltaModeCheckingState
: uint8_t {
517 // Neither deltaMode nor the delta values have been accessed.
519 // The delta values have been accessed, without checking deltaMode first.
521 // The deltaMode has been checked.
525 // For compat reasons, we might expose a DOM_DELTA_LINE event as
526 // DOM_DELTA_PIXEL instead. Whether we do that depends on whether the event
527 // has been asked for the deltaMode before the deltas. If it has, we assume
528 // that the page will correctly handle DOM_DELTA_LINE. This variable tracks
529 // that state. See bug 1392460.
530 DeltaModeCheckingState mDeltaModeCheckingState
=
531 DeltaModeCheckingState::Unknown
;
533 // The amount of scrolling per line or page, without accounting for mouse
534 // wheel transactions etc.
536 // Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
537 nsSize mScrollAmount
;
539 // overflowed delta values for scroll, these values are set by
540 // EventStateManger. If the default action of the wheel event isn't scroll,
541 // these values are always zero. Otherwise, remaining delta values which are
542 // not used by scroll are set.
543 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
544 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
545 // delta values which are not applied the delta_multiplier prefs.
546 // So, if widget wanted to know the actual direction to be scrolled,
547 // it would need to check the mDeltaX and mDeltaY.
548 double mOverflowDeltaX
;
549 double mOverflowDeltaY
;
551 // Should be one of WheelEvent_Binding::DOM_DELTA_*
554 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
555 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
556 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
557 int32_t mLineOrPageDeltaX
;
558 int32_t mLineOrPageDeltaY
;
560 // When the default action for an wheel event is moving history or zooming,
561 // need to chose a delta value for doing it.
562 int32_t GetPreferredIntDelta() {
563 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
566 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
567 return mLineOrPageDeltaY
;
569 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
570 return mLineOrPageDeltaX
;
572 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
573 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
574 return 0; // We cannot guess the answer in this case.
576 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
582 // The default value is SCROLL_DEFAULT, which means EventStateManager will
583 // select preferred scroll type automatically.
584 enum ScrollType
: uint8_t {
586 SCROLL_SYNCHRONOUSLY
,
587 SCROLL_ASYNCHRONOUSELY
,
590 ScrollType mScrollType
;
592 // If the delta values are computed from prefs, this value is true.
593 // Otherwise, i.e., they are computed from native events, false.
594 bool mCustomizedByUserPrefs
;
596 // true if the momentum events directly tied to this event may follow it.
597 bool mMayHaveMomentum
;
598 // true if the event is caused by momentum.
601 // If device event handlers don't know when they should set mLineOrPageDeltaX
602 // and mLineOrPageDeltaY, this is true. Otherwise, false.
603 // If mIsNoLineOrPageDelta is true, ESM will generate
604 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
606 bool mIsNoLineOrPageDelta
;
608 // Whether or not the parent of the currently overscrolled frame is the
609 // ViewPort. This is false in situations when an element on the page is being
610 // overscrolled (such as a text field), but true when the 'page' is being
612 bool mViewPortIsOverscrolled
;
614 // The wheel event can trigger a swipe to start if it's overscrolling the
616 bool mCanTriggerSwipe
;
618 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
619 // overridden. Otherwise, the scroll speed won't be overridden even if
620 // it's enabled by the pref.
621 bool mAllowToOverrideSystemScrollSpeed
;
623 // After the event's default action handler has adjusted its delta's values
624 // for horizontalizing a vertical wheel scroll, this variable will be set to
626 bool mDeltaValuesHorizontalizedForDefaultHandler
;
628 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
629 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
631 mDeltaX
= aEvent
.mDeltaX
;
632 mDeltaY
= aEvent
.mDeltaY
;
633 mDeltaZ
= aEvent
.mDeltaZ
;
634 mDeltaMode
= aEvent
.mDeltaMode
;
635 mScrollAmount
= aEvent
.mScrollAmount
;
636 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
637 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
638 mIsMomentum
= aEvent
.mIsMomentum
;
639 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
640 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
641 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
642 mScrollType
= aEvent
.mScrollType
;
643 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
644 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
645 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
646 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
647 mAllowToOverrideSystemScrollSpeed
=
648 aEvent
.mAllowToOverrideSystemScrollSpeed
;
649 mDeltaValuesHorizontalizedForDefaultHandler
=
650 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
653 // System scroll speed settings may be too slow at using Gecko. In such
654 // case, we should override the scroll speed computed with system settings.
655 // Following methods return preferred delta values which are multiplied by
656 // factors specified by prefs. If system scroll speed shouldn't be
657 // overridden (e.g., this feature is disabled by pref), they return raw
659 double OverriddenDeltaX() const;
660 double OverriddenDeltaY() const;
662 // Compute the overridden delta value. This may be useful for suppressing
663 // too fast scroll by system scroll speed overriding when widget sets
664 // mAllowToOverrideSystemScrollSpeed.
665 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
668 static bool sInitialized
;
669 static bool sIsSystemScrollSpeedOverrideEnabled
;
670 static int32_t sOverrideFactorX
;
671 static int32_t sOverrideFactorY
;
672 static void Initialize();
675 /******************************************************************************
676 * mozilla::WidgetPointerEvent
677 ******************************************************************************/
679 class WidgetPointerEvent
: public WidgetMouseEvent
{
680 friend class mozilla::dom::PBrowserParent
;
681 friend class mozilla::dom::PBrowserChild
;
683 WidgetPointerEvent() : mWidth(1), mHeight(1), mIsPrimary(true) {}
686 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
688 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
)
689 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
),
694 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
695 : WidgetMouseEvent(aEvent
), mWidth(1), mHeight(1), mIsPrimary(true) {
696 mClass
= ePointerEventClass
;
699 virtual WidgetEvent
* Duplicate() const override
{
700 MOZ_ASSERT(mClass
== ePointerEventClass
,
701 "Duplicate() must be overridden by sub class");
702 // Not copying widget, it is a weak reference.
703 WidgetPointerEvent
* result
=
704 new WidgetPointerEvent(false, mMessage
, nullptr);
705 result
->AssignPointerEventData(*this, true);
706 result
->mFlags
= mFlags
;
714 // XXX Not tested by test_assign_event_data.html
715 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
717 AssignMouseEventData(aEvent
, aCopyTargets
);
719 mWidth
= aEvent
.mWidth
;
720 mHeight
= aEvent
.mHeight
;
721 mIsPrimary
= aEvent
.mIsPrimary
;
725 } // namespace mozilla
727 #endif // mozilla_MouseEvents_h__