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 class WidgetPointerEventHolder final
{
27 nsTArray
<WidgetPointerEvent
> mEvents
;
28 NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder
)
31 virtual ~WidgetPointerEventHolder() {}
34 /******************************************************************************
35 * mozilla::WidgetPointerHelper
36 ******************************************************************************/
38 class WidgetPointerHelper
{
44 float tangentialPressure
;
45 bool convertToPointer
;
46 RefPtr
<WidgetPointerEventHolder
> mCoalescedWidgetEvents
;
53 tangentialPressure(0),
54 convertToPointer(true) {}
56 WidgetPointerHelper(uint32_t aPointerId
, uint32_t aTiltX
, uint32_t aTiltY
,
57 uint32_t aTwist
= 0, float aTangentialPressure
= 0)
58 : pointerId(aPointerId
),
62 tangentialPressure(aTangentialPressure
),
63 convertToPointer(true) {}
65 explicit WidgetPointerHelper(const WidgetPointerHelper
& aHelper
)
66 : pointerId(aHelper
.pointerId
),
70 tangentialPressure(aHelper
.tangentialPressure
),
71 convertToPointer(aHelper
.convertToPointer
),
72 mCoalescedWidgetEvents(aHelper
.mCoalescedWidgetEvents
) {}
74 void AssignPointerHelperData(const WidgetPointerHelper
& aEvent
,
75 bool aCopyCoalescedEvents
= false) {
76 pointerId
= aEvent
.pointerId
;
80 tangentialPressure
= aEvent
.tangentialPressure
;
81 convertToPointer
= aEvent
.convertToPointer
;
82 if (aCopyCoalescedEvents
) {
83 mCoalescedWidgetEvents
= aEvent
.mCoalescedWidgetEvents
;
88 /******************************************************************************
89 * mozilla::WidgetMouseEventBase
90 ******************************************************************************/
92 class WidgetMouseEventBase
: public WidgetInputEvent
{
94 friend class dom::PBrowserParent
;
95 friend class dom::PBrowserChild
;
96 friend class dom::PBrowserBridgeParent
;
99 WidgetMouseEventBase()
103 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1),
104 mHitCluster(false) {}
105 // Including MouseEventBinding.h here leads to an include loop, so
106 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
108 WidgetMouseEventBase(bool aIsTrusted
, EventMessage aMessage
,
109 nsIWidget
* aWidget
, EventClassID aEventClassID
)
110 : WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
114 mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1),
115 mHitCluster(false) {}
116 // Including MouseEventBinding.h here leads to an include loop, so
117 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
120 virtual WidgetMouseEventBase
* AsMouseEventBase() override
{ return this; }
122 virtual WidgetEvent
* Duplicate() const override
{
123 MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
126 // ID of the canvas HitRegion
129 // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
132 // Pressed button ID of mousedown or mouseup event.
133 // This is set only when pressing a button causes the event.
136 // Flags of all pressed buttons at the event fired.
137 // This is set at any mouse event, don't be confused with |mButton|.
140 // Possible values a in MouseEvent
141 uint16_t mInputSource
;
143 // Touch near a cluster of links (true)
146 bool IsLeftButtonPressed() const {
147 return !!(mButtons
& MouseButtonsFlag::eLeftFlag
);
149 bool IsRightButtonPressed() const {
150 return !!(mButtons
& MouseButtonsFlag::eRightFlag
);
152 bool IsMiddleButtonPressed() const {
153 return !!(mButtons
& MouseButtonsFlag::eMiddleFlag
);
155 bool Is4thButtonPressed() const {
156 return !!(mButtons
& MouseButtonsFlag::e4thFlag
);
158 bool Is5thButtonPressed() const {
159 return !!(mButtons
& MouseButtonsFlag::e5thFlag
);
162 void AssignMouseEventBaseData(const WidgetMouseEventBase
& aEvent
,
164 AssignInputEventData(aEvent
, aCopyTargets
);
166 mButton
= aEvent
.mButton
;
167 mButtons
= aEvent
.mButtons
;
168 mPressure
= aEvent
.mPressure
;
169 mHitCluster
= aEvent
.mHitCluster
;
170 mInputSource
= aEvent
.mInputSource
;
174 * Returns true if left click event.
176 bool IsLeftClickEvent() const {
177 return mMessage
== eMouseClick
&& mButton
== MouseButton::eLeft
;
181 /******************************************************************************
182 * mozilla::WidgetMouseEvent
183 ******************************************************************************/
185 class WidgetMouseEvent
: public WidgetMouseEventBase
,
186 public WidgetPointerHelper
{
188 friend class dom::PBrowserParent
;
189 friend class dom::PBrowserChild
;
190 friend class dom::PBrowserBridgeParent
;
193 typedef bool ReasonType
;
194 enum Reason
: ReasonType
{ eReal
, eSynthesized
};
196 typedef bool ContextMenuTriggerType
;
197 enum ContextMenuTrigger
: ContextMenuTriggerType
{ eNormal
, eContextMenuKey
};
199 typedef bool ExitFromType
;
200 enum ExitFrom
: ExitFromType
{ eChild
, eTopLevel
};
205 mContextMenuTrigger(eNormal
),
207 mIgnoreRootScrollFrame(false),
209 mUseLegacyNonPrimaryDispatch(false) {}
211 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
212 EventClassID aEventClassID
, Reason aReason
)
213 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
215 mContextMenuTrigger(eNormal
),
217 mIgnoreRootScrollFrame(false),
219 mUseLegacyNonPrimaryDispatch(false) {}
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),
233 mUseLegacyNonPrimaryDispatch(false) {
234 if (aMessage
== eContextMenu
) {
235 mButton
= (mContextMenuTrigger
== eNormal
) ? MouseButton::eRight
236 : MouseButton::eLeft
;
241 virtual ~WidgetMouseEvent() {
242 NS_WARNING_ASSERTION(
243 mMessage
!= eContextMenu
||
244 mButton
== ((mContextMenuTrigger
== eNormal
) ? MouseButton::eRight
245 : MouseButton::eLeft
),
246 "Wrong button set to eContextMenu event?");
250 virtual WidgetEvent
* Duplicate() const override
{
251 MOZ_ASSERT(mClass
== eMouseEventClass
,
252 "Duplicate() must be overridden by sub class");
253 // Not copying widget, it is a weak reference.
254 WidgetMouseEvent
* result
= new WidgetMouseEvent(
255 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
);
256 result
->AssignMouseEventData(*this, true);
257 result
->mFlags
= mFlags
;
261 // If during mouseup handling we detect that click event might need to be
262 // dispatched, this is setup to be the target of the click event.
263 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
265 // mReason indicates the reason why the event is fired:
266 // - Representing mouse operation.
267 // - Synthesized for emulating mousemove event when the content under the
268 // mouse cursor is scrolled.
271 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
272 // This indicates if the context menu event is caused by context menu key or
273 // other reasons (typically, a click of right mouse button).
274 ContextMenuTrigger mContextMenuTrigger
;
276 // mExitFrom is valid only when mMessage is eMouseExitFromWidget.
277 // This indicates if the mouse cursor exits from a top level widget or
281 // Whether the event should ignore scroll frame bounds during dispatch.
282 bool mIgnoreRootScrollFrame
;
284 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
285 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
286 // Otherwise, this must be 0.
287 uint32_t mClickCount
;
289 // Indicates whether the event should dispatch click events for non-primary
290 // mouse buttons on window and document.
291 bool mUseLegacyNonPrimaryDispatch
;
293 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
294 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
295 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
297 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
298 mClickCount
= aEvent
.mClickCount
;
299 mUseLegacyNonPrimaryDispatch
= aEvent
.mUseLegacyNonPrimaryDispatch
;
303 * Returns true if the event is a context menu event caused by key.
305 bool IsContextMenuKeyEvent() const {
306 return mMessage
== eContextMenu
&& mContextMenuTrigger
== eContextMenuKey
;
310 * Returns true if the event is a real mouse event. Otherwise, i.e., it's
311 * a synthesized event by scroll or something, returns false.
313 bool IsReal() const { return mReason
== eReal
; }
316 * Returns true if middle click paste is enabled.
318 static bool IsMiddleClickPasteEnabled();
321 /******************************************************************************
322 * mozilla::WidgetDragEvent
323 ******************************************************************************/
325 class WidgetDragEvent
: public WidgetMouseEvent
{
327 friend class mozilla::dom::PBrowserParent
;
328 friend class mozilla::dom::PBrowserChild
;
332 : mUserCancelled(false), mDefaultPreventedOnContent(false) {}
335 virtual WidgetDragEvent
* AsDragEvent() override
{ return this; }
337 WidgetDragEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
338 : WidgetMouseEvent(aIsTrusted
, aMessage
, aWidget
, eDragEventClass
, eReal
),
339 mUserCancelled(false),
340 mDefaultPreventedOnContent(false) {}
342 virtual WidgetEvent
* Duplicate() const override
{
343 MOZ_ASSERT(mClass
== eDragEventClass
,
344 "Duplicate() must be overridden by sub class");
345 // Not copying widget, it is a weak reference.
346 WidgetDragEvent
* result
= new WidgetDragEvent(false, mMessage
, nullptr);
347 result
->AssignDragEventData(*this, true);
348 result
->mFlags
= mFlags
;
352 // The dragging data.
353 nsCOMPtr
<dom::DataTransfer
> mDataTransfer
;
355 // If this is true, user has cancelled the drag operation.
357 // If this is true, the drag event's preventDefault() is called on content.
358 bool mDefaultPreventedOnContent
;
360 // XXX Not tested by test_assign_event_data.html
361 void AssignDragEventData(const WidgetDragEvent
& aEvent
, bool aCopyTargets
) {
362 AssignMouseEventData(aEvent
, aCopyTargets
);
364 mDataTransfer
= aEvent
.mDataTransfer
;
365 // XXX mUserCancelled isn't copied, is this intentionally?
366 mUserCancelled
= false;
367 mDefaultPreventedOnContent
= aEvent
.mDefaultPreventedOnContent
;
371 * Should be called before dispatching the DOM tree if this event is
372 * synthesized for tests because drop effect is initialized before
373 * dispatching from widget if it's not synthesized event, but synthesized
374 * events are not initialized in the path.
376 void InitDropEffectForTests();
379 /******************************************************************************
380 * mozilla::WidgetMouseScrollEvent
382 * This is used for legacy DOM mouse scroll events, i.e.,
383 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
384 * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
385 ******************************************************************************/
387 class WidgetMouseScrollEvent
: public WidgetMouseEventBase
{
389 WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
392 virtual WidgetMouseScrollEvent
* AsMouseScrollEvent() override
{ return this; }
394 WidgetMouseScrollEvent(bool aIsTrusted
, EventMessage aMessage
,
396 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
397 eMouseScrollEventClass
),
399 mIsHorizontal(false) {}
401 virtual WidgetEvent
* Duplicate() const override
{
402 MOZ_ASSERT(mClass
== eMouseScrollEventClass
,
403 "Duplicate() must be overridden by sub class");
404 // Not copying widget, it is a weak reference.
405 WidgetMouseScrollEvent
* result
=
406 new WidgetMouseScrollEvent(false, mMessage
, nullptr);
407 result
->AssignMouseScrollEventData(*this, true);
408 result
->mFlags
= mFlags
;
412 // The delta value of mouse scroll event.
413 // If the event message is eLegacyMouseLineOrPageScroll, the value indicates
414 // scroll amount in lines. However, if the value is
415 // UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
416 // value inducates one page scroll. If the event message is
417 // eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
420 // If this is true, it may cause to scroll horizontally.
421 // Otherwise, vertically.
424 void AssignMouseScrollEventData(const WidgetMouseScrollEvent
& aEvent
,
426 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
428 mDelta
= aEvent
.mDelta
;
429 mIsHorizontal
= aEvent
.mIsHorizontal
;
433 /******************************************************************************
434 * mozilla::WidgetWheelEvent
435 ******************************************************************************/
437 class WidgetWheelEvent
: public WidgetMouseEventBase
{
439 friend class mozilla::dom::PBrowserParent
;
440 friend class mozilla::dom::PBrowserChild
;
446 mOverflowDeltaX(0.0),
448 // Including WheelEventBinding.h here leads to an include loop, so
449 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
451 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
452 mLineOrPageDeltaX(0),
453 mLineOrPageDeltaY(0),
454 mScrollType(SCROLL_DEFAULT
),
455 mCustomizedByUserPrefs(false),
456 mMayHaveMomentum(false),
458 mIsNoLineOrPageDelta(false),
459 mViewPortIsOverscrolled(false),
460 mCanTriggerSwipe(false),
461 mAllowToOverrideSystemScrollSpeed(false),
462 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
465 virtual WidgetWheelEvent
* AsWheelEvent() override
{ return this; }
467 WidgetWheelEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
468 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eWheelEventClass
),
472 mOverflowDeltaX(0.0),
474 // Including WheelEventBinding.h here leads to an include loop, so
475 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
477 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
478 mLineOrPageDeltaX(0),
479 mLineOrPageDeltaY(0),
480 mScrollType(SCROLL_DEFAULT
),
481 mCustomizedByUserPrefs(false),
482 mMayHaveMomentum(false),
484 mIsNoLineOrPageDelta(false),
485 mViewPortIsOverscrolled(false),
486 mCanTriggerSwipe(false),
487 mAllowToOverrideSystemScrollSpeed(true),
488 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
490 virtual WidgetEvent
* Duplicate() const override
{
491 MOZ_ASSERT(mClass
== eWheelEventClass
,
492 "Duplicate() must be overridden by sub class");
493 // Not copying widget, it is a weak reference.
494 WidgetWheelEvent
* result
= new WidgetWheelEvent(false, mMessage
, nullptr);
495 result
->AssignWheelEventData(*this, true);
496 result
->mFlags
= mFlags
;
500 // On OS X, scroll gestures that start at the edge of the scrollable range
501 // can result in a swipe gesture. For the first wheel event of such a
502 // gesture, call TriggersSwipe() after the event has been processed
503 // in order to find out whether a swipe should be started.
504 bool TriggersSwipe() const {
505 return mCanTriggerSwipe
&& mViewPortIsOverscrolled
&&
506 this->mOverflowDeltaX
!= 0.0;
509 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
510 // mousewheel.*.delta_multiplier_* prefs which are applied by
511 // EventStateManager. So, after widget dispatches this event,
512 // these delta values may have different values than before.
517 // overflowed delta values for scroll, these values are set by
518 // EventStateManger. If the default action of the wheel event isn't scroll,
519 // these values are always zero. Otherwise, remaining delta values which are
520 // not used by scroll are set.
521 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
522 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
523 // delta values which are not applied the delta_multiplier prefs.
524 // So, if widget wanted to know the actual direction to be scrolled,
525 // it would need to check the mDeltaX and mDeltaY.
526 double mOverflowDeltaX
;
527 double mOverflowDeltaY
;
529 // Should be one of WheelEvent_Binding::DOM_DELTA_*
532 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
533 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
534 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
535 int32_t mLineOrPageDeltaX
;
536 int32_t mLineOrPageDeltaY
;
538 // When the default action for an wheel event is moving history or zooming,
539 // need to chose a delta value for doing it.
540 int32_t GetPreferredIntDelta() {
541 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
544 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
545 return mLineOrPageDeltaY
;
547 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
548 return mLineOrPageDeltaX
;
550 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
551 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
552 return 0; // We cannot guess the answer in this case.
554 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
560 // The default value is SCROLL_DEFAULT, which means EventStateManager will
561 // select preferred scroll type automatically.
562 enum ScrollType
: uint8_t {
564 SCROLL_SYNCHRONOUSLY
,
565 SCROLL_ASYNCHRONOUSELY
,
568 ScrollType mScrollType
;
570 // If the delta values are computed from prefs, this value is true.
571 // Otherwise, i.e., they are computed from native events, false.
572 bool mCustomizedByUserPrefs
;
574 // true if the momentum events directly tied to this event may follow it.
575 bool mMayHaveMomentum
;
576 // true if the event is caused by momentum.
579 // If device event handlers don't know when they should set mLineOrPageDeltaX
580 // and mLineOrPageDeltaY, this is true. Otherwise, false.
581 // If mIsNoLineOrPageDelta is true, ESM will generate
582 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
584 bool mIsNoLineOrPageDelta
;
586 // Whether or not the parent of the currently overscrolled frame is the
587 // ViewPort. This is false in situations when an element on the page is being
588 // overscrolled (such as a text field), but true when the 'page' is being
590 bool mViewPortIsOverscrolled
;
592 // The wheel event can trigger a swipe to start if it's overscrolling the
594 bool mCanTriggerSwipe
;
596 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
597 // overridden. Otherwise, the scroll speed won't be overridden even if
598 // it's enabled by the pref.
599 bool mAllowToOverrideSystemScrollSpeed
;
601 // After the event's default action handler has adjusted its delta's values
602 // for horizontalizing a vertical wheel scroll, this variable will be set to
604 bool mDeltaValuesHorizontalizedForDefaultHandler
;
606 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
607 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
609 mDeltaX
= aEvent
.mDeltaX
;
610 mDeltaY
= aEvent
.mDeltaY
;
611 mDeltaZ
= aEvent
.mDeltaZ
;
612 mDeltaMode
= aEvent
.mDeltaMode
;
613 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
614 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
615 mIsMomentum
= aEvent
.mIsMomentum
;
616 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
617 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
618 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
619 mScrollType
= aEvent
.mScrollType
;
620 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
621 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
622 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
623 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
624 mAllowToOverrideSystemScrollSpeed
=
625 aEvent
.mAllowToOverrideSystemScrollSpeed
;
626 mDeltaValuesHorizontalizedForDefaultHandler
=
627 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
630 // System scroll speed settings may be too slow at using Gecko. In such
631 // case, we should override the scroll speed computed with system settings.
632 // Following methods return preferred delta values which are multiplied by
633 // factors specified by prefs. If system scroll speed shouldn't be
634 // overridden (e.g., this feature is disabled by pref), they return raw
636 double OverriddenDeltaX() const;
637 double OverriddenDeltaY() const;
639 // Compute the overridden delta value. This may be useful for suppressing
640 // too fast scroll by system scroll speed overriding when widget sets
641 // mAllowToOverrideSystemScrollSpeed.
642 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
645 static bool sInitialized
;
646 static bool sIsSystemScrollSpeedOverrideEnabled
;
647 static int32_t sOverrideFactorX
;
648 static int32_t sOverrideFactorY
;
649 static void Initialize();
652 /******************************************************************************
653 * mozilla::WidgetPointerEvent
654 ******************************************************************************/
656 class WidgetPointerEvent
: public WidgetMouseEvent
{
657 friend class mozilla::dom::PBrowserParent
;
658 friend class mozilla::dom::PBrowserChild
;
660 WidgetPointerEvent() : mWidth(1), mHeight(1), mIsPrimary(true) {}
663 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
665 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
)
666 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
),
671 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
672 : WidgetMouseEvent(aEvent
), mWidth(1), mHeight(1), mIsPrimary(true) {
673 mClass
= ePointerEventClass
;
676 virtual WidgetEvent
* Duplicate() const override
{
677 MOZ_ASSERT(mClass
== ePointerEventClass
,
678 "Duplicate() must be overridden by sub class");
679 // Not copying widget, it is a weak reference.
680 WidgetPointerEvent
* result
=
681 new WidgetPointerEvent(false, mMessage
, nullptr);
682 result
->AssignPointerEventData(*this, true);
683 result
->mFlags
= mFlags
;
691 // XXX Not tested by test_assign_event_data.html
692 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
694 AssignMouseEventData(aEvent
, aCopyTargets
);
696 mWidth
= aEvent
.mWidth
;
697 mHeight
= aEvent
.mHeight
;
698 mIsPrimary
= aEvent
.mIsPrimary
;
702 } // namespace mozilla
704 #endif // mozilla_MouseEvents_h__