Bug 1204439 part.3 Create methods to get enum item name r=smaug

This commit is contained in:
Masayuki Nakano 2015-09-17 12:05:44 +09:00
parent 8515f08052
commit 8494e42434
6 changed files with 54 additions and 94 deletions

View File

@ -47,33 +47,6 @@ ToChar(bool aBool)
return aBool ? "true" : "false";
}
static const char*
ToChar(EventMessage aEventMessage)
{
switch (aEventMessage) {
case eQuerySelectedText:
return "eQuerySelectedText";
case eQueryTextContent:
return "eQueryTextContent";
case eQueryCaretRect:
return "eQueryCaretRect";
case eQueryTextRect:
return "eQueryTextRect";
case eQueryEditorRect:
return "eQueryEditorRect";
case eQueryContentState:
return "eQueryContentState";
case eQuerySelectionAsTransferable:
return "eQuerySelectionAsTransferable";
case eQueryCharacterAtPoint:
return "eQueryCharacterAtPoint";
case eQueryDOMWidgetHittest:
return "eQueryDOMWidgetHittest";
default:
return "Unsupported message";
}
}
static const char*
ToChar(IMEMessage aIMEMessage)
{

View File

@ -133,29 +133,6 @@ GetIMEStateSetOpenName(IMEState::Open aOpen)
}
}
static const char*
GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case eCompositionStart:
return "eCompositionStart";
case eCompositionEnd:
return "eCompositionEnd";
case eCompositionUpdate:
return "eCompositionUpdate";
case eCompositionChange:
return "eCompositionChange";
case eCompositionCommitAsIs:
return "eCompositionCommitAsIs";
case eCompositionCommit:
return "eCompositionCommit";
case eSetSelection:
return "eSetSelection";
default:
return "unacceptable event message";
}
}
static const char*
GetNotifyIMEMessageName(IMEMessage aMessage)
{
@ -1137,7 +1114,7 @@ IMEStateManager::DispatchCompositionEvent(
"mFlags={ mIsTrusted=%s, mPropagationStopped=%s } }, "
"aIsSynthesized=%s), tabParent=%p",
aEventTargetNode, aPresContext,
GetEventMessageName(aCompositionEvent->mMessage),
ToChar(aCompositionEvent->mMessage),
GetBoolName(aCompositionEvent->mFlags.mIsTrusted),
GetBoolName(aCompositionEvent->mFlags.mPropagationStopped),
GetBoolName(aIsSynthesized), tabParent.get()));
@ -1235,7 +1212,7 @@ IMEStateManager::HandleSelectionEvent(nsPresContext* aPresContext,
"aEventTargetContent=0x%p, aSelectionEvent={ mMessage=%s, "
"mFlags={ mIsTrusted=%s } }), tabParent=%p",
aPresContext, aEventTargetContent,
GetEventMessageName(aSelectionEvent->mMessage),
ToChar(aSelectionEvent->mMessage),
GetBoolName(aSelectionEvent->mFlags.mIsTrusted),
tabParent.get()));
@ -1268,7 +1245,7 @@ IMEStateManager::OnCompositionEventDiscarded(
MOZ_LOG(sISMLog, LogLevel::Info,
("ISM: IMEStateManager::OnCompositionEventDiscarded(aCompositionEvent={ "
"mMessage=%s, mFlags={ mIsTrusted=%s } })",
GetEventMessageName(aCompositionEvent->mMessage),
ToChar(aCompositionEvent->mMessage),
GetBoolName(aCompositionEvent->mFlags.mIsTrusted)));
if (!aCompositionEvent->mFlags.mIsTrusted) {

View File

@ -23,29 +23,6 @@ GetBoolName(bool aBool)
return aBool ? "true" : "false";
}
static const char*
GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case eCompositionStart:
return "eCompositionStart";
case eCompositionEnd:
return "eCompositionEnd";
case eCompositionUpdate:
return "eCompositionUpdate";
case eCompositionChange:
return "eCompositionChange";
case eCompositionCommitAsIs:
return "eCompositionCommitAsIs";
case eCompositionCommit:
return "eCompositionCommit";
case eSetSelection:
return "eSetSelection";
default:
return "unacceptable event message";
}
}
static const char*
GetNotificationName(const IMENotification* aNotification)
{
@ -851,7 +828,7 @@ ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
"mMessage=%s, mData=\"%s\" (Length()=%u), mRanges->Length()=%u }), "
"mPendingEventsNeedingAck=%u, mIsComposing=%s, "
"mRequestedToCommitOrCancelComposition=%s",
this, GetEventMessageName(aEvent.mMessage),
this, ToChar(aEvent.mMessage),
NS_ConvertUTF16toUTF8(aEvent.mData).get(), aEvent.mData.Length(),
aEvent.mRanges ? aEvent.mRanges->Length() : 0, mPendingEventsNeedingAck,
GetBoolName(mIsComposing),
@ -905,7 +882,7 @@ ContentCacheInParent::OnSelectionEvent(
"mMessage=%s, mOffset=%u, mLength=%u, mReversed=%s, "
"mExpandToClusterBoundary=%s, mUseNativeLineBreak=%s }), "
"mPendingEventsNeedingAck=%u, mIsComposing=%s",
this, GetEventMessageName(aSelectionEvent.mMessage),
this, ToChar(aSelectionEvent.mMessage),
aSelectionEvent.mOffset, aSelectionEvent.mLength,
GetBoolName(aSelectionEvent.mReversed),
GetBoolName(aSelectionEvent.mExpandToClusterBoundary),
@ -925,7 +902,7 @@ ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget,
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p OnEventNeedingAckHandled(aWidget=0x%p, "
"aMessage=%s), mPendingEventsNeedingAck=%u",
this, aWidget, GetEventMessageName(aMessage), mPendingEventsNeedingAck));
this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck));
MOZ_RELEASE_ASSERT(mPendingEventsNeedingAck > 0);
if (--mPendingEventsNeedingAck) {

View File

@ -52,6 +52,8 @@ enum EventMessage : EventMessageType
eEventMessage_MaxValue
};
const char* ToChar(EventMessage aEventMessage);
/**
* Event class IDs
*/
@ -72,6 +74,8 @@ enum EventClassID : EventClassIDType
#undef NS_ROOT_EVENT_CLASS
};
const char* ToChar(EventClassID aEventClassID);
typedef uint16_t Modifiers;
#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \

