Bug 912956 part.5 Create mozilla/MouseEvents.h r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 24 Sep 2013 19:04:15 +0900
changeset 163198 354ac52e532516e169ff2769bedcf6e57cfcbcc5
parent 163197 ff21dedcf8e743db1ebc461d34a10601e8a3e664
child 163199 93a96f509d9a1a3cada77f275c6e317e903813cc
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs912956
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 912956 part.5 Create mozilla/MouseEvents.h r=roc
widget/BasicEvents.h
widget/EventForwards.h
widget/MouseEvents.h
widget/moz.build
widget/nsGUIEvent.h
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -31,21 +31,21 @@ enum nsEventStructType
 
   // TextEvents.h
   NS_KEY_EVENT,                      // WidgetKeyboardEvent
   NS_COMPOSITION_EVENT,              // WidgetCompositionEvent
   NS_TEXT_EVENT,                     // WidgetTextEvent
   NS_QUERY_CONTENT_EVENT,            // WidgetQueryContentEvent
   NS_SELECTION_EVENT,                // WidgetSelectionEvent
 
-  // Mouse related events
-  NS_MOUSE_EVENT,                    // nsMouseEvent
-  NS_MOUSE_SCROLL_EVENT,             // nsMouseScrollEvent
-  NS_DRAG_EVENT,                     // nsDragEvent
-  NS_WHEEL_EVENT,                    // WheelEvent
+  // MouseEvents.h
+  NS_MOUSE_EVENT,                    // WidgetMouseEvent
+  NS_DRAG_EVENT,                     // WidgetDragEvent
+  NS_MOUSE_SCROLL_EVENT,             // WidgetMouseScrollEvent
+  NS_WHEEL_EVENT,                    // WidgetWheelEvent
 
   // Touchpad related events
   NS_GESTURENOTIFY_EVENT,            // nsGestureNotifyEvent
   NS_SIMPLE_GESTURE_EVENT,           // nsSimpleGestureEvent
   NS_TOUCH_EVENT,                    // nsTouchEvent
 
   // Scroll related events
   NS_SCROLLPORT_EVENT,               // nsScrollPortEvent
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -65,26 +65,23 @@ struct TextRange;
 
 typedef TextRange* TextRangeArray;
 
 class WidgetKeyboardEvent;
 class WidgetTextEvent;
 class WidgetCompositionEvent;
 class WidgetQueryContentEvent;
 class WidgetSelectionEvent;
-} // namespace mozilla
 
 // MouseEvents.h
-class nsMouseEvent_base;
-class nsMouseEvent;
-class nsDragEvent;
-class nsMouseScrollEvent;
-
-namespace mozilla {
-class WheelEvent;
+class WidgetMouseEventBase;
+class WidgetMouseEvent;
+class WidgetDragEvent;
+class WidgetMouseScrollEvent;
+class WidgetWheelEvent;
 } // namespace mozilla
 
 // TouchEvents.h
 class nsGestureNotifyEvent;
 class nsTouchEvent;
 class nsSimpleGestureEvent;
 
 // ContentEvents.h
@@ -114,10 +111,18 @@ typedef mozilla::AlternativeCharCode    
 typedef mozilla::WidgetKeyboardEvent      nsKeyEvent;
 typedef mozilla::TextRangeStyle           nsTextRangeStyle;
 typedef mozilla::TextRange                nsTextRange;
 typedef mozilla::TextRangeArray           nsTextRangeArray;
 typedef mozilla::WidgetTextEvent          nsTextEvent;
 typedef mozilla::WidgetCompositionEvent   nsCompositionEvent;
 typedef mozilla::WidgetQueryContentEvent  nsQueryContentEvent;
 typedef mozilla::WidgetSelectionEvent     nsSelectionEvent;
+typedef mozilla::WidgetMouseEventBase     nsMouseEvent_base;
+typedef mozilla::WidgetMouseEvent         nsMouseEvent;
+typedef mozilla::WidgetDragEvent          nsDragEvent;
+typedef mozilla::WidgetMouseScrollEvent   nsMouseScrollEvent;
+
+namespace mozilla {
+typedef WidgetWheelEvent                  WheelEvent;
+}
 
 #endif // mozilla_EventForwards_h__
