Bug 912956 part.8 Create mozilla/MiscEvents.h r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 24 Sep 2013 19:04:15 +0900
changeset 148434 ab54eba99d340c18571fb34b43b4940b1ceab85f
parent 148433 e4e2588531d623d5ae73018293e5a65295f0cc37
child 148435 ba03fca314e1eb3813b6a80c36e1c6481433a5ce
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs912956
milestone27.0a1
Bug 912956 part.8 Create mozilla/MiscEvents.h r=roc
dom/network/src/MobileConnection.h
widget/BasicEvents.h
widget/EventForwards.h
widget/MiscEvents.h
widget/moz.build
widget/nsGUIEvent.h
--- a/dom/network/src/MobileConnection.h
+++ b/dom/network/src/MobileConnection.h
@@ -4,16 +4,17 @@
 
 #ifndef mozilla_dom_network_MobileConnection_h
 #define mozilla_dom_network_MobileConnection_h
 
 #include "nsIDOMMobileConnection.h"
 #include "nsIMobileConnectionProvider.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsWeakPtr.h"
 
 namespace mozilla {
 namespace dom {
 namespace network {
 
 class MobileConnection : public nsDOMEventTargetHelper
                        , public nsIDOMMozMobileConnection
 {
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -52,29 +52,29 @@ enum nsEventStructType
   NS_SCROLLPORT_EVENT,               // InternalScrollPortEvent
   NS_SCROLLAREA_EVENT,               // InternalScrollAreaEvent
   NS_FORM_EVENT,                     // InternalFormEvent
   NS_FOCUS_EVENT,                    // InternalFocusEvent
   NS_CLIPBOARD_EVENT,                // InternalClipboardEvent
   NS_TRANSITION_EVENT,               // InternalTransitionEvent
   NS_ANIMATION_EVENT,                // InternalAnimationEvent
 
+  // MiscEvents.h
+  NS_COMMAND_EVENT,                  // WidgetCommandEvent
+  NS_CONTENT_COMMAND_EVENT,          // WidgetContentCommandEvent
+  NS_PLUGIN_EVENT,                   // WidgetPluginEvent
+
   // DOM events
   NS_MUTATION_EVENT,                 // nsMutationEvent
 
-  // SVG events
-  NS_SVGZOOM_EVENT,                  // GUIEvent
-  NS_SMIL_TIME_EVENT,                // UIEvent
-
-  // Command events
-  NS_COMMAND_EVENT,                  // nsCommandEvent
-  NS_CONTENT_COMMAND_EVENT,          // nsContentCommandEvent
-
-  // Plugin event
-  NS_PLUGIN_EVENT                    // nsPluginEvent
+  // Follwoing struct type values are ugly.  They indicate other struct type
+  // actually.  However, they are used for distinguishing which DOM event
+  // should be created for the event.
+  NS_SVGZOOM_EVENT,                  // WidgetGUIEvent
+  NS_SMIL_TIME_EVENT                 // InternalUIEvent
 };
 
 /******************************************************************************
  * Messages
  *
  * TODO: Make them enum.
  ******************************************************************************/
 
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -87,54 +87,57 @@ class WidgetTouchEvent;
 class InternalScriptErrorEvent;
 class InternalScrollPortEvent;
 class InternalScrollAreaEvent;
 class InternalFormEvent;
 class InternalClipboardEvent;
 class InternalFocusEvent;
 class InternalTransitionEvent;
 class InternalAnimationEvent;
-} // namespace mozilla
 
 // MiscEvents.h
-class nsCommandEvent;
-class nsContentCommandEvent;
-class nsPluginEvent;
+class WidgetCommandEvent;
+class WidgetContentCommandEvent;
+class WidgetPluginEvent;
+} // namespace mozilla
 
 // content/events/public/nsMutationEvent.h
 class nsMutationEvent;
 
 // TODO: Remove following typedefs
-typedef mozilla::WidgetEvent              nsEvent;
-typedef mozilla::WidgetGUIEvent           nsGUIEvent;
-typedef mozilla::WidgetInputEvent         nsInputEvent;
-typedef mozilla::InternalUIEvent          nsUIEvent;
-typedef mozilla::AlternativeCharCode      nsAlternativeCharCode;
-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;
+typedef mozilla::WidgetEvent               nsEvent;
+typedef mozilla::WidgetGUIEvent            nsGUIEvent;
+typedef mozilla::WidgetInputEvent          nsInputEvent;
+typedef mozilla::InternalUIEvent           nsUIEvent;
+typedef mozilla::AlternativeCharCode       nsAlternativeCharCode;
+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;
+typedef WidgetWheelEvent                   WheelEvent;
 }
 
-typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
-typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
-typedef mozilla::WidgetTouchEvent         nsTouchEvent;
-typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
-typedef mozilla::InternalScrollPortEvent  nsScrollPortEvent;
-typedef mozilla::InternalScrollAreaEvent  nsScrollAreaEvent;
-typedef mozilla::InternalFormEvent        nsFormEvent;
-typedef mozilla::InternalClipboardEvent   nsClipboardEvent;
-typedef mozilla::InternalFocusEvent       nsFocusEvent;
-typedef mozilla::InternalTransitionEvent  nsTransitionEvent;
-typedef mozilla::InternalAnimationEvent   nsAnimationEvent;
+typedef mozilla::WidgetGestureNotifyEvent  nsGestureNotifyEvent;
+typedef mozilla::WidgetSimpleGestureEvent  nsSimpleGestureEvent;
+typedef mozilla::WidgetTouchEvent          nsTouchEvent;
+typedef mozilla::InternalScriptErrorEvent  nsScriptErrorEvent;
+typedef mozilla::InternalScrollPortEvent   nsScrollPortEvent;
+typedef mozilla::InternalScrollAreaEvent   nsScrollAreaEvent;
+typedef mozilla::InternalFormEvent         nsFormEvent;
+typedef mozilla::InternalClipboardEvent    nsClipboardEvent;
+typedef mozilla::InternalFocusEvent        nsFocusEvent;
+typedef mozilla::InternalTransitionEvent   nsTransitionEvent;
+typedef mozilla::InternalAnimationEvent    nsAnimationEvent;
+typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
+typedef mozilla::WidgetCommandEvent        nsCommandEvent;
+typedef mozilla::WidgetPluginEvent         nsPluginEvent;
 
 #endif // mozilla_EventForwards_h__
