From ea028aeada5c1bede3bd640c20f9f0f45b2d45df Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 1 Oct 2013 16:22:59 +0900 Subject: [PATCH] Bug 920377 part.20 Get rid of nsTextRange r=roc --- content/events/src/nsPrivateTextRange.cpp | 2 +- content/events/src/nsPrivateTextRange.h | 2 +- dom/base/CompositionStringSynthesizer.cpp | 2 +- dom/base/CompositionStringSynthesizer.h | 4 ++-- widget/EventForwards.h | 1 - widget/TextEvents.h | 1 - widget/android/nsWindow.cpp | 2 +- widget/android/nsWindow.h | 2 +- widget/cocoa/TextInputHandler.h | 4 ++-- widget/cocoa/TextInputHandler.mm | 10 +++++----- widget/gtk/nsGtkIMModule.cpp | 10 +++++----- widget/gtk/nsGtkIMModule.h | 2 +- widget/nsGUIEventIPC.h | 6 +++--- widget/os2/nsWindow.cpp | 4 ++-- widget/windows/nsIMM32Handler.cpp | 7 ++++--- widget/windows/nsIMM32Handler.h | 2 +- widget/windows/nsTextStore.cpp | 24 +++++++++++------------ widget/windows/nsTextStore.h | 2 +- 18 files changed, 43 insertions(+), 44 deletions(-) diff --git a/content/events/src/nsPrivateTextRange.cpp b/content/events/src/nsPrivateTextRange.cpp index c1dba310660f..76f89d56b5f6 100644 --- a/content/events/src/nsPrivateTextRange.cpp +++ b/content/events/src/nsPrivateTextRange.cpp @@ -8,7 +8,7 @@ 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)), diff --git a/content/events/src/nsPrivateTextRange.h b/content/events/src/nsPrivateTextRange.h index 5f5e289266ab..b38af5265345 100644 --- a/content/events/src/nsPrivateTextRange.h +++ b/content/events/src/nsPrivateTextRange.h @@ -17,7 +17,7 @@ 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; diff --git a/dom/base/CompositionStringSynthesizer.cpp b/dom/base/CompositionStringSynthesizer.cpp index ac421a81c451..1c7aa08545eb 100644 --- a/dom/base/CompositionStringSynthesizer.cpp +++ b/dom/base/CompositionStringSynthesizer.cpp @@ -82,7 +82,7 @@ CompositionStringSynthesizer::AppendClause(uint32_t aLength, 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; diff --git a/dom/base/CompositionStringSynthesizer.h b/dom/base/CompositionStringSynthesizer.h index 16e4450f2643..f4966d6e857f 100644 --- a/dom/base/CompositionStringSynthesizer.h +++ b/dom/base/CompositionStringSynthesizer.h @@ -32,8 +32,8 @@ public: private: nsWeakPtr mWindow; // refers an instance of nsPIDOMWindow nsString mString; - nsAutoTArray mClauses; - nsTextRange mCaret; + nsAutoTArray mClauses; + TextRange mCaret; nsIWidget* GetWidget(); void ClearInternal(); diff --git a/widget/EventForwards.h b/widget/EventForwards.h index 169322030a11..d84f745c9449 100644 --- a/widget/EventForwards.h +++ b/widget/EventForwards.h @@ -107,7 +107,6 @@ 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; diff --git a/widget/TextEvents.h b/widget/TextEvents.h index 575e81f27c49..3a7f1744549c 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -534,7 +534,6 @@ public: } // namespace mozilla // TODO: Remove following typedefs -typedef mozilla::TextRange nsTextRange; typedef mozilla::WidgetTextEvent nsTextEvent; typedef mozilla::WidgetCompositionEvent nsCompositionEvent; typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 4dbc1098236e..2c3d7689fce9 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1980,7 +1980,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae) break; case AndroidGeckoEvent::IME_ADD_COMPOSITION_RANGE: { - nsTextRange range; + TextRange range; range.mStartOffset = ae->Start(); range.mEndOffset = ae->End(); range.mRangeType = ae->RangeType(); diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index d0ae3c52e670..18857509ca62 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -191,7 +191,7 @@ protected: bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate; int32_t mIMEMaskEventsCount; // Mask events when > 0 nsString mIMEComposingText; - nsAutoTArray mIMERanges; + nsAutoTArray mIMERanges; bool mIMEUpdatingContext; nsAutoTArray mIMEKeyEvents; diff --git a/widget/cocoa/TextInputHandler.h b/widget/cocoa/TextInputHandler.h index 86e4905de5f7..681bb7275a0c 100644 --- a/widget/cocoa/TextInputHandler.h +++ b/widget/cocoa/TextInputHandler.h @@ -1065,13 +1065,13 @@ private: * 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), + * cases (e.g., nsAutoTArray), * 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& aTextRangeList, + void SetTextRangeList(nsTArray& aTextRangeList, NSAttributedString *aAttrString, NSRange& aSelectedRange); diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm index 3edfcddb94cc..8946a0083759 100644 --- a/widget/cocoa/TextInputHandler.mm +++ b/widget/cocoa/TextInputHandler.mm @@ -2556,13 +2556,13 @@ IMEInputHandler::GetRangeCount(NSAttributedString *aAttrString) } void -IMEInputHandler::SetTextRangeList(nsTArray& aTextRangeList, +IMEInputHandler::SetTextRangeList(nsTArray& 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. @@ -2575,7 +2575,7 @@ IMEInputHandler::SetTextRangeList(nsTArray& aTextRangeList, longestEffectiveRange:&effectiveRange inRange:limitRange]; - nsTextRange range; + TextRange range; range.mStartOffset = effectiveRange.location; range.mEndOffset = NSMaxRange(effectiveRange); range.mRangeType = @@ -2594,7 +2594,7 @@ IMEInputHandler::SetTextRangeList(nsTArray& aTextRangeList, } // Get current caret position. - nsTextRange range; + TextRange range; range.mStartOffset = aSelectedRange.location + aSelectedRange.length; range.mEndOffset = range.mStartOffset; range.mRangeType = NS_TEXTRANGE_CARETPOSITION; @@ -2632,7 +2632,7 @@ IMEInputHandler::DispatchTextEvent(const nsString& aText, nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget); textEvent.time = PR_IntervalNow(); textEvent.theText = aText; - nsAutoTArray textRanges; + nsAutoTArray textRanges; if (!aDoCommit) { SetTextRangeList(textRanges, aAttrString, aSelectedRange); } diff --git a/widget/gtk/nsGtkIMModule.cpp b/widget/gtk/nsGtkIMModule.cpp index 35998e802dc1..fb978be594b7 100644 --- a/widget/gtk/nsGtkIMModule.cpp +++ b/widget/gtk/nsGtkIMModule.cpp @@ -1090,13 +1090,13 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString, uint32_t targetOffset = mCompositionStart; - nsAutoTArray textRanges; + nsAutoTArray 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; @@ -1127,7 +1127,7 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString, } void -nsGtkIMModule::SetTextRangeList(nsTArray &aTextRangeList) +nsGtkIMModule::SetTextRangeList(nsTArray &aTextRangeList) { PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, ("GtkIMModule(%p): SetTextRangeList", this)); @@ -1179,7 +1179,7 @@ nsGtkIMModule::SetTextRangeList(nsTArray &aTextRangeList) gint start, end; pango_attr_iterator_range(iter, &start, &end); - nsTextRange range; + TextRange range; // XIMReverse | XIMUnderline if (attrUnderline && attrForeground) { range.mRangeType = NS_TEXTRANGE_SELECTEDCONVERTEDTEXT; @@ -1228,7 +1228,7 @@ nsGtkIMModule::SetTextRangeList(nsTArray &aTextRangeList) 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()) { diff --git a/widget/gtk/nsGtkIMModule.h b/widget/gtk/nsGtkIMModule.h index 5eb0f872d9ce..46b98430a932 100644 --- a/widget/gtk/nsGtkIMModule.h +++ b/widget/gtk/nsGtkIMModule.h @@ -259,7 +259,7 @@ protected: void GetCompositionString(nsAString &aCompositionString); // Generates our text range list from current composition string. - void SetTextRangeList(nsTArray &aTextRangeList); + void SetTextRangeList(nsTArray& aTextRangeList); // Sets the offset's cursor position to IME. void SetCursorPosition(uint32_t aTargetOffset); diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 30c0b7094d36..b085853f894f 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -315,9 +315,9 @@ struct ParamTraits }; template<> -struct ParamTraits +struct ParamTraits { - typedef nsTextRange paramType; + typedef mozilla::TextRange paramType; static void Write(Message* aMsg, const paramType& aParam) { @@ -366,7 +366,7 @@ struct ParamTraits return true; } - aResult->rangeArray = new nsTextRange[aResult->rangeCount]; + aResult->rangeArray = new mozilla::TextRange[aResult->rangeCount]; if (!aResult->rangeArray) return false; diff --git a/widget/os2/nsWindow.cpp b/widget/os2/nsWindow.cpp index 68f24e957dce..2b1fa7b75b38 100644 --- a/widget/os2/nsWindow.cpp +++ b/widget/os2/nsWindow.cpp @@ -2567,7 +2567,7 @@ bool nsWindow::ImeConversionString(HIMI himi) mLastDispatchedCompositionString = compositionString; DispatchWindowEvent(&update); } - nsAutoTArray textRanges; + nsAutoTArray textRanges; if (!compositionString.IsEmpty()) { bool oneClause = false; @@ -2649,7 +2649,7 @@ bool nsWindow::ImeConversionString(HIMI himi) clauseAttr[0] = NS_TEXTRANGE_SELECTEDRAWTEXT; } - nsTextRange newRange; + TextRange newRange; for (ULONG i = 0; i < ulClauseCount - 1; ++i) { newRange.mStartOffset = clauseOffsets[i]; diff --git a/widget/windows/nsIMM32Handler.cpp b/widget/windows/nsIMM32Handler.cpp index b9d81fdacf42..c3571cf46ae7 100644 --- a/widget/windows/nsIMM32Handler.cpp +++ b/widget/windows/nsIMM32Handler.cpp @@ -19,6 +19,7 @@ #include "mozilla/MiscEvents.h" #include "mozilla/TextEvents.h" +using namespace mozilla; using namespace mozilla::widget; static nsIMM32Handler* gIMM32Handler = nullptr; @@ -1586,7 +1587,7 @@ nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow, aWindow->InitEvent(event, &point); - nsAutoTArray textRanges; + nsAutoTArray textRanges; if (aCheckAttr) { SetTextRangeList(textRanges); @@ -1603,7 +1604,7 @@ nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow, } void -nsIMM32Handler::SetTextRangeList(nsTArray &aTextRangeList) +nsIMM32Handler::SetTextRangeList(nsTArray &aTextRangeList) { // Sogou (Simplified Chinese IME) returns contradictory values: The cursor // position is actual cursor position. However, other values (composition @@ -1612,7 +1613,7 @@ nsIMM32Handler::SetTextRangeList(nsTArray &aTextRangeList) 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. diff --git a/widget/windows/nsIMM32Handler.h b/widget/windows/nsIMM32Handler.h index 5ed440021335..2df08e235a4e 100644 --- a/widget/windows/nsIMM32Handler.h +++ b/widget/windows/nsIMM32Handler.h @@ -282,7 +282,7 @@ protected: bool GetTargetClauseRange(uint32_t *aOffset, uint32_t *aLength = nullptr); void DispatchTextEvent(nsWindow* aWindow, const nsIMEContext &aIMEContext, bool aCheckAttr = true); - void SetTextRangeList(nsTArray &aTextRangeList); + void SetTextRangeList(nsTArray& aTextRangeList); nsresult EnsureClauseArray(int32_t aCount); nsresult EnsureAttributeArray(int32_t aCount); diff --git a/widget/windows/nsTextStore.cpp b/widget/windows/nsTextStore.cpp index 7d479d168c29..359166f84ec3 100644 --- a/widget/windows/nsTextStore.cpp +++ b/widget/windows/nsTextStore.cpp @@ -885,7 +885,7 @@ nsTextStore::FlushPendingActions() action.mRanges.Length())); if (action.mRanges.IsEmpty()) { - nsTextRange wholeRange; + TextRange wholeRange; wholeRange.mStartOffset = 0; wholeRange.mEndOffset = action.mData.Length(); wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT; @@ -894,10 +894,10 @@ nsTextStore::FlushPendingActions() // 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)); @@ -945,7 +945,7 @@ nsTextStore::FlushPendingActions() 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; @@ -1466,7 +1466,7 @@ nsTextStore::RecordCompositionUpdateAction() // 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 attrPropetry; @@ -1509,13 +1509,13 @@ nsTextStore::RecordCompositionUpdateAction() PendingAction* action = GetPendingCompositionUpdate(); action->mData = mComposition.mString; - nsTArray& textRanges = action->mRanges; + nsTArray& 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; @@ -1530,7 +1530,7 @@ nsTextStore::RecordCompositionUpdateAction() 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 @@ -1561,7 +1561,7 @@ nsTextStore::RecordCompositionUpdateAction() } } - 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 @@ -1581,7 +1581,7 @@ nsTextStore::RecordCompositionUpdateAction() // 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 && @@ -1596,7 +1596,7 @@ nsTextStore::RecordCompositionUpdateAction() // 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); diff --git a/widget/windows/nsTextStore.h b/widget/windows/nsTextStore.h index eeabfd040110..22444ea96702 100644 --- a/widget/windows/nsTextStore.h +++ b/widget/windows/nsTextStore.h @@ -466,7 +466,7 @@ protected: // For compositionupdate and compositionend nsString mData; // For compositionupdate - nsTArray mRanges; + nsTArray mRanges; // For selectionset bool mSelectionReversed; };