new file mode 100644
--- /dev/null
+++ b/widget/MouseEvents.h
@@ -0,0 +1,432 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_MouseEvents_h__
+#define mozilla_MouseEvents_h__
+
+#include <stdint.h>
+
+#include "mozilla/BasicEvents.h"
+#include "mozilla/MathAlgorithms.h"
+#include "nsCOMPtr.h"
+#include "nsIDOMDataTransfer.h"
+#include "nsIDOMMouseEvent.h"
+#include "nsIDOMWheelEvent.h"
+
+/******************************************************************************
+ * nsDragDropEventStatus
+ ******************************************************************************/
+
+enum nsDragDropEventStatus
+{  
+  // The event is a enter
+  nsDragDropEventStatus_eDragEntered,
+  // The event is exit
+  nsDragDropEventStatus_eDragExited,
+  // The event is drop
+  nsDragDropEventStatus_eDrop
+};
+
+namespace mozilla {
+
+namespace dom {
+  class PBrowserParent;
+  class PBrowserChild;
+} // namespace dom
+
+/******************************************************************************
+ * mozilla::WidgetMouseEventBase
+ ******************************************************************************/
+
+class WidgetMouseEventBase : public WidgetInputEvent
+{
+private:
+  friend class dom::PBrowserParent;
+  friend class dom::PBrowserChild;
+
+public:
+  WidgetMouseEventBase()
+  {
+  }
+
+  WidgetMouseEventBase(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+                       nsEventStructType aStructType) :
+    WidgetInputEvent(aIsTrusted, aMessage, aWidget, aStructType),
+    button(0), buttons(0), pressure(0),
+    inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
+ {
+ }
+
+  /// The possible related target
+  nsCOMPtr<nsISupports> relatedTarget;
+
+  enum buttonType
+  {
+    eLeftButton   = 0,
+    eMiddleButton = 1,
+    eRightButton  = 2
+  };
+  // Pressed button ID of mousedown or mouseup event.
+  // This is set only when pressing a button causes the event.
+  int16_t button;
+
+  enum buttonsFlag {
+    eLeftButtonFlag   = 0x01,
+    eRightButtonFlag  = 0x02,
+    eMiddleButtonFlag = 0x04,
+    // typicall, "back" button being left side of 5-button
+    // mice, see "buttons" attribute document of DOM3 Events.
+    e4thButtonFlag    = 0x08,
+    // typicall, "forward" button being right side of 5-button
+    // mice, see "buttons" attribute document of DOM3 Events.
+    e5thButtonFlag    = 0x10
+  };
+
+  // Flags of all pressed buttons at the event fired.
+  // This is set at any mouse event, don't be confused with |button|.
+  int16_t buttons;
+
+  // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
+  float pressure;
+
+  // Possible values at nsIDOMMouseEvent
+  uint16_t inputSource;
+
+  void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent,
+                                bool aCopyTargets)
+  {
+    AssignInputEventData(aEvent, aCopyTargets);
+
+    relatedTarget = aCopyTargets ? aEvent.relatedTarget : nullptr;
+    button = aEvent.button;
+    buttons = aEvent.buttons;
+    pressure = aEvent.pressure;
+    inputSource = aEvent.inputSource;
+  }
+};
+
+/******************************************************************************
+ * mozilla::WidgetMouseEvent
+ ******************************************************************************/
+
+class WidgetMouseEvent : public WidgetMouseEventBase
+{
+private:
+  friend class mozilla::dom::PBrowserParent;
+  friend class mozilla::dom::PBrowserChild;
+
+public:
+  enum reasonType
+  {
+    eReal,
+    eSynthesized
+  };
+
+  enum contextType
+  {
+    eNormal,
+    eContextMenuKey
+  };
+
+  enum exitType
+  {
+    eChild,
+    eTopLevel
+  };
+
+  WidgetMouseEvent()
+  {
+  }
+
+protected:
+  WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+                   nsEventStructType aStructType, reasonType aReason) :
+    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aStructType),
+    acceptActivation(false), ignoreRootScrollFrame(false),
+    reason(aReason), context(eNormal), exit(eChild), clickCount(0)
+  {
+    switch (aMessage) {
+      case NS_MOUSE_MOVE:
+        mFlags.mCancelable = false;
+        break;
+      case NS_MOUSEENTER:
+      case NS_MOUSELEAVE:
+        mFlags.mBubbles = false;
+        mFlags.mCancelable = false;
+        break;
+      default:
+        break;
+    }
+  }
+
+public:
+
+  WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+                   reasonType aReason, contextType aContext = eNormal) :
+    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_MOUSE_EVENT),
+    acceptActivation(false), ignoreRootScrollFrame(false),
+    reason(aReason), context(aContext), exit(eChild), clickCount(0)
+  {
+    switch (aMessage) {
+      case NS_MOUSE_MOVE:
+        mFlags.mCancelable = false;
+        break;
+      case NS_MOUSEENTER:
+      case NS_MOUSELEAVE:
+        mFlags.mBubbles = false;
+        mFlags.mCancelable = false;
+        break;
+      case NS_CONTEXTMENU:
+        button = (context == eNormal) ? eRightButton : eLeftButton;
+        break;
+      default:
+        break;
+    }
+  }
+
+#ifdef DEBUG
+  ~WidgetMouseEvent() {
+    NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
+                     button ==
+                       ((context == eNormal) ? eRightButton : eLeftButton),
+                     "Wrong button set to NS_CONTEXTMENU event?");
+  }
+#endif
+
+  // Special return code for MOUSE_ACTIVATE to signal.
+  // If the target accepts activation (1), or denies it (0).
+  bool acceptActivation;
+  // Whether the event should ignore scroll frame bounds during dispatch.
+  bool ignoreRootScrollFrame;
+
+  reasonType reason : 4;
+  contextType context : 4;
+  exitType exit;
+
+  /// The number of mouse clicks.
+  uint32_t clickCount;
+
+  void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets)
+  {
+    AssignMouseEventBaseData(aEvent, aCopyTargets);
+
+    acceptActivation = aEvent.acceptActivation;
+    ignoreRootScrollFrame = aEvent.ignoreRootScrollFrame;
+    clickCount = aEvent.clickCount;
+  }
+};
+
+/******************************************************************************
+ * mozilla::WidgetDragEvent
+ ******************************************************************************/
+
+class WidgetDragEvent : public WidgetMouseEvent
+{
+public:
+  WidgetDragEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
+    WidgetMouseEvent(aIsTrusted, aMessage, aWidget, NS_DRAG_EVENT, eReal),
+    userCancelled(false)
+  {
+    mFlags.mCancelable =
+      (aMessage != NS_DRAGDROP_EXIT_SYNTH &&
+       aMessage != NS_DRAGDROP_LEAVE_SYNTH &&
+       aMessage != NS_DRAGDROP_END);
+  }
+
+  // The dragging data.
+  nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
+
+  // If this is true, user has cancelled the drag operation.
+  bool userCancelled;
+
+  // XXX Not tested by test_assign_event_data.html
+  void AssignDragEventData(const WidgetDragEvent& aEvent, bool aCopyTargets)
+  {
+    AssignMouseEventData(aEvent, aCopyTargets);
+
+    dataTransfer = aEvent.dataTransfer;
+    // XXX userCancelled isn't copied, is this instentionally?
+    userCancelled = false;
+  }
+};
+
+/******************************************************************************
+ * mozilla::WidgetMouseScrollEvent
+ *
+ * This is used for legacy DOM mouse scroll events, i.e.,
+ * DOMMouseScroll and MozMousePixelScroll event.  These events are NOT hanbled
+ * by ESM even if widget dispatches them.  Use new WidgetWheelEvent instead.
+ ******************************************************************************/
+
+class WidgetMouseScrollEvent : public WidgetMouseEventBase
+{
+private:
+  WidgetMouseScrollEvent()
+  {
+  }
+
+public:
+  WidgetMouseScrollEvent(bool aIsTrusted, uint32_t aMessage,
+                         nsIWidget* aWidget) :
+    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_MOUSE_SCROLL_EVENT),
+    delta(0), isHorizontal(false)
+  {
+  }
+
+  // The delta value of mouse scroll event.
+  // If the event message is NS_MOUSE_SCROLL, the value indicates scroll amount
+  // in lines.  However, if the value is nsIDOMUIEvent::SCROLL_PAGE_UP or
+  // nsIDOMUIEvent::SCROLL_PAGE_DOWN, the value inducates one page scroll.
+  // If the event message is NS_MOUSE_PIXEL_SCROLL, the value indicates scroll
+  // amount in pixels.
+  int32_t delta;
+
+  // If this is true, it may cause to scroll horizontally.
+  // Otherwise, vertically.
+  bool isHorizontal;
+
+  void AssignMouseScrollEventData(const WidgetMouseScrollEvent& aEvent,
+                                  bool aCopyTargets)
+  {
+    AssignMouseEventBaseData(aEvent, aCopyTargets);
+
+    delta = aEvent.delta;
+    isHorizontal = aEvent.isHorizontal;
+  }
+};
+
+/******************************************************************************
+ * mozilla::WidgetWheelEvent
+ ******************************************************************************/
+
+class WidgetWheelEvent : public WidgetMouseEventBase
+{
+private:
+  friend class mozilla::dom::PBrowserParent;
+  friend class mozilla::dom::PBrowserChild;
+
+  WidgetWheelEvent()
+  {
+  }
+
+public:
+  WidgetWheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
+    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
+    deltaX(0.0), deltaY(0.0), deltaZ(0.0),
+    deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
+    customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
+    lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
+    overflowDeltaX(0.0), overflowDeltaY(0.0)
+  {
+  }
+
+  // NOTE: deltaX, deltaY and deltaZ may be customized by
+  //       mousewheel.*.delta_multiplier_* prefs which are applied by
+  //       nsEventStateManager.  So, after widget dispatches this event,
+  //       these delta values may have different values than before.
+  double deltaX;
+  double deltaY;
+  double deltaZ;
+
+  // Should be one of nsIDOMWheelEvent::DOM_DELTA_*
+  uint32_t deltaMode;
+
+  // Following members are for internal use only, not for DOM event.
+
+  // If the delta values are computed from prefs, this value is true.
+  // Otherwise, i.e., they are computed from native events, false.
+  bool customizedByUserPrefs;
+
+  // true if the event is caused by momentum.
+  bool isMomentum;
+
+  // If device event handlers don't know when they should set lineOrPageDeltaX
+  // and lineOrPageDeltaY, this is true.  Otherwise, false.
+  // If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events
+  // when accumulated pixel delta values reach a line height.
+  bool isPixelOnlyDevice;
+
+  // If widget sets lineOrPageDelta, nsEventStateManager will dispatch
+  // NS_MOUSE_SCROLL event for compatibility.  Note that the delta value means
+  // pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines.
+  int32_t lineOrPageDeltaX;
+  int32_t lineOrPageDeltaY;
+
+  // When the default action for an wheel event is moving history or zooming,
+  // need to chose a delta value for doing it.
+  int32_t GetPreferredIntDelta()
+  {
+    if (!lineOrPageDeltaX && !lineOrPageDeltaY) {
+      return 0;
+    }
+    if (lineOrPageDeltaY && !lineOrPageDeltaX) {
+      return lineOrPageDeltaY;
+    }
+    if (lineOrPageDeltaX && !lineOrPageDeltaY) {
+      return lineOrPageDeltaX;
+    }
+    if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
+        (lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
+      return 0; // We cannot guess the answer in this case.
+    }
+    return (Abs(lineOrPageDeltaX) > Abs(lineOrPageDeltaY)) ?
+             lineOrPageDeltaX : lineOrPageDeltaY;
+  }
+
+  // Scroll type
+  // The default value is SCROLL_DEFAULT, which means nsEventStateManager will
+  // select preferred scroll type automatically.
+  enum ScrollType
+  {
+    SCROLL_DEFAULT,
+    SCROLL_SYNCHRONOUSLY,
+    SCROLL_ASYNCHRONOUSELY,
+    SCROLL_SMOOTHLY
+  };
+  ScrollType scrollType;
+
+  // overflowed delta values for scroll, these values are set by
+  // nsEventStateManger.  If the default action of the wheel event isn't scroll,
+  // these values always zero.  Otherwise, remaning delta values which are
+  // not used by scroll are set.
+  // NOTE: deltaX, deltaY and deltaZ may be modified by nsEventStateManager.
+  //       However, overflowDeltaX and overflowDeltaY indicate unused original
+  //       delta values which are not applied the delta_multiplier prefs.
+  //       So, if widget wanted to know the actual direction to be scrolled,
+  //       it would need to check the deltaX and deltaY.
+  double overflowDeltaX;
+  double overflowDeltaY;
+
+  void AssignWheelEventData(const WidgetWheelEvent& aEvent, bool aCopyTargets)
+  {
+    AssignMouseEventBaseData(aEvent, aCopyTargets);
+
+    deltaX = aEvent.deltaX;
+    deltaY = aEvent.deltaY;
+    deltaZ = aEvent.deltaZ;
+    deltaMode = aEvent.deltaMode;
+    customizedByUserPrefs = aEvent.customizedByUserPrefs;
+    isMomentum = aEvent.isMomentum;
+    isPixelOnlyDevice = aEvent.isPixelOnlyDevice;
+    lineOrPageDeltaX = aEvent.lineOrPageDeltaX;
+    lineOrPageDeltaY = aEvent.lineOrPageDeltaY;
+    scrollType = aEvent.scrollType;
+    overflowDeltaX = aEvent.overflowDeltaX;
+    overflowDeltaY = aEvent.overflowDeltaY;
+  }
+};
+
+// TODO: Remove following typedef
+typedef WidgetWheelEvent                WheelEvent;
+
+} // namespace mozilla
+
+// TODO: Remove following typedefs
+typedef mozilla::WidgetMouseEventBase   nsMouseEvent_base;
+typedef mozilla::WidgetMouseEvent       nsMouseEvent;
+typedef mozilla::WidgetDragEvent        nsDragEvent;
+typedef mozilla::WidgetMouseScrollEvent nsMouseScrollEvent;
+
+#endif // mozilla_MouseEvents_h__
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -109,16 +109,17 @@ EXPORTS += [
     'nsWidgetInitData.h',
     'nsWidgetsCID.h',
 ]
 
 EXPORTS.mozilla += [
     'BasicEvents.h',
     'EventForwards.h',
     'LookAndFeel.h',
+    'MouseEvents.h',
     'TextEvents.h',
     'WidgetUtils.h',
 ]
 
 if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']:
     EXPORTS.mozilla += [
         'WidgetTraceEvent.h',
     ]
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -2,44 +2,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsGUIEvent_h__
 #define nsGUIEvent_h__
 
 #include "mozilla/BasicEvents.h"