View File

@ -14,6 +14,49 @@
namespace mozilla {
/******************************************************************************
* Global helper methods
******************************************************************************/
const char*
ToChar(EventMessage aEventMessage)
{
switch (aEventMessage) {
#define NS_EVENT_MESSAGE(aMessage) \
case aMessage: \
return #aMessage;
#include "mozilla/EventMessageList.h"
#undef NS_EVENT_MESSAGE
default:
return "illegal event message";
}
}
const char*
ToChar(EventClassID aEventClassID)
{
switch (aEventClassID) {
#define NS_ROOT_EVENT_CLASS(aPrefix, aName) \
case eBasic##aName##Class: \
return "eBasic" #aName "Class";
#define NS_EVENT_CLASS(aPrefix, aName) \
case e##aName##Class: \
return "e" #aName "Class";
#include "mozilla/EventClassList.h"
#undef NS_EVENT_CLASS
#undef NS_ROOT_EVENT_CLASS
default:
return "illegal event class ID";
}
}
/******************************************************************************
* As*Event() implementation
******************************************************************************/

View File

@ -534,19 +534,6 @@ GetDisplayAttrStr(const TF_DISPLAYATTRIBUTE& aDispAttr)
return str;
}
static const char*
GetEventMessageName(uint32_t aMessage)
{
switch (aMessage) {
case eMouseDown:
return "eMouseDown";
case eMouseUp:
return "eMouseUp";
default:
return "Unknown";
}
}
static const char*
GetMouseButtonName(int16_t aButton)
{
@ -4744,8 +4731,7 @@ TSFTextStore::OnMouseButtonEventInternal(
"aIMENotification={ mEventMessage=%s, mOffset=%u, mCursorPos={ "
"mX=%d, mY=%d }, mCharRect={ mX=%d, mY=%d, mWidth=%d, mHeight=%d }, "
"mButton=%s, mButtons=%s, mModifiers=%s })",
this, GetEventMessageName(
aIMENotification.mMouseButtonEventData.mEventMessage),
this, ToChar(aIMENotification.mMouseButtonEventData.mEventMessage),
aIMENotification.mMouseButtonEventData.mOffset,
aIMENotification.mMouseButtonEventData.mCursorPos.mX,
aIMENotification.mMouseButtonEventData.mCursorPos.mY,