michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_MouseEvents_h__ michael@0: #define mozilla_MouseEvents_h__ michael@0: michael@0: #include michael@0: michael@0: #include "mozilla/BasicEvents.h" michael@0: #include "mozilla/MathAlgorithms.h" michael@0: #include "mozilla/dom/DataTransfer.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIDOMMouseEvent.h" michael@0: #include "nsIDOMWheelEvent.h" michael@0: michael@0: /****************************************************************************** michael@0: * nsDragDropEventStatus michael@0: ******************************************************************************/ michael@0: michael@0: enum nsDragDropEventStatus michael@0: { michael@0: // The event is a enter michael@0: nsDragDropEventStatus_eDragEntered, michael@0: // The event is exit michael@0: nsDragDropEventStatus_eDragExited, michael@0: // The event is drop michael@0: nsDragDropEventStatus_eDrop michael@0: }; michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace dom { michael@0: class PBrowserParent; michael@0: class PBrowserChild; michael@0: } // namespace dom michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetPointerHelper michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetPointerHelper michael@0: { michael@0: public: michael@0: bool convertToPointer; michael@0: uint32_t pointerId; michael@0: uint32_t tiltX; michael@0: uint32_t tiltY; michael@0: michael@0: WidgetPointerHelper() : convertToPointer(true), pointerId(0), tiltX(0), tiltY(0) {} michael@0: michael@0: void AssignPointerHelperData(const WidgetPointerHelper& aEvent) michael@0: { michael@0: convertToPointer = aEvent.convertToPointer; michael@0: pointerId = aEvent.pointerId; michael@0: tiltX = aEvent.tiltX; michael@0: tiltY = aEvent.tiltY; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetMouseEventBase michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetMouseEventBase : public WidgetInputEvent michael@0: { michael@0: private: michael@0: friend class dom::PBrowserParent; michael@0: friend class dom::PBrowserChild; michael@0: michael@0: protected: michael@0: WidgetMouseEventBase() michael@0: { michael@0: } michael@0: michael@0: WidgetMouseEventBase(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, michael@0: nsEventStructType aStructType) : michael@0: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aStructType), michael@0: button(0), buttons(0), pressure(0), michael@0: inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) michael@0: { michael@0: } michael@0: michael@0: public: michael@0: virtual WidgetMouseEventBase* AsMouseEventBase() MOZ_OVERRIDE { return this; } michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_CRASH("WidgetMouseEventBase must not be most-subclass"); michael@0: return nullptr; michael@0: } michael@0: michael@0: /// The possible related target michael@0: nsCOMPtr relatedTarget; michael@0: michael@0: enum buttonType michael@0: { michael@0: eLeftButton = 0, michael@0: eMiddleButton = 1, michael@0: eRightButton = 2 michael@0: }; michael@0: // Pressed button ID of mousedown or mouseup event. michael@0: // This is set only when pressing a button causes the event. michael@0: int16_t button; michael@0: michael@0: enum buttonsFlag { michael@0: eLeftButtonFlag = 0x01, michael@0: eRightButtonFlag = 0x02, michael@0: eMiddleButtonFlag = 0x04, michael@0: // typicall, "back" button being left side of 5-button michael@0: // mice, see "buttons" attribute document of DOM3 Events. michael@0: e4thButtonFlag = 0x08, michael@0: // typicall, "forward" button being right side of 5-button michael@0: // mice, see "buttons" attribute document of DOM3 Events. michael@0: e5thButtonFlag = 0x10 michael@0: }; michael@0: michael@0: // Flags of all pressed buttons at the event fired. michael@0: // This is set at any mouse event, don't be confused with |button|. michael@0: int16_t buttons; michael@0: michael@0: // Finger or touch pressure of event. It ranges between 0.0 and 1.0. michael@0: float pressure; michael@0: michael@0: // Possible values at nsIDOMMouseEvent michael@0: uint16_t inputSource; michael@0: michael@0: void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent, michael@0: bool aCopyTargets) michael@0: { michael@0: AssignInputEventData(aEvent, aCopyTargets); michael@0: michael@0: relatedTarget = aCopyTargets ? aEvent.relatedTarget : nullptr; michael@0: button = aEvent.button; michael@0: buttons = aEvent.buttons; michael@0: pressure = aEvent.pressure; michael@0: inputSource = aEvent.inputSource; michael@0: } michael@0: michael@0: /** michael@0: * Returns true if left click event. michael@0: */ michael@0: bool IsLeftClickEvent() const michael@0: { michael@0: return message == NS_MOUSE_CLICK && button == eLeftButton; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetMouseEvent michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetMouseEvent : public WidgetMouseEventBase, public WidgetPointerHelper michael@0: { michael@0: private: michael@0: friend class mozilla::dom::PBrowserParent; michael@0: friend class mozilla::dom::PBrowserChild; michael@0: michael@0: public: michael@0: enum reasonType michael@0: { michael@0: eReal, michael@0: eSynthesized michael@0: }; michael@0: michael@0: enum contextType michael@0: { michael@0: eNormal, michael@0: eContextMenuKey michael@0: }; michael@0: michael@0: enum exitType michael@0: { michael@0: eChild, michael@0: eTopLevel michael@0: }; michael@0: michael@0: protected: michael@0: WidgetMouseEvent() michael@0: { michael@0: } michael@0: michael@0: WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, michael@0: nsEventStructType aStructType, reasonType aReason) : michael@0: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aStructType), michael@0: acceptActivation(false), ignoreRootScrollFrame(false), michael@0: reason(aReason), context(eNormal), exit(eChild), clickCount(0) michael@0: { michael@0: switch (aMessage) { michael@0: case NS_MOUSEENTER: michael@0: case NS_MOUSELEAVE: michael@0: mFlags.mBubbles = false; michael@0: mFlags.mCancelable = false; michael@0: break; michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: michael@0: public: michael@0: virtual WidgetMouseEvent* AsMouseEvent() MOZ_OVERRIDE { return this; } michael@0: michael@0: WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, michael@0: reasonType aReason, contextType aContext = eNormal) : michael@0: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_MOUSE_EVENT), michael@0: acceptActivation(false), ignoreRootScrollFrame(false), michael@0: reason(aReason), context(aContext), exit(eChild), clickCount(0) michael@0: { michael@0: switch (aMessage) { michael@0: case NS_MOUSEENTER: michael@0: case NS_MOUSELEAVE: michael@0: mFlags.mBubbles = false; michael@0: mFlags.mCancelable = false; michael@0: break; michael@0: case NS_CONTEXTMENU: michael@0: button = (context == eNormal) ? eRightButton : eLeftButton; michael@0: break; michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: virtual ~WidgetMouseEvent() michael@0: { michael@0: NS_WARN_IF_FALSE(message != NS_CONTEXTMENU || michael@0: button == michael@0: ((context == eNormal) ? eRightButton : eLeftButton), michael@0: "Wrong button set to NS_CONTEXTMENU event?"); michael@0: } michael@0: #endif michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_ASSERT(eventStructType == NS_MOUSE_EVENT, michael@0: "Duplicate() must be overridden by sub class"); michael@0: // Not copying widget, it is a weak reference. michael@0: WidgetMouseEvent* result = michael@0: new WidgetMouseEvent(false, message, nullptr, reason, context); michael@0: result->AssignMouseEventData(*this, true); michael@0: result->mFlags = mFlags; michael@0: return result; michael@0: } michael@0: michael@0: // Special return code for MOUSE_ACTIVATE to signal. michael@0: // If the target accepts activation (1), or denies it (0). michael@0: bool acceptActivation; michael@0: // Whether the event should ignore scroll frame bounds during dispatch. michael@0: bool ignoreRootScrollFrame; michael@0: michael@0: reasonType reason : 4; michael@0: contextType context : 4; michael@0: exitType exit; michael@0: michael@0: /// The number of mouse clicks. michael@0: uint32_t clickCount; michael@0: michael@0: void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets) michael@0: { michael@0: AssignMouseEventBaseData(aEvent, aCopyTargets); michael@0: AssignPointerHelperData(aEvent); michael@0: michael@0: acceptActivation = aEvent.acceptActivation; michael@0: ignoreRootScrollFrame = aEvent.ignoreRootScrollFrame; michael@0: clickCount = aEvent.clickCount; michael@0: } michael@0: michael@0: /** michael@0: * Returns true if the event is a context menu event caused by key. michael@0: */ michael@0: bool IsContextMenuKeyEvent() const michael@0: { michael@0: return message == NS_CONTEXTMENU && context == eContextMenuKey; michael@0: } michael@0: michael@0: /** michael@0: * Returns true if the event is a real mouse event. Otherwise, i.e., it's michael@0: * a synthesized event by scroll or something, returns false. michael@0: */ michael@0: bool IsReal() const michael@0: { michael@0: return reason == eReal; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetDragEvent michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetDragEvent : public WidgetMouseEvent michael@0: { michael@0: public: michael@0: virtual WidgetDragEvent* AsDragEvent() MOZ_OVERRIDE { return this; } michael@0: michael@0: WidgetDragEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : michael@0: WidgetMouseEvent(aIsTrusted, aMessage, aWidget, NS_DRAG_EVENT, eReal), michael@0: userCancelled(false), mDefaultPreventedOnContent(false) michael@0: { michael@0: mFlags.mCancelable = michael@0: (aMessage != NS_DRAGDROP_EXIT_SYNTH && michael@0: aMessage != NS_DRAGDROP_LEAVE_SYNTH && michael@0: aMessage != NS_DRAGDROP_END); michael@0: } michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_ASSERT(eventStructType == NS_DRAG_EVENT, michael@0: "Duplicate() must be overridden by sub class"); michael@0: // Not copying widget, it is a weak reference. michael@0: WidgetDragEvent* result = new WidgetDragEvent(false, message, nullptr); michael@0: result->AssignDragEventData(*this, true); michael@0: result->mFlags = mFlags; michael@0: return result; michael@0: } michael@0: michael@0: // The dragging data. michael@0: nsCOMPtr dataTransfer; michael@0: michael@0: // If this is true, user has cancelled the drag operation. michael@0: bool userCancelled; michael@0: // If this is true, the drag event's preventDefault() is called on content. michael@0: bool mDefaultPreventedOnContent; michael@0: michael@0: // XXX Not tested by test_assign_event_data.html michael@0: void AssignDragEventData(const WidgetDragEvent& aEvent, bool aCopyTargets) michael@0: { michael@0: AssignMouseEventData(aEvent, aCopyTargets); michael@0: michael@0: dataTransfer = aEvent.dataTransfer; michael@0: // XXX userCancelled isn't copied, is this instentionally? michael@0: userCancelled = false; michael@0: mDefaultPreventedOnContent = aEvent.mDefaultPreventedOnContent; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetMouseScrollEvent michael@0: * michael@0: * This is used for legacy DOM mouse scroll events, i.e., michael@0: * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled michael@0: * by ESM even if widget dispatches them. Use new WidgetWheelEvent instead. michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetMouseScrollEvent : public WidgetMouseEventBase michael@0: { michael@0: private: michael@0: WidgetMouseScrollEvent() michael@0: { michael@0: } michael@0: michael@0: public: michael@0: virtual WidgetMouseScrollEvent* AsMouseScrollEvent() MOZ_OVERRIDE michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: WidgetMouseScrollEvent(bool aIsTrusted, uint32_t aMessage, michael@0: nsIWidget* aWidget) : michael@0: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_MOUSE_SCROLL_EVENT), michael@0: delta(0), isHorizontal(false) michael@0: { michael@0: } michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_ASSERT(eventStructType == NS_MOUSE_SCROLL_EVENT, michael@0: "Duplicate() must be overridden by sub class"); michael@0: // Not copying widget, it is a weak reference. michael@0: WidgetMouseScrollEvent* result = michael@0: new WidgetMouseScrollEvent(false, message, nullptr); michael@0: result->AssignMouseScrollEventData(*this, true); michael@0: result->mFlags = mFlags; michael@0: return result; michael@0: } michael@0: michael@0: // The delta value of mouse scroll event. michael@0: // If the event message is NS_MOUSE_SCROLL, the value indicates scroll amount michael@0: // in lines. However, if the value is nsIDOMUIEvent::SCROLL_PAGE_UP or michael@0: // nsIDOMUIEvent::SCROLL_PAGE_DOWN, the value inducates one page scroll. michael@0: // If the event message is NS_MOUSE_PIXEL_SCROLL, the value indicates scroll michael@0: // amount in pixels. michael@0: int32_t delta; michael@0: michael@0: // If this is true, it may cause to scroll horizontally. michael@0: // Otherwise, vertically. michael@0: bool isHorizontal; michael@0: michael@0: void AssignMouseScrollEventData(const WidgetMouseScrollEvent& aEvent, michael@0: bool aCopyTargets) michael@0: { michael@0: AssignMouseEventBaseData(aEvent, aCopyTargets); michael@0: michael@0: delta = aEvent.delta; michael@0: isHorizontal = aEvent.isHorizontal; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetWheelEvent michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetWheelEvent : public WidgetMouseEventBase michael@0: { michael@0: private: michael@0: friend class mozilla::dom::PBrowserParent; michael@0: friend class mozilla::dom::PBrowserChild; michael@0: michael@0: WidgetWheelEvent() michael@0: { michael@0: } michael@0: michael@0: public: michael@0: virtual WidgetWheelEvent* AsWheelEvent() MOZ_OVERRIDE { return this; } michael@0: michael@0: WidgetWheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : michael@0: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT), michael@0: deltaX(0.0), deltaY(0.0), deltaZ(0.0), michael@0: deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL), michael@0: customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false), michael@0: lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT), michael@0: overflowDeltaX(0.0), overflowDeltaY(0.0), michael@0: mViewPortIsOverscrolled(false) michael@0: { michael@0: } michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_ASSERT(eventStructType == NS_WHEEL_EVENT, michael@0: "Duplicate() must be overridden by sub class"); michael@0: // Not copying widget, it is a weak reference. michael@0: WidgetWheelEvent* result = new WidgetWheelEvent(false, message, nullptr); michael@0: result->AssignWheelEventData(*this, true); michael@0: result->mFlags = mFlags; michael@0: return result; michael@0: } michael@0: michael@0: // NOTE: deltaX, deltaY and deltaZ may be customized by michael@0: // mousewheel.*.delta_multiplier_* prefs which are applied by michael@0: // EventStateManager. So, after widget dispatches this event, michael@0: // these delta values may have different values than before. michael@0: double deltaX; michael@0: double deltaY; michael@0: double deltaZ; michael@0: michael@0: // Should be one of nsIDOMWheelEvent::DOM_DELTA_* michael@0: uint32_t deltaMode; michael@0: michael@0: // Following members are for internal use only, not for DOM event. michael@0: michael@0: // If the delta values are computed from prefs, this value is true. michael@0: // Otherwise, i.e., they are computed from native events, false. michael@0: bool customizedByUserPrefs; michael@0: michael@0: // true if the event is caused by momentum. michael@0: bool isMomentum; michael@0: michael@0: // If device event handlers don't know when they should set lineOrPageDeltaX michael@0: // and lineOrPageDeltaY, this is true. Otherwise, false. michael@0: // If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events michael@0: // when accumulated pixel delta values reach a line height. michael@0: bool isPixelOnlyDevice; michael@0: michael@0: // If widget sets lineOrPageDelta, EventStateManager will dispatch michael@0: // NS_MOUSE_SCROLL event for compatibility. Note that the delta value means michael@0: // pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines. michael@0: int32_t lineOrPageDeltaX; michael@0: int32_t lineOrPageDeltaY; michael@0: michael@0: // When the default action for an wheel event is moving history or zooming, michael@0: // need to chose a delta value for doing it. michael@0: int32_t GetPreferredIntDelta() michael@0: { michael@0: if (!lineOrPageDeltaX && !lineOrPageDeltaY) { michael@0: return 0; michael@0: } michael@0: if (lineOrPageDeltaY && !lineOrPageDeltaX) { michael@0: return lineOrPageDeltaY; michael@0: } michael@0: if (lineOrPageDeltaX && !lineOrPageDeltaY) { michael@0: return lineOrPageDeltaX; michael@0: } michael@0: if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) || michael@0: (lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) { michael@0: return 0; // We cannot guess the answer in this case. michael@0: } michael@0: return (Abs(lineOrPageDeltaX) > Abs(lineOrPageDeltaY)) ? michael@0: lineOrPageDeltaX : lineOrPageDeltaY; michael@0: } michael@0: michael@0: // Scroll type michael@0: // The default value is SCROLL_DEFAULT, which means EventStateManager will michael@0: // select preferred scroll type automatically. michael@0: enum ScrollType michael@0: { michael@0: SCROLL_DEFAULT, michael@0: SCROLL_SYNCHRONOUSLY, michael@0: SCROLL_ASYNCHRONOUSELY, michael@0: SCROLL_SMOOTHLY michael@0: }; michael@0: ScrollType scrollType; michael@0: michael@0: // overflowed delta values for scroll, these values are set by michael@0: // nsEventStateManger. If the default action of the wheel event isn't scroll, michael@0: // these values always zero. Otherwise, remaning delta values which are michael@0: // not used by scroll are set. michael@0: // NOTE: deltaX, deltaY and deltaZ may be modified by EventStateManager. michael@0: // However, overflowDeltaX and overflowDeltaY indicate unused original michael@0: // delta values which are not applied the delta_multiplier prefs. michael@0: // So, if widget wanted to know the actual direction to be scrolled, michael@0: // it would need to check the deltaX and deltaY. michael@0: double overflowDeltaX; michael@0: double overflowDeltaY; michael@0: michael@0: // Whether or not the parent of the currently overscrolled frame is the michael@0: // ViewPort. This is false in situations when an element on the page is being michael@0: // overscrolled (such as a text field), but true when the 'page' is being michael@0: // overscrolled. michael@0: bool mViewPortIsOverscrolled; michael@0: michael@0: void AssignWheelEventData(const WidgetWheelEvent& aEvent, bool aCopyTargets) michael@0: { michael@0: AssignMouseEventBaseData(aEvent, aCopyTargets); michael@0: michael@0: deltaX = aEvent.deltaX; michael@0: deltaY = aEvent.deltaY; michael@0: deltaZ = aEvent.deltaZ; michael@0: deltaMode = aEvent.deltaMode; michael@0: customizedByUserPrefs = aEvent.customizedByUserPrefs; michael@0: isMomentum = aEvent.isMomentum; michael@0: isPixelOnlyDevice = aEvent.isPixelOnlyDevice; michael@0: lineOrPageDeltaX = aEvent.lineOrPageDeltaX; michael@0: lineOrPageDeltaY = aEvent.lineOrPageDeltaY; michael@0: scrollType = aEvent.scrollType; michael@0: overflowDeltaX = aEvent.overflowDeltaX; michael@0: overflowDeltaY = aEvent.overflowDeltaY; michael@0: mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled; michael@0: } michael@0: }; michael@0: michael@0: /****************************************************************************** michael@0: * mozilla::WidgetPointerEvent michael@0: ******************************************************************************/ michael@0: michael@0: class WidgetPointerEvent : public WidgetMouseEvent michael@0: { michael@0: friend class mozilla::dom::PBrowserParent; michael@0: friend class mozilla::dom::PBrowserChild; michael@0: michael@0: WidgetPointerEvent() michael@0: { michael@0: } michael@0: michael@0: public: michael@0: virtual WidgetPointerEvent* AsPointerEvent() MOZ_OVERRIDE { return this; } michael@0: michael@0: WidgetPointerEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget* w) michael@0: : WidgetMouseEvent(aIsTrusted, aMsg, w, NS_POINTER_EVENT, eReal) michael@0: , width(0) michael@0: , height(0) michael@0: , isPrimary(true) michael@0: { michael@0: UpdateFlags(); michael@0: } michael@0: michael@0: WidgetPointerEvent(const WidgetMouseEvent& aEvent) michael@0: : WidgetMouseEvent(aEvent) michael@0: , width(0) michael@0: , height(0) michael@0: , isPrimary(true) michael@0: { michael@0: eventStructType = NS_POINTER_EVENT; michael@0: UpdateFlags(); michael@0: } michael@0: michael@0: void UpdateFlags() michael@0: { michael@0: switch (message) { michael@0: case NS_POINTER_ENTER: michael@0: case NS_POINTER_LEAVE: michael@0: mFlags.mBubbles = false; michael@0: mFlags.mCancelable = false; michael@0: break; michael@0: case NS_POINTER_CANCEL: michael@0: case NS_POINTER_GOT_CAPTURE: michael@0: case NS_POINTER_LOST_CAPTURE: michael@0: mFlags.mCancelable = false; michael@0: break; michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: michael@0: virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE michael@0: { michael@0: MOZ_ASSERT(eventStructType == NS_POINTER_EVENT, michael@0: "Duplicate() must be overridden by sub class"); michael@0: // Not copying widget, it is a weak reference. michael@0: WidgetPointerEvent* result = michael@0: new WidgetPointerEvent(false, message, nullptr); michael@0: result->AssignPointerEventData(*this, true); michael@0: result->mFlags = mFlags; michael@0: return result; michael@0: } michael@0: michael@0: uint32_t width; michael@0: uint32_t height; michael@0: bool isPrimary; michael@0: michael@0: // XXX Not tested by test_assign_event_data.html michael@0: void AssignPointerEventData(const WidgetPointerEvent& aEvent, michael@0: bool aCopyTargets) michael@0: { michael@0: AssignMouseEventData(aEvent, aCopyTargets); michael@0: michael@0: width = aEvent.width; michael@0: height = aEvent.height; michael@0: isPrimary = aEvent.isPrimary; michael@0: } michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_MouseEvents_h__