Bug 920377 part.20 Get rid of nsTextRange r=roc

This commit is contained in:
Masayuki Nakano 2013-10-01 16:22:59 +09:00
parent 8ad824bc91
commit 9fc5453724
18 changed files with 43 additions and 44 deletions

View File

@ -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)),

View File

@ -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;

View File

@ -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;

View File

@ -32,8 +32,8 @@ public:
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();

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -191,7 +191,7 @@ protected:
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;

View File

@ -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<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);

View File

@ -2556,13 +2556,13 @@ IMEInputHandler::GetRangeCount(NSAttributedString *aAttrString)
}
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.
@ -2575,7 +2575,7 @@ IMEInputHandler::SetTextRangeList(nsTArray<nsTextRange>& 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<nsTextRange>& 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<nsTextRange, 4> textRanges;
nsAutoTArray<TextRange, 4> textRanges;
if (!aDoCommit) {
SetTextRangeList(textRanges, aAttrString, aSelectedRange);
}

View File

@ -1090,13 +1090,13 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
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;
@ -1127,7 +1127,7 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
}
void
nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
nsGtkIMModule::SetTextRangeList(nsTArray<TextRange> &aTextRangeList)
{
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
("GtkIMModule(%p): SetTextRangeList", this));
@ -1179,7 +1179,7 @@ nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &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<nsTextRange> &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()) {

View File

@ -259,7 +259,7 @@ protected:
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);

View File

@ -315,9 +315,9 @@ struct ParamTraits<mozilla::TextRangeStyle>
};
template<>
struct ParamTraits<nsTextRange>
struct ParamTraits<mozilla::TextRange>
{
typedef nsTextRange paramType;
typedef mozilla::TextRange paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
@ -366,7 +366,7 @@ struct ParamTraits<nsTextEvent>
return true;
}
aResult->rangeArray = new nsTextRange[aResult->rangeCount];
aResult->rangeArray = new mozilla::TextRange[aResult->rangeCount];
if (!aResult->rangeArray)
return false;

View File

@ -2567,7 +2567,7 @@ bool nsWindow::ImeConversionString(HIMI himi)
mLastDispatchedCompositionString = compositionString;
DispatchWindowEvent(&update);
}
nsAutoTArray<nsTextRange, 4> textRanges;
nsAutoTArray<TextRange, 4> 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];

View File

@ -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<nsTextRange, 4> textRanges;
nsAutoTArray<TextRange, 4> textRanges;
if (aCheckAttr) {
SetTextRangeList(textRanges);
@ -1603,7 +1604,7 @@ nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow,
}
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
@ -1612,7 +1613,7 @@ nsIMM32Handler::SetTextRangeList(nsTArray<nsTextRange> &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.

View File

@ -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<nsTextRange> &aTextRangeList);
void SetTextRangeList(nsTArray<mozilla::TextRange>& aTextRangeList);
nsresult EnsureClauseArray(int32_t aCount);
nsresult EnsureAttributeArray(int32_t aCount);

View File

@ -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<ITfProperty> attrPropetry;
@ -1509,13 +1509,13 @@ nsTextStore::RecordCompositionUpdateAction()
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;
@ -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);

View File

@ -466,7 +466,7 @@ protected:
// For compositionupdate and compositionend
nsString mData;
// For compositionupdate
nsTArray<nsTextRange> mRanges;
nsTArray<mozilla::TextRange> mRanges;
// For selectionset
bool mSelectionReversed;
};