Bug 1175382 TextRangeArray::TargetClauseOffset() and TextRangeArray::TargetClauseLength() shouldn't be public and same name methods of WidgetCompositionEvent should be used r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 18 Jun 2015 13:43:18 +0900
changeset 249506 d7492a39e7428093eae563b329addb44a060cf49
parent 249505 328551ccf9eec335cf60f0226694996f539ebc01
child 249507 b94564503734e4c42ef40c7edde627ca781b2da7
push id28927
push usercbook@mozilla.com
push dateThu, 18 Jun 2015 13:13:33 +0000
treeherdermozilla-central@efe86609e776 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1175382
milestone41.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 1175382 TextRangeArray::TargetClauseOffset() and TextRangeArray::TargetClauseLength() shouldn't be public and same name methods of WidgetCompositionEvent should be used r=m_kato
widget/TextRange.h
widget/gtk/nsGtkIMModule.cpp
--- a/widget/TextRange.h
+++ b/widget/TextRange.h
@@ -186,59 +186,61 @@ struct TextRange
   }
 };
 
 /******************************************************************************
  * mozilla::TextRangeArray
  ******************************************************************************/
 class TextRangeArray final : public nsAutoTArray<TextRange, 10>
 {
+  friend class WidgetCompositionEvent;
+
   ~TextRangeArray() {}
 
   NS_INLINE_DECL_REFCOUNTING(TextRangeArray)
 
   const TextRange* GetTargetClause() const
   {
     for (uint32_t i = 0; i < Length(); ++i) {
       const TextRange& range = ElementAt(i);
       if (range.mRangeType == NS_TEXTRANGE_SELECTEDRAWTEXT ||
           range.mRangeType == NS_TEXTRANGE_SELECTEDCONVERTEDTEXT) {
         return &range;
       }
     }
     return nullptr;
   }
 
-public:
-  bool IsComposing() const
-  {
-    for (uint32_t i = 0; i < Length(); ++i) {
-      if (ElementAt(i).IsClause()) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   // Returns target clause offset.  If there are selected clauses, this returns
   // the first selected clause offset.  Otherwise, 0.
   uint32_t TargetClauseOffset() const
   {
     const TextRange* range = GetTargetClause();
     return range ? range->mStartOffset : 0;
   }
 
   // Returns target clause length.  If there are selected clauses, this returns
   // the first selected clause length.  Otherwise, UINT32_MAX.
   uint32_t TargetClauseLength() const
   {
     const TextRange* range = GetTargetClause();
     return range ? range->Length() : UINT32_MAX;
   }
 
+public:
+  bool IsComposing() const
+  {
+    for (uint32_t i = 0; i < Length(); ++i) {
+      if (ElementAt(i).IsClause()) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   bool Equals(const TextRangeArray& aOther) const
   {
     size_t len = Length();
     if (len != aOther.Length()) {
       return false;
     }
     for (size_t i = 0; i < len; i++) {
       if (!ElementAt(i).Equals(aOther.ElementAt(i))) {
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -1205,27 +1205,27 @@ nsGtkIMModule::DispatchCompositionChange
 
     uint32_t targetOffset = mCompositionStart;
 
     compositionChangeEvent.mData =
       mDispatchedCompositionString = aCompositionString;
 
     compositionChangeEvent.mRanges =
       CreateTextRangeArray(aContext, mDispatchedCompositionString);
-    targetOffset += compositionChangeEvent.mRanges->TargetClauseOffset();
+    targetOffset += compositionChangeEvent.TargetClauseOffset();
 
     mCompositionState = eCompositionState_CompositionChangeEventDispatched;
 
     // We cannot call SetCursorPosition for e10s-aware.
     // DispatchEvent is async on e10s, so composition rect isn't updated now
     // on tab parent.
     mLayoutChanged = false;
     mCompositionTargetRange.mOffset = targetOffset;
     mCompositionTargetRange.mLength =
-        compositionChangeEvent.mRanges->TargetClauseLength();
+        compositionChangeEvent.TargetClauseLength();
 
     mLastFocusedWindow->DispatchEvent(&compositionChangeEvent, status);
     if (lastFocusedWindow->IsDestroyed() ||
         lastFocusedWindow != mLastFocusedWindow) {
         MOZ_LOG(gGtkIMLog, LogLevel::Info,
             ("    NOTE, the focused widget was destroyed/changed by "
              "compositionchange event"));
         return false;