Bug 1204439 part.3 Create methods to get enum item name r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 17 Sep 2015 12:05:44 +0900
changeset 295566 632ffd1d42ba18eeed7edc09de746a4c777eeddb
parent 295565 baeaf70bec1dbe78e2d56d5ba05d9ef739e2fbb3
child 295567 65cec42b60faaca7166b1db707d1c4f98d3f8e88
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1204439
milestone43.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 1204439 part.3 Create methods to get enum item name r=smaug
dom/events/IMEContentObserver.cpp
dom/events/IMEStateManager.cpp
widget/ContentCache.cpp
widget/EventForwards.h
widget/WidgetEventImpl.cpp
widget/windows/TSFTextStore.cpp
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -43,43 +43,16 @@ PRLogModuleInfo* sIMECOLog = nullptr;
 
 static const char*
 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)
 {
   switch (aIMEMessage) {
     case NOTIFY_IME_OF_NOTHING:
       return "NOTIFY_IME_OF_NOTHING";
     case NOTIFY_IME_OF_FOCUS:
       return "NOTIFY_IME_OF_FOCUS";
     case NOTIFY_IME_OF_BLUR:
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -129,39 +129,16 @@ GetIMEStateSetOpenName(IMEState::Open aO
     case IMEState::CLOSED:
       return "CLOSED";
     default:
       return "illegal value";
   }
 }
 
 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)
 {
   switch (aMessage) {
     case NOTIFY_IME_OF_FOCUS:
       return "NOTIFY_IME_OF_FOCUS";
     case NOTIFY_IME_OF_BLUR:
       return "NOTIFY_IME_OF_BLUR";
     case NOTIFY_IME_OF_SELECTION_CHANGE:
@@ -1132,17 +1109,17 @@ IMEStateManager::DispatchCompositionEven
       TabParent::GetFrom(aEventTargetNode->AsContent()) : nullptr;
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("ISM: IMEStateManager::DispatchCompositionEvent(aNode=0x%p, "
      "aPresContext=0x%p, aCompositionEvent={ message=%s, "
      "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()));
 
   if (!aCompositionEvent->mFlags.mIsTrusted ||
       aCompositionEvent->mFlags.mPropagationStopped) {
     return;
   }
@@ -1230,17 +1207,17 @@ IMEStateManager::HandleSelectionEvent(ns
   nsRefPtr<TabParent> tabParent =
     eventTargetContent ? TabParent::GetFrom(eventTargetContent) : nullptr;
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("ISM: IMEStateManager::HandleSelectionEvent(aPresContext=0x%p, "
      "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()));
 
   if (!aSelectionEvent->mFlags.mIsTrusted) {
     return;
   }
 
   nsRefPtr<TextComposition> composition = sTextCompositions ?
@@ -1263,17 +1240,17 @@ IMEStateManager::OnCompositionEventDisca
                    WidgetCompositionEvent* aCompositionEvent)
 {
   // Note that this method is never called for synthesized events for emulating
   // commit or cancel composition.
 
   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) {
     return;
   }
 
   // Ignore compositionstart for now because sTextCompositions may not have
   // been created yet.
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -19,39 +19,16 @@ using namespace widget;
 
 static const char*
 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)
 {
   if (!aNotification) {
     return "Not notification";
   }
   switch (aNotification->mMessage) {
     case NOTIFY_IME_OF_FOCUS:
       return "NOTIFY_IME_OF_FOCUS";
@@ -846,17 +823,17 @@ ContentCacheInParent::GetCaretRect(uint3
 bool
 ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("ContentCacheInParent: 0x%p OnCompositionEvent(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),
      GetBoolName(mRequestedToCommitOrCancelComposition)));
 
   if (!aEvent.CausesDOMTextEvent()) {
     MOZ_ASSERT(aEvent.mMessage == eCompositionStart);
     mIsComposing = !aEvent.CausesDOMCompositionEndEvent();
@@ -900,17 +877,17 @@ void
 ContentCacheInParent::OnSelectionEvent(
                         const WidgetSelectionEvent& aSelectionEvent)
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("ContentCacheInParent: 0x%p OnSelectionEvent(aEvent={ "
      "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),
      GetBoolName(aSelectionEvent.mUseNativeLineBreak), mPendingEventsNeedingAck,
      GetBoolName(mIsComposing)));
 
   mPendingEventsNeedingAck++;
 }
@@ -920,17 +897,17 @@ ContentCacheInParent::OnEventNeedingAckH
                                                 EventMessage aMessage)
 {
   // This is called when the child process receives WidgetCompositionEvent or
   // WidgetSelectionEvent.
 
   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) {
     return;
   }
 
   FlushPendingNotifications(aWidget);
 }
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -47,16 +47,18 @@ enum EventMessage : EventMessageType
 
 #undef NS_EVENT_MESSAGE
 #undef NS_EVENT_MESSAGE_FIRST_LAST
 
   // For preventing bustage due to "," after the last item.
   eEventMessage_MaxValue
 };
 
+const char* ToChar(EventMessage aEventMessage);
+
 /**
  * Event class IDs
  */
 
 typedef uint8_t EventClassIDType;
 
 enum EventClassID : EventClassIDType
 {
@@ -67,16 +69,18 @@ enum EventClassID : EventClassIDType
 #define NS_EVENT_CLASS(aPrefix, aName)      , e##aName##Class
 
 #include "mozilla/EventClassList.h"
 
 #undef NS_EVENT_CLASS
 #undef NS_ROOT_EVENT_CLASS
 };
 
+const char* ToChar(EventClassID aEventClassID);
+
 typedef uint16_t Modifiers;
 
 #define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \
   KEY_NAME_INDEX_##aCPPName,
 
 enum KeyNameIndex
 {
 #include "mozilla/KeyNameList.h"
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -10,16 +10,59 @@
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 
 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
  ******************************************************************************/
 
 #define NS_ROOT_EVENT_CLASS(aPrefix, aName)
 #define NS_EVENT_CLASS(aPrefix, aName) \
 aPrefix##aName* \
 WidgetEvent::As##aName() \
 { \
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -530,29 +530,16 @@ GetDisplayAttrStr(const TF_DISPLAYATTRIB
   str += ", crLine:{ ";
   str += GetColorName(aDispAttr.crLine);
   str += " }, bAttr: ";
   str += GetClauseAttrName(aDispAttr.bAttr);
   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)
 {
   switch (aButton) {
     case WidgetMouseEventBase::eLeftButton:
       return "LeftButton";
     case WidgetMouseEventBase::eMiddleButton:
       return "MiddleButton";
     case WidgetMouseEventBase::eRightButton:
@@ -4739,18 +4726,17 @@ TSFTextStore::OnMouseButtonEventInternal
     return NS_OK;
   }
 
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   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,
           aIMENotification.mMouseButtonEventData.mCharRect.mX,
           aIMENotification.mMouseButtonEventData.mCharRect.mY,
           aIMENotification.mMouseButtonEventData.mCharRect.mWidth,
           aIMENotification.mMouseButtonEventData.mCharRect.mHeight,
           GetMouseButtonName(aIMENotification.mMouseButtonEventData.mButton),