Bug 920377 part.20 Get rid of nsTextRange r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 01 Oct 2013 16:22:59 +0900
changeset 164196 2e92ba62e3e6d3d171b8cb0d25ce9d6474aa9cf7
parent 164195 3cef286bd24f4fb8895c27284c207d44a9e9d3fe
child 164197 d04a5b8e1499d2d4a0bdac8d4f8ff4d3f6a71552
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs920377
milestone27.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 920377 part.20 Get rid of nsTextRange r=roc
content/events/src/nsPrivateTextRange.cpp
content/events/src/nsPrivateTextRange.h
dom/base/CompositionStringSynthesizer.cpp
dom/base/CompositionStringSynthesizer.h
widget/EventForwards.h
widget/TextEvents.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/gtk/nsGtkIMModule.cpp
widget/gtk/nsGtkIMModule.h
widget/nsGUIEventIPC.h
widget/os2/nsWindow.cpp
widget/windows/nsIMM32Handler.cpp
widget/windows/nsIMM32Handler.h
widget/windows/nsTextStore.cpp
widget/windows/nsTextStore.h
--- a/content/events/src/nsPrivateTextRange.cpp
+++ b/content/events/src/nsPrivateTextRange.cpp
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsPrivateTextRange.h"
 #include "mozilla/TextEvents.h"
 
 using namespace mozilla;
 
-nsPrivateTextRange::nsPrivateTextRange(const nsTextRange &aTextRange)
+nsPrivateTextRange::nsPrivateTextRange(const TextRange &aTextRange)
   : mRangeStart(uint16_t(aTextRange.mStartOffset)),
     mRangeEnd(uint16_t(aTextRange.mEndOffset)),
     mRangeType(uint16_t(aTextRange.mRangeType)),
     mRangeStyle(aTextRange.mRangeStyle)
 {
 }
 
 nsPrivateTextRange::~nsPrivateTextRange(void)
