Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1046101 part.33 Generate EventClassID with EventClassList.h in Ev…
Browse files Browse the repository at this point in the history
…entForwards.h and nsContentUtils should use it instead of uint32_t r=smaug
  • Loading branch information
masayuki-nakano committed Aug 4, 2014
1 parent a094aa8 commit 4425f64
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 75 deletions.
12 changes: 6 additions & 6 deletions content/base/public/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct EventNameMapping
nsIAtom* mAtom;
uint32_t mId;
int32_t mType;
uint32_t mStructType;
mozilla::EventClassID mEventClassID;
};

struct nsShortcutCandidate {
Expand Down Expand Up @@ -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.
Expand All @@ -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);

/**
Expand Down
24 changes: 12 additions & 12 deletions content/base/src/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/xbl/nsXBLEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
57 changes: 1 addition & 56 deletions widget/BasicEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include "mozilla/dom/EventTarget.h"
#include "mozilla/EventForwards.h"
#include "mozilla/TimeStamp.h"
#include "nsCOMPtr.h"
#include "nsIAtom.h"
Expand All @@ -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
*
Expand Down
16 changes: 16 additions & 0 deletions widget/EventForwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 4425f64

Please sign in to comment.