Bug 1046101 part.33 Generate EventClassID with EventClassList.h in EventForwards.h and nsContentUtils should use it instead of uint32_t r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 04 Aug 2014 14:28:58 +0900
changeset 197673 c0cfff4ee625d2e1f10b349016d6b776930ddea1
parent 197672 a00fe3dedf677a331204206723d982bc8b1f86a1
child 197674 911cc1b35f4b34d2f657df8f51b56bbcf8fc59b5
push id27249
push userryanvm@gmail.com
push dateMon, 04 Aug 2014 20:14:35 +0000
treeherdermozilla-central@7f81be7db528 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1046101
milestone34.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 1046101 part.33 Generate EventClassID with EventClassList.h in EventForwards.h and nsContentUtils should use it instead of uint32_t r=smaug
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
dom/xbl/nsXBLEventHandler.cpp
widget/BasicEvents.h
widget/EventForwards.h
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -146,17 +146,17 @@ enum EventNameType {
   EventNameType_All = 0xFFFF
 };
 
 struct EventNameMapping
 {
   nsIAtom* mAtom;
   uint32_t mId;
   int32_t  mType;
-  uint32_t mStructType;
+  mozilla::EventClassID mEventClassID;
 };
 
 struct nsShortcutCandidate {
   nsShortcutCandidate(uint32_t aCharCode, bool aIgnoreShift) :
     mCharCode(aCharCode), mIgnoreShift(aIgnoreShift)
   {
   }
   uint32_t mCharCode;
@@ -1028,35 +1028,35 @@ public:
    * event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
    * event doesn't match a known event name.
    *
    * @param aName the event name to look up
    */
   static uint32_t GetEventId(nsIAtom* aName);
 
   /**
-   * Return the category for the event with the given name. The name is the
+   * Return the EventClassID for the event with the given name. The name is the
    * event name *without* the 'on' prefix. Returns eBasicEventClass if the event
-   * is not known to be in any particular category.
+   * is not known to be of any particular event class.
    *
    * @param aName the event name to look up
    */
-  static uint32_t GetEventCategory(const nsAString& aName);
+  static mozilla::EventClassID GetEventClassID(const nsAString& aName);
 
   /**
    * Return the event id and atom for the event with the given name.
    * The name is the event name *without* the 'on' prefix.
    * Returns NS_USER_DEFINED_EVENT on the aEventID if the
    * event doesn't match a known event name in the category.
    *
    * @param aName the event name to look up
-   * @param aEventStruct only return event id in aEventStruct category
+   * @param aEventClassID only return event id for aEventClassID
    */
   static nsIAtom* GetEventIdAndAtom(const nsAString& aName,
-                                    uint32_t aEventStruct,
+                                    mozilla::EventClassID aEventClassID,
                                     uint32_t* aEventID);
 
   /**
    * Used only during traversal of the XPCOM graph by the cycle
    * collector: push a pointer to the listener manager onto the
    * children deque, if it exists. Do nothing if there is no listener
    * manager.
    *
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -620,18 +620,18 @@ nsContentUtils::InitializeModifierString
 }
 
 bool
 nsContentUtils::InitializeEventTable() {
   NS_ASSERTION(!sAtomEventTable, "EventTable already initialized!");
   NS_ASSERTION(!sStringEventTable, "EventTable already initialized!");
 
   static const EventNameMapping eventArray[] = {
-#define EVENT(name_,  _id, _type, _struct)          \
-    { nsGkAtoms::on##name_, _id, _type, _struct },
+#define EVENT(name_,  _id, _type, _class)          \
+    { nsGkAtoms::on##name_, _id, _type, _class },
 #define WINDOW_ONLY_EVENT EVENT
 #define NON_IDL_EVENT EVENT
 #include "mozilla/EventNameList.h"
 #undef WINDOW_ONLY_EVENT
 #undef EVENT
     { nullptr }
   };
 
@@ -653,19 +653,19 @@ nsContentUtils::InitializeEventTable() {
 
 void
 nsContentUtils::InitializeTouchEventTable()
 {
   static bool sEventTableInitialized = false;
   if (!sEventTableInitialized && sAtomEventTable && sStringEventTable) {
     sEventTableInitialized = true;
     static const EventNameMapping touchEventArray[] = {
-#define EVENT(name_,  _id, _type, _struct)
-#define TOUCH_EVENT(name_,  _id, _type, _struct)      \
-      { nsGkAtoms::on##name_, _id, _type, _struct },
+#define EVENT(name_,  _id, _type, _class)
+#define TOUCH_EVENT(name_,  _id, _type, _class)      \
+      { nsGkAtoms::on##name_, _id, _type, _class },
 #include "mozilla/EventNameList.h"
 #undef TOUCH_EVENT
 #undef EVENT
       { nullptr }
     };
     // Subtract one from the length because of the trailing null
     for (uint32_t i = 0; i < ArrayLength(touchEventArray) - 1; ++i) {
       sAtomEventTable->Put(touchEventArray[i].mAtom, touchEventArray[i]);
@@ -3597,35 +3597,35 @@ nsContentUtils::GetEventId(nsIAtom* aNam
       return mapping.mId;
     }
   }
 
   return NS_USER_DEFINED_EVENT;
 }
 
 // static
-uint32_t
-nsContentUtils::GetEventCategory(const nsAString& aName)
+mozilla::EventClassID
+nsContentUtils::GetEventClassID(const nsAString& aName)
 {
   EventNameMapping mapping;
   if (sStringEventTable->Get(aName, &mapping))
-    return mapping.mStructType;
+    return mapping.mEventClassID;
 
   return eBasicEventClass;
 }
 
 nsIAtom*
 nsContentUtils::GetEventIdAndAtom(const nsAString& aName,
-                                  uint32_t aEventStruct,
+                                  mozilla::EventClassID aEventClassID,
                                   uint32_t* aEventID)
 {
   EventNameMapping mapping;
   if (sStringEventTable->Get(aName, &mapping)) {
-    *aEventID =
-      mapping.mStructType == aEventStruct ? mapping.mId : NS_USER_DEFINED_EVENT;
+    *aEventID = mapping.mEventClassID == aEventClassID ? mapping.mId :
+                                                         NS_USER_DEFINED_EVENT;
     return mapping.mAtom;
   }
 
   // If we have cached lots of user defined event names, clear some of them.
   if (sUserDefinedEvents->Count() > 127) {
     while (sUserDefinedEvents->Count() > 64) {
       nsIAtom* first = sUserDefinedEvents->ObjectAt(0);
       sStringEventTable->Remove(Substring(nsDependentAtomString(first), 2));
@@ -3634,17 +3634,17 @@ nsContentUtils::GetEventIdAndAtom(const 
   }
 
   *aEventID = NS_USER_DEFINED_EVENT;
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aName);
   sUserDefinedEvents->AppendObject(atom);
   mapping.mAtom = atom;
   mapping.mId = NS_USER_DEFINED_EVENT;
   mapping.mType = EventNameType_None;
-  mapping.mStructType = eBasicEventClass;
+  mapping.mEventClassID = eBasicEventClass;
   sStringEventTable->Put(aName, mapping);
   return mapping.mAtom;
 }
 
 static
 nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget,
                            const nsAString& aEventName,
                            bool aCanBubble, bool aCancelable,
--- a/dom/xbl/nsXBLEventHandler.cpp
+++ b/dom/xbl/nsXBLEventHandler.cpp
@@ -143,17 +143,17 @@ nsXBLKeyEventHandler::HandleEvent(nsIDOM
 
 ///////////////////////////////////////////////////////////////////////////////////
 
 nsresult
 NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
                       nsIAtom* aEventType,
                       nsXBLEventHandler** aResult)
 {
-  switch (nsContentUtils::GetEventCategory(nsDependentAtomString(aEventType))) {
+  switch (nsContentUtils::GetEventClassID(nsDependentAtomString(aEventType))) {
     case eDragEventClass:
     case eMouseEventClass:
     case eMouseScrollEventClass:
     case eWheelEventClass:
     case eSimpleGestureEventClass:
       *aResult = new nsXBLMouseEventHandler(aHandler);
       break;
     default:
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -4,80 +4,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_BasicEvents_h__
 #define mozilla_BasicEvents_h__
 
 #include <stdint.h>
 
 #include "mozilla/dom/EventTarget.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/TimeStamp.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsISupportsImpl.h"
 #include "nsIWidget.h"
 #include "nsString.h"
 #include "Units.h"
 
-namespace mozilla {
-
-/******************************************************************************
- * Event Class ID
- ******************************************************************************/
-typedef uint8_t EventClassIDType;
-enum EventClassID MOZ_ENUM_TYPE(EventClassIDType)
-{
-  // BasicEvents.h
-  eBasicEventClass,                  // WidgetEvent
-  eGUIEventClass,                    // WidgetGUIEvent
-  eInputEventClass,                  // WidgetInputEvent
-  eUIEventClass,                     // InternalUIEvent
-
-  // TextEvents.h
-  eKeyboardEventClass,               // WidgetKeyboardEvent
-  eCompositionEventClass,            // WidgetCompositionEvent
-  eTextEventClass,                   // WidgetTextEvent
-  eQueryContentEventClass,           // WidgetQueryContentEvent
-  eSelectionEventClass,              // WidgetSelectionEvent
-  eEditorInputEventClass,            // InternalEditorInputEvent
-
-  // MouseEvents.h
-  eMouseEventClass,                  // WidgetMouseEvent
-  eDragEventClass,                   // WidgetDragEvent
-  eMouseScrollEventClass,            // WidgetMouseScrollEvent
-  eWheelEventClass,                  // WidgetWheelEvent
-  ePointerEventClass,                // PointerEvent
-
-  // TouchEvents.h
-  eGestureNotifyEventClass,          // WidgetGestureNotifyEvent
-  eSimpleGestureEventClass,          // WidgetSimpleGestureEvent
-  eTouchEventClass,                  // WidgetTouchEvent
-
-  // ContentEvents.h
-  eScrollPortEventClass,             // InternalScrollPortEvent
-  eScrollAreaEventClass,             // InternalScrollAreaEvent
-  eFormEventClass,                   // InternalFormEvent
-  eFocusEventClass,                  // InternalFocusEvent
-  eClipboardEventClass,              // InternalClipboardEvent
-  eTransitionEventClass,             // InternalTransitionEvent
-  eAnimationEventClass,              // InternalAnimationEvent
-  eSVGZoomEventClass,                // InternalSVGZoomEvent
-  eSMILTimeEventClass,               // InternalSMILTimeEvent
-
-  // MiscEvents.h
-  eCommandEventClass,                // WidgetCommandEvent
-  eContentCommandEventClass,         // WidgetContentCommandEvent
-  ePluginEventClass,                 // WidgetPluginEvent
-
-  // InternalMutationEvent.h (dom/events)
-  eMutationEventClass                // InternalMutationEvent
-};
-
-} // namespace mozilla
-
 /******************************************************************************
  * Messages
  *
  * TODO: Make them enum.
  ******************************************************************************/
 
 #define NS_EVENT_NULL                   0
 
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -25,16 +25,32 @@ enum nsEventStatus
   // The event is consumed, don't do default processing
   nsEventStatus_eConsumeNoDefault,
   // The event is consumed, but do default processing
   nsEventStatus_eConsumeDoDefault
 };
 
 namespace mozilla {
 
+typedef uint8_t EventClassIDType;
+
+enum EventClassID MOZ_ENUM_TYPE(EventClassIDType)
+{
+  // The event class name will be:
+  //   eBasicEventClass for WidgetEvent
+  //   eFooEventClass for WidgetFooEvent or InternalFooEvent
+#define NS_ROOT_EVENT_CLASS(aPrefix, aName)   eBasic##aName##Class
+#define NS_EVENT_CLASS(aPrefix, aName)      , e##aName##Class
+
+#include "mozilla/EventClassList.h"
+
+#undef NS_EVENT_CLASS
+#undef NS_ROOT_EVENT_CLASS
+};
+
 typedef uint16_t Modifiers;
 
 #define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \
   KEY_NAME_INDEX_##aCPPName,
 
 enum KeyNameIndex
 {
 #include "mozilla/KeyNameList.h"