--- a/content/events/src/nsPrivateTextRange.h
+++ b/content/events/src/nsPrivateTextRange.h
@@ -12,17 +12,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/TextEvents.h"
 
 class nsPrivateTextRange MOZ_FINAL : public nsIPrivateTextRange
 {
 	NS_DECL_ISUPPORTS
 public:
 
-	nsPrivateTextRange(const nsTextRange &aTextRange);
+	nsPrivateTextRange(const mozilla::TextRange &aTextRange);
 	virtual ~nsPrivateTextRange(void);
 
 	NS_IMETHOD GetRangeStart(uint16_t* aRangeStart) MOZ_OVERRIDE;
 	NS_IMETHOD GetRangeEnd(uint16_t* aRangeEnd) MOZ_OVERRIDE;
 	NS_IMETHOD GetRangeType(uint16_t* aRangeType) MOZ_OVERRIDE;
 	NS_IMETHOD GetRangeStyle(mozilla::TextRangeStyle* aRangeStyle) MOZ_OVERRIDE;
 
 protected:
--- a/dom/base/CompositionStringSynthesizer.cpp
+++ b/dom/base/CompositionStringSynthesizer.cpp
@@ -77,17 +77,17 @@ CompositionStringSynthesizer::AppendClau
   nsCOMPtr<nsIWidget> widget = GetWidget();
   NS_ENSURE_TRUE(widget && !widget->Destroyed(), NS_ERROR_NOT_AVAILABLE);
 
   switch (aAttribute) {
     case ATTR_RAWINPUT:
     case ATTR_SELECTEDRAWTEXT:
     case ATTR_CONVERTEDTEXT:
     case ATTR_SELECTEDCONVERTEDTEXT: {
-      nsTextRange textRange;
+      TextRange textRange;
       textRange.mStartOffset =
         mClauses.IsEmpty() ? 0 : mClauses[mClauses.Length() - 1].mEndOffset;
       textRange.mEndOffset = textRange.mStartOffset + aLength;
       textRange.mRangeType = aAttribute;
       mClauses.AppendElement(textRange);
       return NS_OK;
     }
     default:
--- a/dom/base/CompositionStringSynthesizer.h
+++ b/dom/base/CompositionStringSynthesizer.h
@@ -27,18 +27,18 @@ public:
   ~CompositionStringSynthesizer();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICOMPOSITIONSTRINGSYNTHESIZER
 
 private:
   nsWeakPtr mWindow; // refers an instance of nsPIDOMWindow
   nsString mString;
-  nsAutoTArray<nsTextRange, 10> mClauses;
-  nsTextRange mCaret;
+  nsAutoTArray<TextRange, 10> mClauses;
+  TextRange mCaret;
 
   nsIWidget* GetWidget();
   void ClearInternal();
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -102,17 +102,16 @@ class WidgetPluginEvent;
 class InternalMutationEvent;
 } // namespace mozilla
 
 // TODO: Remove following typedefs
 typedef mozilla::WidgetEvent               nsEvent;
 typedef mozilla::WidgetGUIEvent            nsGUIEvent;
 typedef mozilla::WidgetInputEvent          nsInputEvent;
 typedef mozilla::InternalUIEvent           nsUIEvent;
-typedef mozilla::TextRange                 nsTextRange;
 typedef mozilla::WidgetTextEvent           nsTextEvent;
 typedef mozilla::WidgetCompositionEvent    nsCompositionEvent;
 typedef mozilla::WidgetQueryContentEvent   nsQueryContentEvent;
 typedef mozilla::WidgetSelectionEvent      nsSelectionEvent;
 typedef mozilla::WidgetMouseEventBase      nsMouseEvent_base;
 typedef mozilla::WidgetMouseEvent          nsMouseEvent;
 typedef mozilla::WidgetDragEvent           nsDragEvent;
 typedef mozilla::WidgetMouseScrollEvent    nsMouseScrollEvent;
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -529,15 +529,14 @@ public:
   bool mExpandToClusterBoundary;
   // true if setting selection succeeded.
   bool mSucceeded;
 };
 
 } // namespace mozilla
 
 // TODO: Remove following typedefs
