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"
23 class WidgetPointerEvent
;
24 class WidgetPointerEventHolder final
{
26 nsTArray
<WidgetPointerEvent
> mEvents
;
27 NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder
)
30 virtual ~WidgetPointerEventHolder() {}
33 /******************************************************************************
34 * mozilla::WidgetPointerHelper
35 ******************************************************************************/
37 class WidgetPointerHelper
{
43 float tangentialPressure
;
44 bool convertToPointer
;
45 RefPtr
<WidgetPointerEventHolder
> mCoalescedWidgetEvents
;
52 tangentialPressure(0),
53 convertToPointer(true) {}
55 WidgetPointerHelper(uint32_t aPointerId
, uint32_t aTiltX
, uint32_t aTiltY
,
56 uint32_t aTwist
= 0, float aTangentialPressure
= 0)
57 : pointerId(aPointerId
),
61 tangentialPressure(aTangentialPressure
),
62 convertToPointer(true) {}
64 explicit WidgetPointerHelper(const WidgetPointerHelper
& aHelper
)
65 : pointerId(aHelper
.pointerId
),
69 tangentialPressure(aHelper
.tangentialPressure
),
70 convertToPointer(aHelper
.convertToPointer
),
71 mCoalescedWidgetEvents(aHelper
.mCoalescedWidgetEvents
) {}
73 void AssignPointerHelperData(const WidgetPointerHelper
& aEvent
,
74 bool aCopyCoalescedEvents
= false) {
75 pointerId
= aEvent
.pointerId
;
79 tangentialPressure
= aEvent
.tangentialPressure
;
80 convertToPointer
= aEvent
.convertToPointer
;
81 if (aCopyCoalescedEvents
) {
82 mCoalescedWidgetEvents
= aEvent
.mCoalescedWidgetEvents
;
87 /******************************************************************************
88 * mozilla::WidgetMouseEventBase
89 ******************************************************************************/
91 class WidgetMouseEventBase
: public WidgetInputEvent
{
93 friend class dom::PBrowserParent
;
94 friend class dom::PBrowserChild
;
97 WidgetMouseEventBase()
102 // Including MouseEventBinding.h here leads to an include loop, so
103 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
105 inputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
107 WidgetMouseEventBase(bool aIsTrusted
, EventMessage aMessage
,
108 nsIWidget
* aWidget
, EventClassID aEventClassID
)
109 : WidgetInputEvent(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
114 // Including MouseEventBinding.h here leads to an include loop, so
115 // we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
117 inputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
120 virtual WidgetMouseEventBase
* AsMouseEventBase() override
{ return this; }
122 virtual WidgetEvent
* Duplicate() const override
{
123 MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
132 // Pressed button ID of mousedown or mouseup event.
133 // This is set only when pressing a button causes the event.
137 eNoButtonFlag
= 0x00,
138 eLeftButtonFlag
= 0x01,
139 eRightButtonFlag
= 0x02,
140 eMiddleButtonFlag
= 0x04,
141 // typicall, "back" button being left side of 5-button
142 // mice, see "buttons" attribute document of DOM3 Events.
143 e4thButtonFlag
= 0x08,
144 // typicall, "forward" button being right side of 5-button
145 // mice, see "buttons" attribute document of DOM3 Events.
146 e5thButtonFlag
= 0x10
149 // Flags of all pressed buttons at the event fired.
150 // This is set at any mouse event, don't be confused with |button|.
153 // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
155 // Touch near a cluster of links (true)
158 // Possible values a in MouseEvent
159 uint16_t inputSource
;
161 // ID of the canvas HitRegion
164 bool IsLeftButtonPressed() const { return !!(buttons
& eLeftButtonFlag
); }
165 bool IsRightButtonPressed() const { return !!(buttons
& eRightButtonFlag
); }
166 bool IsMiddleButtonPressed() const { return !!(buttons
& eMiddleButtonFlag
); }
167 bool Is4thButtonPressed() const { return !!(buttons
& e4thButtonFlag
); }
168 bool Is5thButtonPressed() const { return !!(buttons
& e5thButtonFlag
); }
170 void AssignMouseEventBaseData(const WidgetMouseEventBase
& aEvent
,
172 AssignInputEventData(aEvent
, aCopyTargets
);
174 button
= aEvent
.button
;
175 buttons
= aEvent
.buttons
;
176 pressure
= aEvent
.pressure
;
177 hitCluster
= aEvent
.hitCluster
;
178 inputSource
= aEvent
.inputSource
;
182 * Returns true if left click event.
184 bool IsLeftClickEvent() const {
185 return mMessage
== eMouseClick
&& button
== eLeftButton
;
189 /******************************************************************************
190 * mozilla::WidgetMouseEvent
191 ******************************************************************************/
193 class WidgetMouseEvent
: public WidgetMouseEventBase
,
194 public WidgetPointerHelper
{
196 friend class dom::PBrowserParent
;
197 friend class dom::PBrowserChild
;
200 typedef bool ReasonType
;
201 enum Reason
: ReasonType
{ eReal
, eSynthesized
};
203 typedef bool ContextMenuTriggerType
;
204 enum ContextMenuTrigger
: ContextMenuTriggerType
{ eNormal
, eContextMenuKey
};
206 typedef bool ExitFromType
;
207 enum ExitFrom
: ExitFromType
{ eChild
, eTopLevel
};
212 mContextMenuTrigger(eNormal
),
214 mIgnoreRootScrollFrame(false),
217 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
218 EventClassID aEventClassID
, Reason aReason
)
219 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, aEventClassID
),
221 mContextMenuTrigger(eNormal
),
223 mIgnoreRootScrollFrame(false),
227 virtual WidgetMouseEvent
* AsMouseEvent() override
{ return this; }
229 WidgetMouseEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
,
231 ContextMenuTrigger aContextMenuTrigger
= eNormal
)
232 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eMouseEventClass
),
234 mContextMenuTrigger(aContextMenuTrigger
),
236 mIgnoreRootScrollFrame(false),
238 if (aMessage
== eContextMenu
) {
239 button
= (mContextMenuTrigger
== eNormal
) ? eRightButton
: eLeftButton
;
244 virtual ~WidgetMouseEvent() {
245 NS_WARNING_ASSERTION(
246 mMessage
!= eContextMenu
||
248 ((mContextMenuTrigger
== eNormal
) ? eRightButton
: eLeftButton
),
249 "Wrong button set to eContextMenu event?");
253 virtual WidgetEvent
* Duplicate() const override
{
254 MOZ_ASSERT(mClass
== eMouseEventClass
,
255 "Duplicate() must be overridden by sub class");
256 // Not copying widget, it is a weak reference.
257 WidgetMouseEvent
* result
= new WidgetMouseEvent(
258 false, mMessage
, nullptr, mReason
, mContextMenuTrigger
);
259 result
->AssignMouseEventData(*this, true);
260 result
->mFlags
= mFlags
;
264 // If during mouseup handling we detect that click event might need to be
265 // dispatched, this is setup to be the target of the click event.
266 nsCOMPtr
<dom::EventTarget
> mClickTarget
;
268 // mReason indicates the reason why the event is fired:
269 // - Representing mouse operation.
270 // - Synthesized for emulating mousemove event when the content under the
271 // mouse cursor is scrolled.
274 // mContextMenuTrigger is valid only when mMessage is eContextMenu.
275 // This indicates if the context menu event is caused by context menu key or
276 // other reasons (typically, a click of right mouse button).
277 ContextMenuTrigger mContextMenuTrigger
;
279 // mExitFrom is valid only when mMessage is eMouseExitFromWidget.
280 // This indicates if the mouse cursor exits from a top level widget or
284 // Whether the event should ignore scroll frame bounds during dispatch.
285 bool mIgnoreRootScrollFrame
;
287 // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
288 // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
289 // Otherwise, this must be 0.
290 uint32_t mClickCount
;
292 void AssignMouseEventData(const WidgetMouseEvent
& aEvent
, bool aCopyTargets
) {
293 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
294 AssignPointerHelperData(aEvent
, /* aCopyCoalescedEvents */ true);
296 mIgnoreRootScrollFrame
= aEvent
.mIgnoreRootScrollFrame
;
297 mClickCount
= aEvent
.mClickCount
;
301 * Returns true if the event is a context menu event caused by key.
303 bool IsContextMenuKeyEvent() const {
304 return mMessage
== eContextMenu
&& mContextMenuTrigger
== eContextMenuKey
;
308 * Returns true if the event is a real mouse event. Otherwise, i.e., it's
309 * a synthesized event by scroll or something, returns false.
311 bool IsReal() const { return mReason
== eReal
; }
314 * Returns true if middle click paste is enabled.
316 static bool IsMiddleClickPasteEnabled();
319 /******************************************************************************
320 * mozilla::WidgetDragEvent
321 ******************************************************************************/
323 class WidgetDragEvent
: public WidgetMouseEvent
{
325 friend class mozilla::dom::PBrowserParent
;
326 friend class mozilla::dom::PBrowserChild
;
330 : mUserCancelled(false), mDefaultPreventedOnContent(false) {}
333 virtual WidgetDragEvent
* AsDragEvent() override
{ return this; }
335 WidgetDragEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
336 : WidgetMouseEvent(aIsTrusted
, aMessage
, aWidget
, eDragEventClass
, eReal
),
337 mUserCancelled(false),
338 mDefaultPreventedOnContent(false) {}
340 virtual WidgetEvent
* Duplicate() const override
{
341 MOZ_ASSERT(mClass
== eDragEventClass
,
342 "Duplicate() must be overridden by sub class");
343 // Not copying widget, it is a weak reference.
344 WidgetDragEvent
* result
= new WidgetDragEvent(false, mMessage
, nullptr);
345 result
->AssignDragEventData(*this, true);
346 result
->mFlags
= mFlags
;
350 // The dragging data.
351 nsCOMPtr
<dom::DataTransfer
> mDataTransfer
;
353 // If this is true, user has cancelled the drag operation.
355 // If this is true, the drag event's preventDefault() is called on content.
356 bool mDefaultPreventedOnContent
;
358 // XXX Not tested by test_assign_event_data.html
359 void AssignDragEventData(const WidgetDragEvent
& aEvent
, bool aCopyTargets
) {
360 AssignMouseEventData(aEvent
, aCopyTargets
);
362 mDataTransfer
= aEvent
.mDataTransfer
;
363 // XXX mUserCancelled isn't copied, is this intentionally?
364 mUserCancelled
= false;
365 mDefaultPreventedOnContent
= aEvent
.mDefaultPreventedOnContent
;
369 /******************************************************************************
370 * mozilla::WidgetMouseScrollEvent
372 * This is used for legacy DOM mouse scroll events, i.e.,
373 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
374 * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
375 ******************************************************************************/
377 class WidgetMouseScrollEvent
: public WidgetMouseEventBase
{
379 WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
382 virtual WidgetMouseScrollEvent
* AsMouseScrollEvent() override
{ return this; }
384 WidgetMouseScrollEvent(bool aIsTrusted
, EventMessage aMessage
,
386 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
,
387 eMouseScrollEventClass
),
389 mIsHorizontal(false) {}
391 virtual WidgetEvent
* Duplicate() const override
{
392 MOZ_ASSERT(mClass
== eMouseScrollEventClass
,
393 "Duplicate() must be overridden by sub class");
394 // Not copying widget, it is a weak reference.
395 WidgetMouseScrollEvent
* result
=
396 new WidgetMouseScrollEvent(false, mMessage
, nullptr);
397 result
->AssignMouseScrollEventData(*this, true);
398 result
->mFlags
= mFlags
;
402 // The delta value of mouse scroll event.
403 // If the event message is eLegacyMouseLineOrPageScroll, the value indicates
404 // scroll amount in lines. However, if the value is
405 // UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
406 // value inducates one page scroll. If the event message is
407 // eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
410 // If this is true, it may cause to scroll horizontally.
411 // Otherwise, vertically.
414 void AssignMouseScrollEventData(const WidgetMouseScrollEvent
& aEvent
,
416 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
418 mDelta
= aEvent
.mDelta
;
419 mIsHorizontal
= aEvent
.mIsHorizontal
;
423 /******************************************************************************
424 * mozilla::WidgetWheelEvent
425 ******************************************************************************/
427 class WidgetWheelEvent
: public WidgetMouseEventBase
{
429 friend class mozilla::dom::PBrowserParent
;
430 friend class mozilla::dom::PBrowserChild
;
436 mOverflowDeltaX(0.0),
438 // Including WheelEventBinding.h here leads to an include loop, so
439 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
441 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
442 mLineOrPageDeltaX(0),
443 mLineOrPageDeltaY(0),
444 mScrollType(SCROLL_DEFAULT
),
445 mCustomizedByUserPrefs(false),
446 mMayHaveMomentum(false),
448 mIsNoLineOrPageDelta(false),
449 mViewPortIsOverscrolled(false),
450 mCanTriggerSwipe(false),
451 mAllowToOverrideSystemScrollSpeed(false),
452 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
455 virtual WidgetWheelEvent
* AsWheelEvent() override
{ return this; }
457 WidgetWheelEvent(bool aIsTrusted
, EventMessage aMessage
, nsIWidget
* aWidget
)
458 : WidgetMouseEventBase(aIsTrusted
, aMessage
, aWidget
, eWheelEventClass
),
462 mOverflowDeltaX(0.0),
464 // Including WheelEventBinding.h here leads to an include loop, so
465 // we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
467 mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
468 mLineOrPageDeltaX(0),
469 mLineOrPageDeltaY(0),
470 mScrollType(SCROLL_DEFAULT
),
471 mCustomizedByUserPrefs(false),
472 mMayHaveMomentum(false),
474 mIsNoLineOrPageDelta(false),
475 mViewPortIsOverscrolled(false),
476 mCanTriggerSwipe(false),
477 mAllowToOverrideSystemScrollSpeed(true),
478 mDeltaValuesHorizontalizedForDefaultHandler(false) {}
480 virtual WidgetEvent
* Duplicate() const override
{
481 MOZ_ASSERT(mClass
== eWheelEventClass
,
482 "Duplicate() must be overridden by sub class");
483 // Not copying widget, it is a weak reference.
484 WidgetWheelEvent
* result
= new WidgetWheelEvent(false, mMessage
, nullptr);
485 result
->AssignWheelEventData(*this, true);
486 result
->mFlags
= mFlags
;
490 // On OS X, scroll gestures that start at the edge of the scrollable range
491 // can result in a swipe gesture. For the first wheel event of such a
492 // gesture, call TriggersSwipe() after the event has been processed
493 // in order to find out whether a swipe should be started.
494 bool TriggersSwipe() const {
495 return mCanTriggerSwipe
&& mViewPortIsOverscrolled
&&
496 this->mOverflowDeltaX
!= 0.0;
499 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
500 // mousewheel.*.delta_multiplier_* prefs which are applied by
501 // EventStateManager. So, after widget dispatches this event,
502 // these delta values may have different values than before.
507 // overflowed delta values for scroll, these values are set by
508 // EventStateManger. If the default action of the wheel event isn't scroll,
509 // these values are always zero. Otherwise, remaining delta values which are
510 // not used by scroll are set.
511 // NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
512 // However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
513 // delta values which are not applied the delta_multiplier prefs.
514 // So, if widget wanted to know the actual direction to be scrolled,
515 // it would need to check the mDeltaX and mDeltaY.
516 double mOverflowDeltaX
;
517 double mOverflowDeltaY
;
519 // Should be one of WheelEvent_Binding::DOM_DELTA_*
522 // If widget sets mLineOrPageDelta, EventStateManager will dispatch
523 // eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
524 // value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
525 int32_t mLineOrPageDeltaX
;
526 int32_t mLineOrPageDeltaY
;
528 // When the default action for an wheel event is moving history or zooming,
529 // need to chose a delta value for doing it.
530 int32_t GetPreferredIntDelta() {
531 if (!mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
534 if (mLineOrPageDeltaY
&& !mLineOrPageDeltaX
) {
535 return mLineOrPageDeltaY
;
537 if (mLineOrPageDeltaX
&& !mLineOrPageDeltaY
) {
538 return mLineOrPageDeltaX
;
540 if ((mLineOrPageDeltaX
< 0 && mLineOrPageDeltaY
> 0) ||
541 (mLineOrPageDeltaX
> 0 && mLineOrPageDeltaY
< 0)) {
542 return 0; // We cannot guess the answer in this case.
544 return (Abs(mLineOrPageDeltaX
) > Abs(mLineOrPageDeltaY
))
550 // The default value is SCROLL_DEFAULT, which means EventStateManager will
551 // select preferred scroll type automatically.
552 enum ScrollType
: uint8_t {
554 SCROLL_SYNCHRONOUSLY
,
555 SCROLL_ASYNCHRONOUSELY
,
558 ScrollType mScrollType
;
560 // If the delta values are computed from prefs, this value is true.
561 // Otherwise, i.e., they are computed from native events, false.
562 bool mCustomizedByUserPrefs
;
564 // true if the momentum events directly tied to this event may follow it.
565 bool mMayHaveMomentum
;
566 // true if the event is caused by momentum.
569 // If device event handlers don't know when they should set mLineOrPageDeltaX
570 // and mLineOrPageDeltaY, this is true. Otherwise, false.
571 // If mIsNoLineOrPageDelta is true, ESM will generate
572 // eLegacyMouseLineOrPageScroll events when accumulated delta values reach
574 bool mIsNoLineOrPageDelta
;
576 // Whether or not the parent of the currently overscrolled frame is the
577 // ViewPort. This is false in situations when an element on the page is being
578 // overscrolled (such as a text field), but true when the 'page' is being
580 bool mViewPortIsOverscrolled
;
582 // The wheel event can trigger a swipe to start if it's overscrolling the
584 bool mCanTriggerSwipe
;
586 // If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
587 // overridden. Otherwise, the scroll speed won't be overridden even if
588 // it's enabled by the pref.
589 bool mAllowToOverrideSystemScrollSpeed
;
591 // After the event's default action handler has adjusted its delta's values
592 // for horizontalizing a vertical wheel scroll, this variable will be set to
594 bool mDeltaValuesHorizontalizedForDefaultHandler
;
596 void AssignWheelEventData(const WidgetWheelEvent
& aEvent
, bool aCopyTargets
) {
597 AssignMouseEventBaseData(aEvent
, aCopyTargets
);
599 mDeltaX
= aEvent
.mDeltaX
;
600 mDeltaY
= aEvent
.mDeltaY
;
601 mDeltaZ
= aEvent
.mDeltaZ
;
602 mDeltaMode
= aEvent
.mDeltaMode
;
603 mCustomizedByUserPrefs
= aEvent
.mCustomizedByUserPrefs
;
604 mMayHaveMomentum
= aEvent
.mMayHaveMomentum
;
605 mIsMomentum
= aEvent
.mIsMomentum
;
606 mIsNoLineOrPageDelta
= aEvent
.mIsNoLineOrPageDelta
;
607 mLineOrPageDeltaX
= aEvent
.mLineOrPageDeltaX
;
608 mLineOrPageDeltaY
= aEvent
.mLineOrPageDeltaY
;
609 mScrollType
= aEvent
.mScrollType
;
610 mOverflowDeltaX
= aEvent
.mOverflowDeltaX
;
611 mOverflowDeltaY
= aEvent
.mOverflowDeltaY
;
612 mViewPortIsOverscrolled
= aEvent
.mViewPortIsOverscrolled
;
613 mCanTriggerSwipe
= aEvent
.mCanTriggerSwipe
;
614 mAllowToOverrideSystemScrollSpeed
=
615 aEvent
.mAllowToOverrideSystemScrollSpeed
;
616 mDeltaValuesHorizontalizedForDefaultHandler
=
617 aEvent
.mDeltaValuesHorizontalizedForDefaultHandler
;
620 // System scroll speed settings may be too slow at using Gecko. In such
621 // case, we should override the scroll speed computed with system settings.
622 // Following methods return preferred delta values which are multiplied by
623 // factors specified by prefs. If system scroll speed shouldn't be
624 // overridden (e.g., this feature is disabled by pref), they return raw
626 double OverriddenDeltaX() const;
627 double OverriddenDeltaY() const;
629 // Compute the overridden delta value. This may be useful for suppressing
630 // too fast scroll by system scroll speed overriding when widget sets
631 // mAllowToOverrideSystemScrollSpeed.
632 static double ComputeOverriddenDelta(double aDelta
, bool aIsForVertical
);
635 static bool sInitialized
;
636 static bool sIsSystemScrollSpeedOverrideEnabled
;
637 static int32_t sOverrideFactorX
;
638 static int32_t sOverrideFactorY
;
639 static void Initialize();
642 /******************************************************************************
643 * mozilla::WidgetPointerEvent
644 ******************************************************************************/
646 class WidgetPointerEvent
: public WidgetMouseEvent
{
647 friend class mozilla::dom::PBrowserParent
;
648 friend class mozilla::dom::PBrowserChild
;
650 WidgetPointerEvent() : mWidth(1), mHeight(1), mIsPrimary(true) {}
653 virtual WidgetPointerEvent
* AsPointerEvent() override
{ return this; }
655 WidgetPointerEvent(bool aIsTrusted
, EventMessage aMsg
, nsIWidget
* w
)
656 : WidgetMouseEvent(aIsTrusted
, aMsg
, w
, ePointerEventClass
, eReal
),
661 explicit WidgetPointerEvent(const WidgetMouseEvent
& aEvent
)
662 : WidgetMouseEvent(aEvent
), mWidth(1), mHeight(1), mIsPrimary(true) {
663 mClass
= ePointerEventClass
;
666 virtual WidgetEvent
* Duplicate() const override
{
667 MOZ_ASSERT(mClass
== ePointerEventClass
,
668 "Duplicate() must be overridden by sub class");
669 // Not copying widget, it is a weak reference.
670 WidgetPointerEvent
* result
=
671 new WidgetPointerEvent(false, mMessage
, nullptr);
672 result
->AssignPointerEventData(*this, true);
673 result
->mFlags
= mFlags
;
681 // XXX Not tested by test_assign_event_data.html
682 void AssignPointerEventData(const WidgetPointerEvent
& aEvent
,
684 AssignMouseEventData(aEvent
, aCopyTargets
);
686 mWidth
= aEvent
.mWidth
;
687 mHeight
= aEvent
.mHeight
;
688 mIsPrimary
= aEvent
.mIsPrimary
;
692 } // namespace mozilla
694 #endif // mozilla_MouseEvents_h__