From 4425f64e48d1976d53d1292aed7591ae3f6cde81 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 4 Aug 2014 14:28:58 +0900 Subject: [PATCH] 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 | 12 +++--- content/base/src/nsContentUtils.cpp | 24 ++++++------ dom/xbl/nsXBLEventHandler.cpp | 2 +- widget/BasicEvents.h | 57 +--------------------------- widget/EventForwards.h | 16 ++++++++ 5 files changed, 36 insertions(+), 75 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 4d2f656dcbd5..da8f18e041bf 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -151,7 +151,7 @@ struct EventNameMapping nsIAtom* mAtom; uint32_t mId; int32_t mType; - uint32_t mStructType; + mozilla::EventClassID mEventClassID; }; struct nsShortcutCandidate { @@ -1033,13 +1033,13 @@ class nsContentUtils 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. @@ -1048,10 +1048,10 @@ class nsContentUtils * 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); /** diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 41c0051c58f5..858e5f68014c 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -625,8 +625,8 @@ nsContentUtils::InitializeEventTable() { 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" @@ -658,9 +658,9 @@ nsContentUtils::InitializeTouchEventTable() 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 @@ -3602,25 +3602,25 @@ nsContentUtils::GetEventId(nsIAtom* aName) } // 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; } @@ -3639,7 +3639,7 @@ nsContentUtils::GetEventIdAndAtom(const nsAString& aName, 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; } diff --git a/dom/xbl/nsXBLEventHandler.cpp b/dom/xbl/nsXBLEventHandler.cpp index f8585cb2caaa..5661734a8fdc 100644 --- a/dom/xbl/nsXBLEventHandler.cpp +++ b/dom/xbl/nsXBLEventHandler.cpp @@ -148,7 +148,7 @@ NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler, nsIAtom* aEventType, nsXBLEventHandler** aResult) { - switch (nsContentUtils::GetEventCategory(nsDependentAtomString(aEventType))) { + switch (nsContentUtils::GetEventClassID(nsDependentAtomString(aEventType))) { case eDragEventClass: case eMouseEventClass: case eMouseScrollEventClass: diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index 4462ebdf9f5e..873882bccdaf 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -9,6 +9,7 @@ #include #include "mozilla/dom/EventTarget.h" +#include "mozilla/EventForwards.h" #include "mozilla/TimeStamp.h" #include "nsCOMPtr.h" #include "nsIAtom.h" @@ -17,62 +18,6 @@ #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 * diff --git a/widget/EventForwards.h b/widget/EventForwards.h index 1dc2c311d00c..cfaccd9c249c 100644 --- a/widget/EventForwards.h +++ b/widget/EventForwards.h @@ -30,6 +30,22 @@ enum nsEventStatus 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) \