-typedef mozilla::TextRange               nsTextRange;
 typedef mozilla::WidgetTextEvent         nsTextEvent;
 typedef mozilla::WidgetCompositionEvent  nsCompositionEvent;
 typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
 typedef mozilla::WidgetSelectionEvent    nsSelectionEvent;
 
 #endif // mozilla_TextEvents_h__
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1975,17 +1975,17 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             selEvent.mReversed = start > end;
             selEvent.mExpandToClusterBoundary = false;
 
             DispatchEvent(&selEvent);
         }
         break;
     case AndroidGeckoEvent::IME_ADD_COMPOSITION_RANGE:
         {
-            nsTextRange range;
+            TextRange range;
             range.mStartOffset = ae->Start();
             range.mEndOffset = ae->End();
             range.mRangeType = ae->RangeType();
             range.mRangeStyle.mDefinedStyles = ae->RangeStyles();
             range.mRangeStyle.mLineStyle = ae->RangeLineStyle();
             range.mRangeStyle.mIsBoldLine = ae->RangeBoldLine();
             range.mRangeStyle.mForegroundColor =
                     ConvertAndroidColor(uint32_t(ae->RangeForeColor()));
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -186,17 +186,17 @@ protected:
     double mLastDist;
 
     nsCOMPtr<nsIIdleServiceInternal> mIdleService;
 
     bool mIMEComposing;
     bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate;
     int32_t mIMEMaskEventsCount; // Mask events when > 0
     nsString mIMEComposingText;
-    nsAutoTArray<nsTextRange, 4> mIMERanges;
+    nsAutoTArray<mozilla::TextRange, 4> mIMERanges;
     bool mIMEUpdatingContext;
     nsAutoTArray<mozilla::AndroidGeckoEvent, 8> mIMEKeyEvents;
 
     struct IMEChange {
         int32_t mStart, mOldEnd, mNewEnd;
 
         IMEChange() :
             mStart(-1), mOldEnd(-1), mNewEnd(-1)
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -1060,23 +1060,23 @@ private:
 
   /**
    * SetTextRangeList() appends text ranges to aTextRangeList.
    *
    * @param aTextRangeList        When SetTextRangeList() returns, this will
    *                              be set to the NSUnderlineStyleAttributeName
    *                              ranges in aAttrString.  Note that if you pass
    *                              in a large enough auto-range instance for most
-   *                              cases (e.g., nsAutoTArray<nsTextRange, 4>),
+   *                              cases (e.g., nsAutoTArray<TextRange, 4>),
    *                              it prevents memory fragmentation.
    * @param aAttrString           An NSAttributedString instance which indicates
    *                              current composition string.
    * @param aSelectedRange        Current selected range (or caret position).
    */
-  void SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
+  void SetTextRangeList(nsTArray<TextRange>& aTextRangeList,
                         NSAttributedString *aAttrString,
                         NSRange& aSelectedRange);
 
   /**
    * InitCompositionEvent() initializes aCompositionEvent.
    *
    * @param aCompositionEvent     A composition event which you want to
    *                              initialize.
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2551,36 +2551,36 @@ IMEInputHandler::GetRangeCount(NSAttribu
      this, GetCharacters([aAttrString string]), count));
 
   return count;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 void
-IMEInputHandler::SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
+IMEInputHandler::SetTextRangeList(nsTArray<TextRange>& aTextRangeList,
                                   NSAttributedString *aAttrString,
                                   NSRange& aSelectedRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  // Convert the Cocoa range into the nsTextRange Array used in Gecko.
+  // Convert the Cocoa range into the TextRange Array used in Gecko.
   // Iterate through the attributed string and map the underline attribute to
   // Gecko IME textrange attributes.  We may need to change the code here if
   // we change the implementation of validAttributesForMarkedText.
   NSRange limitRange = NSMakeRange(0, [aAttrString length]);
   uint32_t rangeCount = GetRangeCount(aAttrString);
   for (uint32_t i = 0; i < rangeCount && limitRange.length > 0; i++) {
     NSRange effectiveRange;
     id attributeValue = [aAttrString attribute:NSUnderlineStyleAttributeName
                                        atIndex:limitRange.location
                          longestEffectiveRange:&effectiveRange
                                        inRange:limitRange];
 
-    nsTextRange range;
+    TextRange range;
     range.mStartOffset = effectiveRange.location;
     range.mEndOffset = NSMaxRange(effectiveRange);
     range.mRangeType =
       ConvertToTextRangeType([attributeValue intValue], aSelectedRange);
     aTextRangeList.AppendElement(range);
 
     PR_LOG(gLog, PR_LOG_ALWAYS,
       ("%p IMEInputHandler::SetTextRangeList, "
@@ -2589,17 +2589,17 @@ IMEInputHandler::SetTextRangeList(nsTArr
        GetRangeTypeName(range.mRangeType)));
 
     limitRange =
       NSMakeRange(NSMaxRange(effectiveRange), 
                   NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
   }
 
   // Get current caret position.
-  nsTextRange range;
+  TextRange range;
   range.mStartOffset = aSelectedRange.location + aSelectedRange.length;
   range.mEndOffset = range.mStartOffset;
   range.mRangeType = NS_TEXTRANGE_CARETPOSITION;
   aTextRangeList.AppendElement(range);
 
   PR_LOG(gLog, PR_LOG_ALWAYS,
     ("%p IMEInputHandler::SetTextRangeList, "
      "range={ mStartOffset=%llu, mEndOffset=%llu, mRangeType=%s }",
@@ -2627,17 +2627,17 @@ IMEInputHandler::DispatchTextEvent(const
 
   NS_ENSURE_TRUE(!Destroyed(), false);
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
   nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget);
   textEvent.time = PR_IntervalNow();
   textEvent.theText = aText;
-  nsAutoTArray<nsTextRange, 4> textRanges;
+  nsAutoTArray<TextRange, 4> textRanges;
   if (!aDoCommit) {
     SetTextRangeList(textRanges, aAttrString, aSelectedRange);
   }
   textEvent.rangeArray = textRanges.Elements();
   textEvent.rangeCount = textRanges.Length();
 
   if (textEvent.theText != mLastDispatchedCompositionString) {
     nsCompositionEvent compositionUpdate(true, NS_COMPOSITION_UPDATE,
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -1085,23 +1085,23 @@ nsGtkIMModule::DispatchTextEvent(const n
         }
     }
 
     nsTextEvent textEvent(true, NS_TEXT_TEXT, mLastFocusedWindow);
     InitEvent(textEvent);
 
     uint32_t targetOffset = mCompositionStart;
 
-    nsAutoTArray<nsTextRange, 4> textRanges;
+    nsAutoTArray<TextRange, 4> textRanges;
     if (!aIsCommit) {
         // NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
         //       has been updated already.
         SetTextRangeList(textRanges);
         for (uint32_t i = 0; i < textRanges.Length(); i++) {
-            nsTextRange& range = textRanges[i];
+            TextRange& range = textRanges[i];
             if (range.mRangeType == NS_TEXTRANGE_SELECTEDRAWTEXT ||
                 range.mRangeType == NS_TEXTRANGE_SELECTEDCONVERTEDTEXT) {
                 targetOffset += range.mStartOffset;
                 break;
             }
         }
     }
 
@@ -1122,17 +1122,17 @@ nsGtkIMModule::DispatchTextEvent(const n
     }
 
     SetCursorPosition(targetOffset);
 
     return true;
 }
 
 void
-nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
+nsGtkIMModule::SetTextRangeList(nsTArray<TextRange> &aTextRangeList)
 {
     PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
         ("GtkIMModule(%p): SetTextRangeList", this));
 
     NS_PRECONDITION(aTextRangeList.IsEmpty(), "aTextRangeList must be empty");
 
     gchar *preedit_string;
     gint cursor_pos;
@@ -1174,17 +1174,17 @@ nsGtkIMModule::SetTextRangeList(nsTArray
         if (!attrUnderline && !attrForeground) {
             continue;
         }
 
         // Get the range of the current attribute(s)
         gint start, end;
         pango_attr_iterator_range(iter, &start, &end);
 
-        nsTextRange range;
+        TextRange range;
         // XIMReverse | XIMUnderline
         if (attrUnderline && attrForeground) {
             range.mRangeType = NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
         }
         // XIMUnderline
         else if (attrUnderline) {
             range.mRangeType = NS_TEXTRANGE_CONVERTEDTEXT;
         }
@@ -1223,17 +1223,17 @@ nsGtkIMModule::SetTextRangeList(nsTArray
         aTextRangeList.AppendElement(range);
 
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    mStartOffset=%u, mEndOffset=%u, mRangeType=%s",
              range.mStartOffset, range.mEndOffset,
              GetRangeTypeName(range.mRangeType)));
     } while (pango_attr_iterator_next(iter));
 
-    nsTextRange range;
+    TextRange range;
     if (cursor_pos < 0) {
         range.mStartOffset = 0;
     } else if (uint32_t(cursor_pos) > mDispatchedCompositionString.Length()) {
         range.mStartOffset = mDispatchedCompositionString.Length();
     } else {
         range.mStartOffset = uint32_t(cursor_pos);
     }
     range.mEndOffset = range.mStartOffset;
--- a/widget/gtk/nsGtkIMModule.h
+++ b/widget/gtk/nsGtkIMModule.h
@@ -254,17 +254,17 @@ protected:
     // Reset the current composition of IME.  All native composition events
     // during this processing are ignored.
     void ResetIME();
 
     // Gets the current composition string by the native APIs.
     void GetCompositionString(nsAString &aCompositionString);
 
     // Generates our text range list from current composition string.
-    void SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList);
+    void SetTextRangeList(nsTArray<mozilla::TextRange>& aTextRangeList);
 
     // Sets the offset's cursor position to IME.
     void SetCursorPosition(uint32_t aTargetOffset);
 
     // Queries the current selection offset of the window.
     uint32_t GetSelectionOffset(nsWindow* aWindow);
 
     // Get current paragraph text content and cursor position
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -310,19 +310,19 @@ struct ParamTraits<mozilla::TextRangeSty
            ReadParam(aMsg, aIter, &aResult->mIsBoldLine) &&
            ReadParam(aMsg, aIter, &aResult->mForegroundColor) &&
            ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
            ReadParam(aMsg, aIter, &aResult->mUnderlineColor);
   }
 };
 
 template<>
-struct ParamTraits<nsTextRange>
+struct ParamTraits<mozilla::TextRange>
 {
-  typedef nsTextRange paramType;
+  typedef mozilla::TextRange paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.mStartOffset);
     WriteParam(aMsg, aParam.mEndOffset);
     WriteParam(aMsg, aParam.mRangeType);
     WriteParam(aMsg, aParam.mRangeStyle);
   }
@@ -361,17 +361,17 @@ struct ParamTraits<nsTextEvent>
         !ReadParam(aMsg, aIter, &aResult->rangeCount))
       return false;
 
     if (!aResult->rangeCount) {
       aResult->rangeArray = nullptr;
       return true;
     }
 
-    aResult->rangeArray = new nsTextRange[aResult->rangeCount];
+    aResult->rangeArray = new mozilla::TextRange[aResult->rangeCount];
     if (!aResult->rangeArray)
       return false;
 
     for (uint32_t index = 0; index < aResult->rangeCount; index++)
       if (!ReadParam(aMsg, aIter, &aResult->rangeArray[index])) {
         Free(*aResult);
         return false;
       }
--- a/widget/os2/nsWindow.cpp
+++ b/widget/os2/nsWindow.cpp
@@ -2562,17 +2562,17 @@ bool nsWindow::ImeConversionString(HIMI 
   // Is a conversion string changed ?
   if (mLastDispatchedCompositionString != compositionString) {
     nsCompositionEvent update(true, NS_COMPOSITION_UPDATE, this);
     InitEvent(update);
     update.data = compositionString;
     mLastDispatchedCompositionString = compositionString;
     DispatchWindowEvent(&update);
   }
-  nsAutoTArray<nsTextRange, 4> textRanges;
+  nsAutoTArray<TextRange, 4> textRanges;
   if (!compositionString.IsEmpty()) {
     bool oneClause = false;
 
     ulBufLen = 0;
     if (spfnImGetConversionString(himi, IMR_CONV_CONVERSIONCLAUSE, 0,
                                   &ulBufLen)) {
       oneClause = true;  // Assume that there is only one clause
     }
@@ -2644,17 +2644,17 @@ bool nsWindow::ImeConversionString(HIMI 
 
     if (oneClause) {
       ulClauseCount = 2;
       clauseOffsets[0] = 0;
       clauseOffsets[1] = compositionString.Length();
       clauseAttr[0] = NS_TEXTRANGE_SELECTEDRAWTEXT;
     }
 
-    nsTextRange newRange;
+    TextRange newRange;
 
     for (ULONG i = 0; i < ulClauseCount - 1; ++i) {
       newRange.mStartOffset = clauseOffsets[i];
       newRange.mEndOffset = clauseOffsets[i + 1];
       newRange.mRangeType = PlatformToNSAttr(clauseAttr[i]);
       textRanges.AppendElement(newRange);
     }
 
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -14,16 +14,17 @@
 #include "nsWindowDefs.h"
 #include "WinUtils.h"
 #include "KeyboardLayout.h"
 #include <algorithm>
 
 #include "mozilla/MiscEvents.h"
 #include "mozilla/TextEvents.h"
 
+using namespace mozilla;
 using namespace mozilla::widget;
 
 static nsIMM32Handler* gIMM32Handler = nullptr;
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gIMM32Log = nullptr;
 #endif
 
@@ -1581,43 +1582,43 @@ nsIMM32Handler::DispatchTextEvent(nsWind
     }
     SetIMERelatedWindowsPos(aWindow, aIMEContext);
   }
 
   nsTextEvent event(true, NS_TEXT_TEXT, aWindow);
 
   aWindow->InitEvent(event, &point);
 
-  nsAutoTArray<nsTextRange, 4> textRanges;
+  nsAutoTArray<TextRange, 4> textRanges;
 
   if (aCheckAttr) {
     SetTextRangeList(textRanges);
   }
 
   event.rangeCount = textRanges.Length();
   event.rangeArray = textRanges.Elements();
 
   event.theText = mCompositionString.get();
 
   aWindow->DispatchWindowEvent(&event);
 
   SetIMERelatedWindowsPos(aWindow, aIMEContext);
 }
 
 void
-nsIMM32Handler::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
+nsIMM32Handler::SetTextRangeList(nsTArray<TextRange> &aTextRangeList)
 {
   // Sogou (Simplified Chinese IME) returns contradictory values: The cursor
   // position is actual cursor position. However, other values (composition
   // string and attributes) are empty. So, if you want to remove following
   // assertion, be careful.
   NS_ASSERTION(ShouldDrawCompositionStringOurselves(),
     "SetTextRangeList is called when we don't need to fire text event");
 
-  nsTextRange range;
+  TextRange range;
   if (mClauseArray.Length() == 0) {
     // Some IMEs don't return clause array information, then, we assume that
     // all characters in the composition string are in one clause.
     range.mStartOffset = 0;
     range.mEndOffset = mCompositionString.Length();
     range.mRangeType = NS_TEXTRANGE_RAWINPUT;
     aTextRangeList.AppendElement(range);
 
--- a/widget/windows/nsIMM32Handler.h
+++ b/widget/windows/nsIMM32Handler.h
@@ -277,17 +277,17 @@ protected:
    *  aLength can be null (default), but aOffset must not be null.
    *
    *  The aOffset value is offset in the contents.  So, when you need offset
    *  in the composition string, you need to subtract mCompositionStart from it.
    */
   bool GetTargetClauseRange(uint32_t *aOffset, uint32_t *aLength = nullptr);
   void DispatchTextEvent(nsWindow* aWindow, const nsIMEContext &aIMEContext,
                          bool aCheckAttr = true);
-  void SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList);
+  void SetTextRangeList(nsTArray<mozilla::TextRange>& aTextRangeList);
 
   nsresult EnsureClauseArray(int32_t aCount);
   nsresult EnsureAttributeArray(int32_t aCount);
 
   /**
    * When WM_IME_CHAR is received and passed to DefWindowProc, we need to
    * record the messages.  In other words, we should record the messages
    * when we receive WM_IME_CHAR on windowless plug-in (if we have focus,
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -880,29 +880,29 @@ nsTextStore::FlushPendingActions()
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions() "
                 "flushing COMPOSITION_UPDATE={ mData=\"%s\", "
                 "mRanges.Length()=%d }",
                 this, NS_ConvertUTF16toUTF8(action.mData).get(),
                 action.mRanges.Length()));
 
         if (action.mRanges.IsEmpty()) {
-          nsTextRange wholeRange;
+          TextRange wholeRange;
           wholeRange.mStartOffset = 0;
           wholeRange.mEndOffset = action.mData.Length();
           wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
           action.mRanges.AppendElement(wholeRange);
         } else {
           // Adjust offsets in the ranges for XP linefeed character (only \n).
           // XXX Following code is the safest approach.  However, it wastes
           //     a little performance.  For ensuring the clauses do not
-          //     overlap each other, we should redesign nsTextRange later.
+          //     overlap each other, we should redesign TextRange later.
           for (uint32_t i = 0; i < action.mRanges.Length(); ++i) {
-            nsTextRange& range = action.mRanges[i];
-            nsTextRange nativeRange = range;
+            TextRange& range = action.mRanges[i];
+            TextRange nativeRange = range;
             if (nativeRange.mStartOffset > 0) {
               nsAutoString preText(
                 Substring(action.mData, 0, nativeRange.mStartOffset));
               preText.ReplaceSubstring(NS_LITERAL_STRING("\r\n"),
                                        NS_LITERAL_STRING("\n"));
               range.mStartOffset = preText.Length();
             }
             if (nativeRange.Length() == 0) {
@@ -940,17 +940,17 @@ nsTextStore::FlushPendingActions()
 
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions(), "
                 "dispatching text event...", this));
         nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget);
         mWidget->InitEvent(textEvent);
         textEvent.theText = mComposition.mLastData;
         if (action.mRanges.IsEmpty()) {
-          nsTextRange wholeRange;
+          TextRange wholeRange;
           wholeRange.mStartOffset = 0;
           wholeRange.mEndOffset = textEvent.theText.Length();
           wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
           action.mRanges.AppendElement(wholeRange);
         }
         textEvent.rangeArray = action.mRanges.Elements();
         textEvent.rangeCount = action.mRanges.Length();
         mWidget->DispatchWindowEvent(&textEvent);
@@ -1461,17 +1461,17 @@ nsTextStore::RecordCompositionUpdateActi
     return E_FAIL;
   }
 
   // Getting display attributes is *really* complicated!
   // We first get the context and the property objects to query for
   // attributes, but since a big range can have a variety of values for
   // the attribute, we have to find out all the ranges that have distinct
   // attribute values. Then we query for what the value represents through
-  // the display attribute manager and translate that to nsTextRange to be
+  // the display attribute manager and translate that to TextRange to be
   // sent in NS_TEXT_TEXT
 
   nsRefPtr<ITfProperty> attrPropetry;
   HRESULT hr = mContext->GetProperty(GUID_PROP_ATTRIBUTE,
                                      getter_AddRefs(attrPropetry));
   if (FAILED(hr) || !attrPropetry) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::RecordCompositionUpdateAction() FAILED "
@@ -1504,38 +1504,38 @@ nsTextStore::RecordCompositionUpdateActi
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::RecordCompositionUpdateAction() FAILED "
             "due to CurrentSelection() failure", this));
     return E_FAIL;
   }
 
   PendingAction* action = GetPendingCompositionUpdate();
   action->mData = mComposition.mString;
-  nsTArray<nsTextRange>& textRanges = action->mRanges;
+  nsTArray<TextRange>& textRanges = action->mRanges;
   // The ranges might already have been initialized already, however, if this
   // is called again, that means we need to overwrite the ranges with current
   // information.
   textRanges.Clear();
 
-  nsTextRange newRange;
+  TextRange newRange;
   // No matter if we have display attribute info or not,
   // we always pass in at least one range to NS_TEXT_TEXT
   newRange.mStartOffset = 0;
   newRange.mEndOffset = action->mData.Length();
   newRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
   textRanges.AppendElement(newRange);
 
   nsRefPtr<ITfRange> range;
   while (S_OK == enumRanges->Next(1, getter_AddRefs(range), NULL) && range) {
 
     LONG start = 0, length = 0;
     if (FAILED(GetRangeExtent(range, &start, &length)))
       continue;
 
-    nsTextRange newRange;
+    TextRange newRange;
     newRange.mStartOffset = uint32_t(start - mComposition.mStart);
     // The end of the last range in the array is
     // always kept at the end of composition
     newRange.mEndOffset = mComposition.mString.Length();
 
     TF_DISPLAYATTRIBUTE attr;
     hr = GetDisplayAttribute(attrPropetry, range, &attr);
     if (FAILED(hr)) {
@@ -1556,17 +1556,17 @@ nsTextStore::RecordCompositionUpdateActi
       }
       if (GetLineStyle(attr.lsStyle, newRange.mRangeStyle.mLineStyle)) {
         newRange.mRangeStyle.mDefinedStyles |=
                                TextRangeStyle::DEFINED_LINESTYLE;
         newRange.mRangeStyle.mIsBoldLine = attr.fBoldLine != 0;
       }
     }
 
-    nsTextRange& lastRange = textRanges[textRanges.Length() - 1];
+    TextRange& lastRange = textRanges[textRanges.Length() - 1];
     if (lastRange.mStartOffset == newRange.mStartOffset) {
       // Replace range if last range is the same as this one
       // So that ranges don't overlap and confuse the editor
       lastRange = newRange;
     } else {
       lastRange.mEndOffset = newRange.mStartOffset;
       textRanges.AppendElement(newRange);
     }
@@ -1576,32 +1576,32 @@ nsTextStore::RecordCompositionUpdateActi
   // It sets no change style to IME selection (the selection is always only
   // one).  So, the composition string looks like normal (or committed) string.
   // At this time, current selection range is same as the composition string
   // range.  Other applications set a wide caret which covers the composition
   // string,  however, Gecko doesn't support the wide caret drawing now (Gecko
   // doesn't support XOR drawing), unfortunately.  For now, we should change
   // the range style to undefined.
   if (!currentSel.IsCollapsed() && textRanges.Length() == 1) {
-    nsTextRange& range = textRanges[0];
+    TextRange& range = textRanges[0];
     LONG start = currentSel.MinOffset();
     LONG end = currentSel.MaxOffset();
     if ((LONG)range.mStartOffset == start - mComposition.mStart &&
         (LONG)range.mEndOffset == end - mComposition.mStart &&
         range.mRangeStyle.IsNoChangeStyle()) {
       range.mRangeStyle.Clear();
       // The looks of selected type is better than others.
       range.mRangeType = NS_TEXTRANGE_SELECTEDRAWTEXT;
     }
   }
 
   // The caret position has to be collapsed.
   LONG caretPosition = currentSel.MaxOffset();
   caretPosition -= mComposition.mStart;
-  nsTextRange caretRange;
+  TextRange caretRange;
   caretRange.mStartOffset = caretRange.mEndOffset = uint32_t(caretPosition);
   caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
   textRanges.AppendElement(caretRange);
 
   PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
          ("TSF: 0x%p   nsTextStore::RecordCompositionUpdateAction() "
           "succeeded", this));
 
--- a/widget/windows/nsTextStore.h
+++ b/widget/windows/nsTextStore.h
@@ -461,17 +461,17 @@ protected:
     };
     ActionType mType;
     // For compositionstart and selectionset
     LONG mSelectionStart;
     LONG mSelectionLength;
     // For compositionupdate and compositionend
     nsString mData;
     // For compositionupdate
-    nsTArray<nsTextRange> mRanges;
+    nsTArray<mozilla::TextRange> mRanges;
     // For selectionset
     bool mSelectionReversed;
   };
   // Items of mPendingActions are appended when TSF tells us to need to dispatch
   // DOM composition events.  However, we cannot dispatch while the document is
   // locked because it can cause modifying the locked document.  So, the pending
   // actions should be performed when document lock is unlocked.
   nsTArray<PendingAction> mPendingActions;