Bug 1386411 - Part 3: Inline some helper functions in Selection.cpp; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 01 Aug 2017 17:19:19 -0400
changeset 372771 99684f0b3ed66b52681016e77a585d90165ed332
parent 372770 61b7d37ac269656ffc7ba33380c0b0ecb897c7e3
child 372772 cb876b926c3221a3ce0b8e617b1442fb355cbf0a
push id32283
push userkwierso@gmail.com
push dateFri, 04 Aug 2017 01:07:14 +0000
treeherdermozilla-central@32083f24a1bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1386411
milestone57.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 1386411 - Part 3: Inline some helper functions in Selection.cpp; r=bzbarsky
dom/base/Selection.cpp
dom/base/Selection.h
dom/base/nsISelectionController.idl
widget/TextRange.h
widget/nsGUIEventIPC.h
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -127,58 +127,16 @@ ToChar(SelectionType aSelectionType)
       return "SelectionType::eURLSecondary";
     case SelectionType::eURLStrikeout:
       return "SelectionType::eURLStrikeout";
     default:
       return "Invalid SelectionType";
   }
 }
 
-static bool
-IsValidSelectionType(RawSelectionType aRawSelectionType)
-{
-  switch (static_cast<SelectionType>(aRawSelectionType)) {
-    case SelectionType::eNone:
-    case SelectionType::eNormal:
-    case SelectionType::eSpellCheck:
-    case SelectionType::eIMERawClause:
-    case SelectionType::eIMESelectedRawClause:
-    case SelectionType::eIMEConvertedClause:
-    case SelectionType::eIMESelectedClause:
-    case SelectionType::eAccessibility:
-    case SelectionType::eFind:
-    case SelectionType::eURLSecondary:
-    case SelectionType::eURLStrikeout:
-      return true;
-    default:
-      return false;
-  }
-}
-
-SelectionType
-ToSelectionType(RawSelectionType aRawSelectionType)
-{
-  if (!IsValidSelectionType(aRawSelectionType)) {
-    return SelectionType::eInvalid;
-  }
-  return static_cast<SelectionType>(aRawSelectionType);
-}
-
-RawSelectionType
-ToRawSelectionType(SelectionType aSelectionType)
-{
-  return static_cast<RawSelectionType>(aSelectionType);
-}
-
-bool operator &(SelectionType aSelectionType,
-                RawSelectionType aRawSelectionTypes)
-{
-  return (ToRawSelectionType(aSelectionType) & aRawSelectionTypes) != 0;
-}
-
 } // namespace mozilla
 
 //#define DEBUG_SELECTION // uncomment for printf describing every collapse and extend.
 //#define DEBUG_NAVIGATION
 
 
 //#define DEBUG_TABLE_SELECTION 1
 
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -510,16 +510,64 @@ public:
   {
     if (mSelection) {
       mSelection->RemoveSelectionChangeBlocker();
     }
   }
 };
 
 } // namespace dom
+
+inline bool
+IsValidSelectionType(RawSelectionType aRawSelectionType)
+{
+  switch (static_cast<SelectionType>(aRawSelectionType)) {
+    case SelectionType::eNone:
+    case SelectionType::eNormal:
+    case SelectionType::eSpellCheck:
+    case SelectionType::eIMERawClause:
+    case SelectionType::eIMESelectedRawClause:
+    case SelectionType::eIMEConvertedClause:
+    case SelectionType::eIMESelectedClause:
+    case SelectionType::eAccessibility:
+    case SelectionType::eFind:
+    case SelectionType::eURLSecondary:
+    case SelectionType::eURLStrikeout:
+      return true;
+    default:
+      return false;
+  }
+}
+
+inline SelectionType
+ToSelectionType(RawSelectionType aRawSelectionType)
+{
+  if (!IsValidSelectionType(aRawSelectionType)) {
+    return SelectionType::eInvalid;
+  }
+  return static_cast<SelectionType>(aRawSelectionType);
+}
+
+inline RawSelectionType
+ToRawSelectionType(SelectionType aSelectionType)
+{
+  return static_cast<RawSelectionType>(aSelectionType);
+}
+
+inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType)
+{
+  return ToRawSelectionType(ToSelectionType(aTextRangeType));
+}
+
+inline bool operator &(SelectionType aSelectionType,
+                       RawSelectionType aRawSelectionTypes)
+{
+  return (ToRawSelectionType(aSelectionType) & aRawSelectionTypes) != 0;
+}
+
 } // namespace mozilla
 
 inline mozilla::dom::Selection*
 nsISelection::AsSelection()
 {
   return static_cast<mozilla::dom::Selection*>(this);
 }
 
--- a/dom/base/nsISelectionController.idl
+++ b/dom/base/nsISelectionController.idl
@@ -308,15 +308,15 @@ enum : size_t
 {
   // kSelectionTypeCount is number of SelectionType.
   kSelectionTypeCount = nsISelectionController::NUM_SELECTIONTYPES,
   // kPresentSelectionTypeCount is number of SelectionType except "none".
   kPresentSelectionTypeCount = kSelectionTypeCount - 1
 };
 
 const char* ToChar(SelectionType aSelectionType);
-SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
-RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
-bool operator &(SelectionType aSelectionType,
-                RawSelectionType aRawSelectionTypes);
+inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
+inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
+inline bool operator &(SelectionType aSelectionType,
+                       RawSelectionType aRawSelectionTypes);
 
 } // namespace mozilla
 %}
--- a/widget/TextRange.h
+++ b/widget/TextRange.h
@@ -140,21 +140,16 @@ enum class TextRangeType : RawTextRangeT
 };
 
 bool IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeValue);
 RawTextRangeType ToRawTextRangeType(TextRangeType aTextRangeType);
 TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType);
 const char* ToChar(TextRangeType aTextRangeType);
 SelectionType ToSelectionType(TextRangeType aTextRangeType);
 
-inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType)
-{
-  return ToRawSelectionType(ToSelectionType(aTextRangeType));
-}
-
 struct TextRange
 {
   TextRange()
     : mStartOffset(0)
     , mEndOffset(0)
     , mRangeType(TextRangeType::eUninitialized)
   {
   }
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -9,16 +9,17 @@
 #include "ipc/IPCMessageUtils.h"
 #include "mozilla/ContentCache.h"
 #include "mozilla/GfxMessageUtils.h"
 #include "mozilla/dom/Touch.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
+#include "mozilla/dom/Selection.h"
 #include "InputData.h"
 
 namespace IPC
 {
 
 template<>
 struct ParamTraits<mozilla::EventMessage>
 {