new file mode 100644
--- /dev/null
+++ b/widget/MiscEvents.h
@@ -0,0 +1,123 @@
+/* -*- 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_MiscEvents_h__
+#define mozilla_MiscEvents_h__
+
+#include <stdint.h>
+
+#include "mozilla/BasicEvents.h"
+#include "nsCOMPtr.h"
+#include "nsIAtom.h"
+#include "nsITransferable.h"
+
+namespace mozilla {
+
+/******************************************************************************
+ * mozilla::WidgetContentCommandEvent
+ ******************************************************************************/
+
+class WidgetContentCommandEvent : public WidgetGUIEvent
+{
+public:
+  WidgetContentCommandEvent(bool aIsTrusted, uint32_t aMessage,
+                            nsIWidget* aWidget,
+                            bool aOnlyEnabledCheck = false) :
+    WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_CONTENT_COMMAND_EVENT),
+    mOnlyEnabledCheck(aOnlyEnabledCheck), mSucceeded(false), mIsEnabled(false)
+  {
+  }
+
+  // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
+  nsCOMPtr<nsITransferable> mTransferable; // [in]
+
+  // NS_CONTENT_COMMAND_SCROLL
+  // for mScroll.mUnit
+  enum
+  {
+    eCmdScrollUnit_Line,
+    eCmdScrollUnit_Page,
+    eCmdScrollUnit_Whole
+  };
+
+  struct ScrollInfo
+  {
+    ScrollInfo() :
+      mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
+    {
+    }
+
+    int32_t mAmount;    // [in]
+    uint8_t mUnit;      // [in]
+    bool mIsHorizontal; // [in]
+  } mScroll;
+
+  bool mOnlyEnabledCheck; // [in]
+
+  bool mSucceeded; // [out]
+  bool mIsEnabled; // [out]
+};
+
+/******************************************************************************
+ * mozilla::WidgetCommandEvent
+ *
+ * This sends a command to chrome.  If you want to request what is performed
+ * in focused content, you should use WidgetContentCommandEvent instead.
+ *
+ * XXX Should be |WidgetChromeCommandEvent|?
+ ******************************************************************************/
+
+class WidgetCommandEvent : public WidgetGUIEvent
+{
+public:
+  WidgetCommandEvent(bool aIsTrusted, nsIAtom* aEventType,
+                     nsIAtom* aCommand, nsIWidget* aWidget) :
+    WidgetGUIEvent(aIsTrusted, NS_USER_DEFINED_EVENT, aWidget,
+                   NS_COMMAND_EVENT),
+    command(aCommand)
+  {
+    userType = aEventType;
+  }
+
+  nsCOMPtr<nsIAtom> command;
+
+  // XXX Not tested by test_assign_event_data.html
+  void AssignCommandEventData(const WidgetCommandEvent& aEvent,
+                              bool aCopyTargets)
+  {
+    AssignGUIEventData(aEvent, aCopyTargets);
+
+    // command must have been initialized with the constructor.
+  }
+};
+
+/******************************************************************************
+ * mozilla::WidgetPluginEvent
+ *
+ * This event delivers only a native event to focused plugin.
+ ******************************************************************************/
+
+class WidgetPluginEvent : public WidgetGUIEvent
+{
+public:
+  WidgetPluginEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
+    WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_PLUGIN_EVENT),
+    retargetToFocusedDocument(false)
+  {
+  }
+
+  // If true, this event needs to be retargeted to focused document.
+  // Otherwise, never retargeted. Defaults to false.
+  bool retargetToFocusedDocument;
+};
+
+} // namespace mozilla
+
+// TODO: Remove following typedefs
+typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
+typedef mozilla::WidgetCommandEvent        nsCommandEvent;
+typedef mozilla::WidgetPluginEvent         nsPluginEvent;
+
+#endif // mozilla_MiscEvents_h__
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -110,16 +110,17 @@ EXPORTS += [
     'nsWidgetsCID.h',
 ]
 
 EXPORTS.mozilla += [
     'BasicEvents.h',
     'ContentEvents.h',
     'EventForwards.h',
     'LookAndFeel.h',
+    'MiscEvents.h',
     'MouseEvents.h',
     'TextEvents.h',
     'TouchEvents.h',
     'WidgetUtils.h',
 ]
 
 if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']:
     EXPORTS.mozilla += [
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -3,114 +3,24 @@
  * 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/ContentEvents.h"
+#include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 
-#include "nsPoint.h"
-#include "nsRect.h"
-#include "nsWeakPtr.h"
-#include "nsITransferable.h"
-
 #define NS_EVENT_TYPE_NULL                   0
 #define NS_EVENT_TYPE_ALL                  1 // Not a real event type
 
-class nsContentCommandEvent : public nsGUIEvent
-{
-public:
-  nsContentCommandEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget,
-                        bool aOnlyEnabledCheck = false) :
-    nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
-    mOnlyEnabledCheck(bool(aOnlyEnabledCheck)),
-    mSucceeded(false), mIsEnabled(false)
-  {
-  }
-
-  // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
-  nsCOMPtr<nsITransferable> mTransferable;                 // [in]
-
-  // NS_CONTENT_COMMAND_SCROLL
-  // for mScroll.mUnit
-  enum {
-    eCmdScrollUnit_Line,
-    eCmdScrollUnit_Page,
-    eCmdScrollUnit_Whole
-  };
-
-  struct ScrollInfo {
-    ScrollInfo() :
-      mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
-    {
-    }
-
-    int32_t      mAmount;                                  // [in]
-    uint8_t      mUnit;                                    // [in]
-    bool mIsHorizontal;                            // [in]
-  } mScroll;
-
-  bool mOnlyEnabledCheck;                          // [in]
-
-  bool mSucceeded;                                 // [out]
-  bool mIsEnabled;                                 // [out]
-};
-
-/**
- * Command event
- *
- * Custom commands for example from the operating system.
- */
-
-class nsCommandEvent : public nsGUIEvent
-{
-public:
-  nsCommandEvent(bool isTrusted, nsIAtom* aEventType,
-                 nsIAtom* aCommand, nsIWidget* w)
-    : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
-  {
-    userType = aEventType;
-    command = aCommand;
-  }
-
-  nsCOMPtr<nsIAtom> command;
-
-  // XXX Not tested by test_assign_event_data.html
-  void AssignCommandEventData(const nsCommandEvent& aEvent, bool aCopyTargets)
-  {
-    AssignGUIEventData(aEvent, aCopyTargets);
-
-    // command must have been initialized with the constructor.
-  }
-};
-
-/**
- * Native event pluginEvent for plugins.
- */
-
-class nsPluginEvent : public nsGUIEvent
-{
-public:
-  nsPluginEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
-    : nsGUIEvent(isTrusted, msg, w, NS_PLUGIN_EVENT),
-      retargetToFocusedDocument(false)
-  {
-  }
-
-  // If TRUE, this event needs to be retargeted to focused document.
-  // Otherwise, never retargeted.
-  // Defaults to false.
-  bool retargetToFocusedDocument;
-};
-
 #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) || \