-#include "mozilla/MathAlgorithms.h"
+#include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 
 #include "nsPoint.h"
 #include "nsRect.h"
-#include "nsIDOMMouseEvent.h"
-#include "nsIDOMWheelEvent.h"
 #include "nsIDOMDataTransfer.h"
 #include "nsWeakPtr.h"
 #include "nsITransferable.h"
 #include "nsAutoPtr.h"
 #include "mozilla/dom/Touch.h"
 
-namespace mozilla {
-namespace dom {
-  class PBrowserParent;
-  class PBrowserChild;
-}
-namespace plugins {
-  class PPluginInstanceChild;
-}
-}
-
-class nsRenderingContext;
-class nsIMenuItem;
 class nsIContent;
-class nsIURI;
-class nsHashKey;
 
 #define NS_EVENT_TYPE_NULL                   0
 #define NS_EVENT_TYPE_ALL                  1 // Not a real event type
 
 /**
  * Script error event
  */
 
@@ -111,355 +95,16 @@ public:
                                  bool aCopyTargets)
   {
     AssignGUIEventData(aEvent, aCopyTargets);
 
     mArea = aEvent.mArea;
   }
 };
 
-/**
- * Mouse event
- */
-
-class nsMouseEvent_base : public nsInputEvent
-{
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-public:
-
-  nsMouseEvent_base()
-  {
-  }
-
-  nsMouseEvent_base(bool isTrusted, uint32_t msg, nsIWidget *w,
-                    nsEventStructType type)
-    : nsInputEvent(isTrusted, msg, w, type), button(0), buttons(0),
-      pressure(0), inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
-
-  /// The possible related target
-  nsCOMPtr<nsISupports> relatedTarget;
-
-  int16_t               button;
-  int16_t               buttons;
-
-  // Finger or touch pressure of event
-  // ranges between 0.0 and 1.0
-  float                 pressure;
-
-  // Possible values at nsIDOMMouseEvent
-  uint16_t              inputSource;
-
-  void AssignMouseEventBaseData(const nsMouseEvent_base& aEvent,
-                                bool aCopyTargets)
-  {
-    AssignInputEventData(aEvent, aCopyTargets);
-
-    relatedTarget = aCopyTargets ? aEvent.relatedTarget : nullptr;
-    button = aEvent.button;
-    buttons = aEvent.buttons;
-    pressure = aEvent.pressure;
-    inputSource = aEvent.inputSource;
-  }
-};
-
-class nsMouseEvent : public nsMouseEvent_base
-{
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-public:
-  enum buttonType  { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
-  enum buttonsFlag { eLeftButtonFlag   = 0x01,
-                     eRightButtonFlag  = 0x02,
-                     eMiddleButtonFlag = 0x04,
-                     // typicall, "back" button being left side of 5-button
-                     // mice, see "buttons" attribute document of DOM3 Events.
-                     e4thButtonFlag    = 0x08,
-                     // typicall, "forward" button being right side of 5-button
-                     // mice, see "buttons" attribute document of DOM3 Events.
-                     e5thButtonFlag    = 0x10 };
-  enum reasonType  { eReal, eSynthesized };
-  enum contextType { eNormal, eContextMenuKey };
-  enum exitType    { eChild, eTopLevel };
-
-  nsMouseEvent()
-  {
-  }
-
-protected:
-  nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
-               nsEventStructType structType, reasonType aReason)
-    : nsMouseEvent_base(isTrusted, msg, w, structType),
-      acceptActivation(false), ignoreRootScrollFrame(false),
-      reason(aReason), context(eNormal), exit(eChild), clickCount(0)
-  {
-    switch (msg) {
-      case NS_MOUSE_MOVE:
-        mFlags.mCancelable = false;
-        break;
-      case NS_MOUSEENTER:
-      case NS_MOUSELEAVE:
-        mFlags.mBubbles = false;
-        mFlags.mCancelable = false;
-        break;
-      default:
-        break;
-    }
-  }
-
-public:
-
-  nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
-               reasonType aReason, contextType aContext = eNormal)
-    : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
-      acceptActivation(false), ignoreRootScrollFrame(false),
-      reason(aReason), context(aContext), exit(eChild), clickCount(0)
-  {
-    switch (msg) {
-      case NS_MOUSE_MOVE:
-        mFlags.mCancelable = false;
-        break;
-      case NS_MOUSEENTER:
-      case NS_MOUSELEAVE:
-        mFlags.mBubbles = false;
-        mFlags.mCancelable = false;
-        break;
-      case NS_CONTEXTMENU:
-        button = (context == eNormal) ? eRightButton : eLeftButton;
-        break;
-      default:
-        break;
-    }
-  }
-
-#ifdef DEBUG
-  ~nsMouseEvent() {
-    NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
-                     button ==
-                       ((context == eNormal) ? eRightButton : eLeftButton),
-                     "Wrong button set to NS_CONTEXTMENU event?");
-  }
-#endif
-
-  /// Special return code for MOUSE_ACTIVATE to signal
-  /// if the target accepts activation (1), or denies it (0)
-  bool acceptActivation;
-  // Whether the event should ignore scroll frame bounds
-  // during dispatch.
-  bool ignoreRootScrollFrame;
-
-  reasonType   reason : 4;
-  contextType  context : 4;
-  exitType     exit;
-
-  /// The number of mouse clicks
-  uint32_t     clickCount;
-
-  void AssignMouseEventData(const nsMouseEvent& aEvent, bool aCopyTargets)
-  {
-    AssignMouseEventBaseData(aEvent, aCopyTargets);
-
-    acceptActivation = aEvent.acceptActivation;
-    ignoreRootScrollFrame = aEvent.ignoreRootScrollFrame;
-    clickCount = aEvent.clickCount;
-  }
-};
-
-/**
- * Drag event
- */
-
-class nsDragEvent : public nsMouseEvent
-{
-public:
-  nsDragEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
-    : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
-      userCancelled(false)
-  {
-    mFlags.mCancelable =
-      (msg != NS_DRAGDROP_EXIT_SYNTH &&
-       msg != NS_DRAGDROP_LEAVE_SYNTH &&
-       msg != NS_DRAGDROP_END);
-  }
-
-  nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
-  bool userCancelled;
-
-  // XXX Not tested by test_assign_event_data.html
-  void AssignDragEventData(const nsDragEvent& aEvent, bool aCopyTargets)
-  {
-    AssignMouseEventData(aEvent, aCopyTargets);
-
-    dataTransfer = aEvent.dataTransfer;
-    // XXX userCancelled isn't copied, is this instentionally?
-    userCancelled = false;
-  }
-};
-
-/**
- * nsMouseScrollEvent is used for legacy DOM mouse scroll events, i.e.,
- * DOMMouseScroll and MozMousePixelScroll event.  These events are NOT hanbled
- * by ESM even if widget dispatches them.  Use new WheelEvent instead.
- */
-
-class nsMouseScrollEvent : public nsMouseEvent_base
-{
-private:
-  nsMouseScrollEvent()
-  {
-  }
-
-public:
-  nsMouseScrollEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
-    : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
-      delta(0), isHorizontal(false)
-  {
-  }
-
-  int32_t               delta;
-  bool                  isHorizontal;
-
-  void AssignMouseScrollEventData(const nsMouseScrollEvent& aEvent,
-                                  bool aCopyTargets)
-  {
-    AssignMouseEventBaseData(aEvent, aCopyTargets);
-
-    delta = aEvent.delta;
-    isHorizontal = aEvent.isHorizontal;
-  }
-};
-
-/**
- * WheelEvent is used only for DOM Level 3 WheelEvent (dom::DOMWheelEvent).
- */
-
-namespace mozilla {
-
-class WheelEvent : public nsMouseEvent_base
-{
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-  WheelEvent()
-  {
-  }
-
-public:
-  WheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
-    nsMouseEvent_base(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
-    deltaX(0.0), deltaY(0.0), deltaZ(0.0),
-    deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
-    customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
-    lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
-    overflowDeltaX(0.0), overflowDeltaY(0.0)
-  {
-  }
-
-  // NOTE: deltaX, deltaY and deltaZ may be customized by
-  //       mousewheel.*.delta_multiplier_* prefs which are applied by
-  //       nsEventStateManager.  So, after widget dispatches this event,
-  //       these delta values may have different values than before.
-  double deltaX;
-  double deltaY;
-  double deltaZ;
-
-  // Should be one of nsIDOMWheelEvent::DOM_DELTA_*
-  uint32_t deltaMode;
-
-  // Following members are for internal use only, not for DOM event.
-
-  // If the delta values are computed from prefs, this value is true.
-  // Otherwise, i.e., they are computed from native events, false.
-  bool customizedByUserPrefs;
-
-  // true if the event is caused by momentum.
-  bool isMomentum;
-
-  // If device event handlers don't know when they should set lineOrPageDeltaX
-  // and lineOrPageDeltaY, this is true.  Otherwise, false.
-  // If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events
-  // when accumulated pixel delta values reach a line height.
-  bool isPixelOnlyDevice;
-
-  // If widget sets lineOrPageDelta, nsEventStateManager will dispatch
-  // NS_MOUSE_SCROLL event for compatibility.  Note that the delta value means
-  // pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines.
-  int32_t lineOrPageDeltaX;
-  int32_t lineOrPageDeltaY;
-
-  // When the default action for an wheel event is moving history or zooming,
-  // need to chose a delta value for doing it.
-  int32_t GetPreferredIntDelta()
-  {
-    if (!lineOrPageDeltaX && !lineOrPageDeltaY) {
-      return 0;
-    }
-    if (lineOrPageDeltaY && !lineOrPageDeltaX) {
-      return lineOrPageDeltaY;
-    }
-    if (lineOrPageDeltaX && !lineOrPageDeltaY) {
-      return lineOrPageDeltaX;
-    }
-    if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
-        (lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
-      return 0; // We cannot guess the answer in this case.
-    }
-    return (Abs(lineOrPageDeltaX) > Abs(lineOrPageDeltaY)) ?
-             lineOrPageDeltaX : lineOrPageDeltaY;
-  }
-
-  // Scroll type
-  // The default value is SCROLL_DEFAULT, which means nsEventStateManager will
-  // select preferred scroll type automatically.
-  enum ScrollType {
-    SCROLL_DEFAULT,
-    SCROLL_SYNCHRONOUSLY,
-    SCROLL_ASYNCHRONOUSELY,
-    SCROLL_SMOOTHLY
-  };
-  ScrollType scrollType;
-
-  // overflowed delta values for scroll, these values are set by
-  // nsEventStateManger.  If the default action of the wheel event isn't scroll,
-  // these values always zero.  Otherwise, remaning delta values which are
-  // not used by scroll are set.
-  // NOTE: deltaX, deltaY and deltaZ may be modified by nsEventStateManager.
-  //       However, overflowDeltaX and overflowDeltaY indicate unused original
-  //       delta values which are not applied the delta_multiplier prefs.
-  //       So, if widget wanted to know the actual direction to be scrolled,
-  //       it would need to check the deltaX and deltaY.
-  double overflowDeltaX;
-  double overflowDeltaY;
-
-  void AssignWheelEventData(const WheelEvent& aEvent, bool aCopyTargets)
-  {
-    AssignMouseEventBaseData(aEvent, aCopyTargets);
-
-    deltaX = aEvent.deltaX;
-    deltaY = aEvent.deltaY;
-    deltaZ = aEvent.deltaZ;
-    deltaMode = aEvent.deltaMode;
-    customizedByUserPrefs = aEvent.customizedByUserPrefs;
-    isMomentum = aEvent.isMomentum;
-    isPixelOnlyDevice = aEvent.isPixelOnlyDevice;
-    lineOrPageDeltaX = aEvent.lineOrPageDeltaX;
-    lineOrPageDeltaY = aEvent.lineOrPageDeltaY;
-    scrollType = aEvent.scrollType;
-    overflowDeltaX = aEvent.overflowDeltaX;
-    overflowDeltaY = aEvent.overflowDeltaY;
-  }
-};
-
-} // namespace mozilla
-
 /*
  * Gesture Notify Event:
  *
  * This event is the first event generated when the user touches
  * the screen with a finger, and it's meant to decide what kind
  * of action we'll use for that touch interaction.
  *
  * The event is dispatched to the layout and based on what is underneath
@@ -771,28 +416,16 @@ public:
   }
 
   // If TRUE, this event needs to be retargeted to focused document.
   // Otherwise, never retargeted.
   // Defaults to false.
   bool retargetToFocusedDocument;
 };
 
-/**
- * Event status for D&D Event
- */
-enum nsDragDropEventStatus {  
-  /// The event is a enter
-  nsDragDropEventStatus_eDragEntered,            
-  /// The event is exit
-  nsDragDropEventStatus_eDragExited, 
-  /// The event is drop
-  nsDragDropEventStatus_eDrop  
-};
-
 #define NS_IS_INPUT_EVENT(evnt) \
        (((evnt)->eventStructType == NS_INPUT_EVENT) || \
         ((evnt)->eventStructType == NS_MOUSE_EVENT) || \
         ((evnt)->eventStructType == NS_KEY_EVENT) || \
         ((evnt)->eventStructType == NS_TOUCH_EVENT) || \
         ((evnt)->eventStructType == NS_DRAG_EVENT) || \
         ((evnt)->eventStructType == NS_MOUSE_SCROLL_EVENT) || \
         ((evnt)->eventStructType == NS_WHEEL_EVENT) || \