Bug 920377 part.20 Get rid of nsTextRange r=roc
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
nsPrivateTextRange::nsPrivateTextRange(const nsTextRange &aTextRange)
|
nsPrivateTextRange::nsPrivateTextRange(const TextRange &aTextRange)
|
||||||
: mRangeStart(uint16_t(aTextRange.mStartOffset)),
|
: mRangeStart(uint16_t(aTextRange.mStartOffset)),
|
||||||
mRangeEnd(uint16_t(aTextRange.mEndOffset)),
|
mRangeEnd(uint16_t(aTextRange.mEndOffset)),
|
||||||
mRangeType(uint16_t(aTextRange.mRangeType)),
|
mRangeType(uint16_t(aTextRange.mRangeType)),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class nsPrivateTextRange MOZ_FINAL : public nsIPrivateTextRange
|
|||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
public:
|
public:
|
||||||
|
|
||||||
nsPrivateTextRange(const nsTextRange &aTextRange);
|
nsPrivateTextRange(const mozilla::TextRange &aTextRange);
|
||||||
virtual ~nsPrivateTextRange(void);
|
virtual ~nsPrivateTextRange(void);
|
||||||
|
|
||||||
NS_IMETHOD GetRangeStart(uint16_t* aRangeStart) MOZ_OVERRIDE;
|
NS_IMETHOD GetRangeStart(uint16_t* aRangeStart) MOZ_OVERRIDE;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ CompositionStringSynthesizer::AppendClause(uint32_t aLength,
|
|||||||
case ATTR_SELECTEDRAWTEXT:
|
case ATTR_SELECTEDRAWTEXT:
|
||||||
case ATTR_CONVERTEDTEXT:
|
case ATTR_CONVERTEDTEXT:
|
||||||
case ATTR_SELECTEDCONVERTEDTEXT: {
|
case ATTR_SELECTEDCONVERTEDTEXT: {
|
||||||
nsTextRange textRange;
|
TextRange textRange;
|
||||||
textRange.mStartOffset =
|
textRange.mStartOffset =
|
||||||
mClauses.IsEmpty() ? 0 : mClauses[mClauses.Length() - 1].mEndOffset;
|
mClauses.IsEmpty() ? 0 : mClauses[mClauses.Length() - 1].mEndOffset;
|
||||||
textRange.mEndOffset = textRange.mStartOffset + aLength;
|
textRange.mEndOffset = textRange.mStartOffset + aLength;
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
nsWeakPtr mWindow; // refers an instance of nsPIDOMWindow
|
nsWeakPtr mWindow; // refers an instance of nsPIDOMWindow
|
||||||
nsString mString;
|
nsString mString;
|
||||||
nsAutoTArray<nsTextRange, 10> mClauses;
|
nsAutoTArray<TextRange, 10> mClauses;
|
||||||
nsTextRange mCaret;
|
TextRange mCaret;
|
||||||
|
|
||||||
nsIWidget* GetWidget();
|
nsIWidget* GetWidget();
|
||||||
void ClearInternal();
|
void ClearInternal();
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ typedef mozilla::WidgetEvent nsEvent;
|
|||||||
typedef mozilla::WidgetGUIEvent nsGUIEvent;
|
typedef mozilla::WidgetGUIEvent nsGUIEvent;
|
||||||
typedef mozilla::WidgetInputEvent nsInputEvent;
|
typedef mozilla::WidgetInputEvent nsInputEvent;
|
||||||
typedef mozilla::InternalUIEvent nsUIEvent;
|
typedef mozilla::InternalUIEvent nsUIEvent;
|
||||||
typedef mozilla::TextRange nsTextRange;
|
|
||||||
typedef mozilla::WidgetTextEvent nsTextEvent;
|
typedef mozilla::WidgetTextEvent nsTextEvent;
|
||||||
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
|
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
|
||||||
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
|
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
|
||||||
|
|||||||
@@ -534,7 +534,6 @@ public:
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
// TODO: Remove following typedefs
|
// TODO: Remove following typedefs
|
||||||
typedef mozilla::TextRange nsTextRange;
|
|
||||||
typedef mozilla::WidgetTextEvent nsTextEvent;
|
typedef mozilla::WidgetTextEvent nsTextEvent;
|
||||||
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
|
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
|
||||||
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
|
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
|
||||||
|
|||||||
@@ -1980,7 +1980,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
break;
|
break;
|
||||||
case AndroidGeckoEvent::IME_ADD_COMPOSITION_RANGE:
|
case AndroidGeckoEvent::IME_ADD_COMPOSITION_RANGE:
|
||||||
{
|
{
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
range.mStartOffset = ae->Start();
|
range.mStartOffset = ae->Start();
|
||||||
range.mEndOffset = ae->End();
|
range.mEndOffset = ae->End();
|
||||||
range.mRangeType = ae->RangeType();
|
range.mRangeType = ae->RangeType();
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ protected:
|
|||||||
bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate;
|
bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate;
|
||||||
int32_t mIMEMaskEventsCount; // Mask events when > 0
|
int32_t mIMEMaskEventsCount; // Mask events when > 0
|
||||||
nsString mIMEComposingText;
|
nsString mIMEComposingText;
|
||||||
nsAutoTArray<nsTextRange, 4> mIMERanges;
|
nsAutoTArray<mozilla::TextRange, 4> mIMERanges;
|
||||||
bool mIMEUpdatingContext;
|
bool mIMEUpdatingContext;
|
||||||
nsAutoTArray<mozilla::AndroidGeckoEvent, 8> mIMEKeyEvents;
|
nsAutoTArray<mozilla::AndroidGeckoEvent, 8> mIMEKeyEvents;
|
||||||
|
|
||||||
|
|||||||
@@ -1065,13 +1065,13 @@ private:
|
|||||||
* be set to the NSUnderlineStyleAttributeName
|
* be set to the NSUnderlineStyleAttributeName
|
||||||
* ranges in aAttrString. Note that if you pass
|
* ranges in aAttrString. Note that if you pass
|
||||||
* in a large enough auto-range instance for most
|
* 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.
|
* it prevents memory fragmentation.
|
||||||
* @param aAttrString An NSAttributedString instance which indicates
|
* @param aAttrString An NSAttributedString instance which indicates
|
||||||
* current composition string.
|
* current composition string.
|
||||||
* @param aSelectedRange Current selected range (or caret position).
|
* @param aSelectedRange Current selected range (or caret position).
|
||||||
*/
|
*/
|
||||||
void SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
|
void SetTextRangeList(nsTArray<TextRange>& aTextRangeList,
|
||||||
NSAttributedString *aAttrString,
|
NSAttributedString *aAttrString,
|
||||||
NSRange& aSelectedRange);
|
NSRange& aSelectedRange);
|
||||||
|
|
||||||
|
|||||||
@@ -2556,13 +2556,13 @@ IMEInputHandler::GetRangeCount(NSAttributedString *aAttrString)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IMEInputHandler::SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
|
IMEInputHandler::SetTextRangeList(nsTArray<TextRange>& aTextRangeList,
|
||||||
NSAttributedString *aAttrString,
|
NSAttributedString *aAttrString,
|
||||||
NSRange& aSelectedRange)
|
NSRange& aSelectedRange)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
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
|
// Iterate through the attributed string and map the underline attribute to
|
||||||
// Gecko IME textrange attributes. We may need to change the code here if
|
// Gecko IME textrange attributes. We may need to change the code here if
|
||||||
// we change the implementation of validAttributesForMarkedText.
|
// we change the implementation of validAttributesForMarkedText.
|
||||||
@@ -2575,7 +2575,7 @@ IMEInputHandler::SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
|
|||||||
longestEffectiveRange:&effectiveRange
|
longestEffectiveRange:&effectiveRange
|
||||||
inRange:limitRange];
|
inRange:limitRange];
|
||||||
|
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
range.mStartOffset = effectiveRange.location;
|
range.mStartOffset = effectiveRange.location;
|
||||||
range.mEndOffset = NSMaxRange(effectiveRange);
|
range.mEndOffset = NSMaxRange(effectiveRange);
|
||||||
range.mRangeType =
|
range.mRangeType =
|
||||||
@@ -2594,7 +2594,7 @@ IMEInputHandler::SetTextRangeList(nsTArray<nsTextRange>& aTextRangeList,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get current caret position.
|
// Get current caret position.
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
range.mStartOffset = aSelectedRange.location + aSelectedRange.length;
|
range.mStartOffset = aSelectedRange.location + aSelectedRange.length;
|
||||||
range.mEndOffset = range.mStartOffset;
|
range.mEndOffset = range.mStartOffset;
|
||||||
range.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
range.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||||
@@ -2632,7 +2632,7 @@ IMEInputHandler::DispatchTextEvent(const nsString& aText,
|
|||||||
nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget);
|
nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget);
|
||||||
textEvent.time = PR_IntervalNow();
|
textEvent.time = PR_IntervalNow();
|
||||||
textEvent.theText = aText;
|
textEvent.theText = aText;
|
||||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
nsAutoTArray<TextRange, 4> textRanges;
|
||||||
if (!aDoCommit) {
|
if (!aDoCommit) {
|
||||||
SetTextRangeList(textRanges, aAttrString, aSelectedRange);
|
SetTextRangeList(textRanges, aAttrString, aSelectedRange);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1090,13 +1090,13 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
|
|||||||
|
|
||||||
uint32_t targetOffset = mCompositionStart;
|
uint32_t targetOffset = mCompositionStart;
|
||||||
|
|
||||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
nsAutoTArray<TextRange, 4> textRanges;
|
||||||
if (!aIsCommit) {
|
if (!aIsCommit) {
|
||||||
// NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
|
// NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
|
||||||
// has been updated already.
|
// has been updated already.
|
||||||
SetTextRangeList(textRanges);
|
SetTextRangeList(textRanges);
|
||||||
for (uint32_t i = 0; i < textRanges.Length(); i++) {
|
for (uint32_t i = 0; i < textRanges.Length(); i++) {
|
||||||
nsTextRange& range = textRanges[i];
|
TextRange& range = textRanges[i];
|
||||||
if (range.mRangeType == NS_TEXTRANGE_SELECTEDRAWTEXT ||
|
if (range.mRangeType == NS_TEXTRANGE_SELECTEDRAWTEXT ||
|
||||||
range.mRangeType == NS_TEXTRANGE_SELECTEDCONVERTEDTEXT) {
|
range.mRangeType == NS_TEXTRANGE_SELECTEDCONVERTEDTEXT) {
|
||||||
targetOffset += range.mStartOffset;
|
targetOffset += range.mStartOffset;
|
||||||
@@ -1127,7 +1127,7 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
|
nsGtkIMModule::SetTextRangeList(nsTArray<TextRange> &aTextRangeList)
|
||||||
{
|
{
|
||||||
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
||||||
("GtkIMModule(%p): SetTextRangeList", this));
|
("GtkIMModule(%p): SetTextRangeList", this));
|
||||||
@@ -1179,7 +1179,7 @@ nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
|
|||||||
gint start, end;
|
gint start, end;
|
||||||
pango_attr_iterator_range(iter, &start, &end);
|
pango_attr_iterator_range(iter, &start, &end);
|
||||||
|
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
// XIMReverse | XIMUnderline
|
// XIMReverse | XIMUnderline
|
||||||
if (attrUnderline && attrForeground) {
|
if (attrUnderline && attrForeground) {
|
||||||
range.mRangeType = NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
|
range.mRangeType = NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
|
||||||
@@ -1228,7 +1228,7 @@ nsGtkIMModule::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
|
|||||||
GetRangeTypeName(range.mRangeType)));
|
GetRangeTypeName(range.mRangeType)));
|
||||||
} while (pango_attr_iterator_next(iter));
|
} while (pango_attr_iterator_next(iter));
|
||||||
|
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
if (cursor_pos < 0) {
|
if (cursor_pos < 0) {
|
||||||
range.mStartOffset = 0;
|
range.mStartOffset = 0;
|
||||||
} else if (uint32_t(cursor_pos) > mDispatchedCompositionString.Length()) {
|
} else if (uint32_t(cursor_pos) > mDispatchedCompositionString.Length()) {
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ protected:
|
|||||||
void GetCompositionString(nsAString &aCompositionString);
|
void GetCompositionString(nsAString &aCompositionString);
|
||||||
|
|
||||||
// Generates our text range list from current composition string.
|
// 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.
|
// Sets the offset's cursor position to IME.
|
||||||
void SetCursorPosition(uint32_t aTargetOffset);
|
void SetCursorPosition(uint32_t aTargetOffset);
|
||||||
|
|||||||
@@ -315,9 +315,9 @@ struct ParamTraits<mozilla::TextRangeStyle>
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ParamTraits<nsTextRange>
|
struct ParamTraits<mozilla::TextRange>
|
||||||
{
|
{
|
||||||
typedef nsTextRange paramType;
|
typedef mozilla::TextRange paramType;
|
||||||
|
|
||||||
static void Write(Message* aMsg, const paramType& aParam)
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
{
|
{
|
||||||
@@ -366,7 +366,7 @@ struct ParamTraits<nsTextEvent>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult->rangeArray = new nsTextRange[aResult->rangeCount];
|
aResult->rangeArray = new mozilla::TextRange[aResult->rangeCount];
|
||||||
if (!aResult->rangeArray)
|
if (!aResult->rangeArray)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -2567,7 +2567,7 @@ bool nsWindow::ImeConversionString(HIMI himi)
|
|||||||
mLastDispatchedCompositionString = compositionString;
|
mLastDispatchedCompositionString = compositionString;
|
||||||
DispatchWindowEvent(&update);
|
DispatchWindowEvent(&update);
|
||||||
}
|
}
|
||||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
nsAutoTArray<TextRange, 4> textRanges;
|
||||||
if (!compositionString.IsEmpty()) {
|
if (!compositionString.IsEmpty()) {
|
||||||
bool oneClause = false;
|
bool oneClause = false;
|
||||||
|
|
||||||
@@ -2649,7 +2649,7 @@ bool nsWindow::ImeConversionString(HIMI himi)
|
|||||||
clauseAttr[0] = NS_TEXTRANGE_SELECTEDRAWTEXT;
|
clauseAttr[0] = NS_TEXTRANGE_SELECTEDRAWTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTextRange newRange;
|
TextRange newRange;
|
||||||
|
|
||||||
for (ULONG i = 0; i < ulClauseCount - 1; ++i) {
|
for (ULONG i = 0; i < ulClauseCount - 1; ++i) {
|
||||||
newRange.mStartOffset = clauseOffsets[i];
|
newRange.mStartOffset = clauseOffsets[i];
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "mozilla/MiscEvents.h"
|
#include "mozilla/MiscEvents.h"
|
||||||
#include "mozilla/TextEvents.h"
|
#include "mozilla/TextEvents.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
using namespace mozilla::widget;
|
using namespace mozilla::widget;
|
||||||
|
|
||||||
static nsIMM32Handler* gIMM32Handler = nullptr;
|
static nsIMM32Handler* gIMM32Handler = nullptr;
|
||||||
@@ -1586,7 +1587,7 @@ nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow,
|
|||||||
|
|
||||||
aWindow->InitEvent(event, &point);
|
aWindow->InitEvent(event, &point);
|
||||||
|
|
||||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
nsAutoTArray<TextRange, 4> textRanges;
|
||||||
|
|
||||||
if (aCheckAttr) {
|
if (aCheckAttr) {
|
||||||
SetTextRangeList(textRanges);
|
SetTextRangeList(textRanges);
|
||||||
@@ -1603,7 +1604,7 @@ nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsIMM32Handler::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
|
nsIMM32Handler::SetTextRangeList(nsTArray<TextRange> &aTextRangeList)
|
||||||
{
|
{
|
||||||
// Sogou (Simplified Chinese IME) returns contradictory values: The cursor
|
// Sogou (Simplified Chinese IME) returns contradictory values: The cursor
|
||||||
// position is actual cursor position. However, other values (composition
|
// position is actual cursor position. However, other values (composition
|
||||||
@@ -1612,7 +1613,7 @@ nsIMM32Handler::SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList)
|
|||||||
NS_ASSERTION(ShouldDrawCompositionStringOurselves(),
|
NS_ASSERTION(ShouldDrawCompositionStringOurselves(),
|
||||||
"SetTextRangeList is called when we don't need to fire text event");
|
"SetTextRangeList is called when we don't need to fire text event");
|
||||||
|
|
||||||
nsTextRange range;
|
TextRange range;
|
||||||
if (mClauseArray.Length() == 0) {
|
if (mClauseArray.Length() == 0) {
|
||||||
// Some IMEs don't return clause array information, then, we assume that
|
// Some IMEs don't return clause array information, then, we assume that
|
||||||
// all characters in the composition string are in one clause.
|
// all characters in the composition string are in one clause.
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ protected:
|
|||||||
bool GetTargetClauseRange(uint32_t *aOffset, uint32_t *aLength = nullptr);
|
bool GetTargetClauseRange(uint32_t *aOffset, uint32_t *aLength = nullptr);
|
||||||
void DispatchTextEvent(nsWindow* aWindow, const nsIMEContext &aIMEContext,
|
void DispatchTextEvent(nsWindow* aWindow, const nsIMEContext &aIMEContext,
|
||||||
bool aCheckAttr = true);
|
bool aCheckAttr = true);
|
||||||
void SetTextRangeList(nsTArray<nsTextRange> &aTextRangeList);
|
void SetTextRangeList(nsTArray<mozilla::TextRange>& aTextRangeList);
|
||||||
|
|
||||||
nsresult EnsureClauseArray(int32_t aCount);
|
nsresult EnsureClauseArray(int32_t aCount);
|
||||||
nsresult EnsureAttributeArray(int32_t aCount);
|
nsresult EnsureAttributeArray(int32_t aCount);
|
||||||
|
|||||||
@@ -885,7 +885,7 @@ nsTextStore::FlushPendingActions()
|
|||||||
action.mRanges.Length()));
|
action.mRanges.Length()));
|
||||||
|
|
||||||
if (action.mRanges.IsEmpty()) {
|
if (action.mRanges.IsEmpty()) {
|
||||||
nsTextRange wholeRange;
|
TextRange wholeRange;
|
||||||
wholeRange.mStartOffset = 0;
|
wholeRange.mStartOffset = 0;
|
||||||
wholeRange.mEndOffset = action.mData.Length();
|
wholeRange.mEndOffset = action.mData.Length();
|
||||||
wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
|
wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
|
||||||
@@ -894,10 +894,10 @@ nsTextStore::FlushPendingActions()
|
|||||||
// Adjust offsets in the ranges for XP linefeed character (only \n).
|
// Adjust offsets in the ranges for XP linefeed character (only \n).
|
||||||
// XXX Following code is the safest approach. However, it wastes
|
// XXX Following code is the safest approach. However, it wastes
|
||||||
// a little performance. For ensuring the clauses do not
|
// 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) {
|
for (uint32_t i = 0; i < action.mRanges.Length(); ++i) {
|
||||||
nsTextRange& range = action.mRanges[i];
|
TextRange& range = action.mRanges[i];
|
||||||
nsTextRange nativeRange = range;
|
TextRange nativeRange = range;
|
||||||
if (nativeRange.mStartOffset > 0) {
|
if (nativeRange.mStartOffset > 0) {
|
||||||
nsAutoString preText(
|
nsAutoString preText(
|
||||||
Substring(action.mData, 0, nativeRange.mStartOffset));
|
Substring(action.mData, 0, nativeRange.mStartOffset));
|
||||||
@@ -945,7 +945,7 @@ nsTextStore::FlushPendingActions()
|
|||||||
mWidget->InitEvent(textEvent);
|
mWidget->InitEvent(textEvent);
|
||||||
textEvent.theText = mComposition.mLastData;
|
textEvent.theText = mComposition.mLastData;
|
||||||
if (action.mRanges.IsEmpty()) {
|
if (action.mRanges.IsEmpty()) {
|
||||||
nsTextRange wholeRange;
|
TextRange wholeRange;
|
||||||
wholeRange.mStartOffset = 0;
|
wholeRange.mStartOffset = 0;
|
||||||
wholeRange.mEndOffset = textEvent.theText.Length();
|
wholeRange.mEndOffset = textEvent.theText.Length();
|
||||||
wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
|
wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
|
||||||
@@ -1466,7 +1466,7 @@ nsTextStore::RecordCompositionUpdateAction()
|
|||||||
// attributes, but since a big range can have a variety of values 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
|
// the attribute, we have to find out all the ranges that have distinct
|
||||||
// attribute values. Then we query for what the value represents through
|
// 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
|
// sent in NS_TEXT_TEXT
|
||||||
|
|
||||||
nsRefPtr<ITfProperty> attrPropetry;
|
nsRefPtr<ITfProperty> attrPropetry;
|
||||||
@@ -1509,13 +1509,13 @@ nsTextStore::RecordCompositionUpdateAction()
|
|||||||
|
|
||||||
PendingAction* action = GetPendingCompositionUpdate();
|
PendingAction* action = GetPendingCompositionUpdate();
|
||||||
action->mData = mComposition.mString;
|
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
|
// The ranges might already have been initialized already, however, if this
|
||||||
// is called again, that means we need to overwrite the ranges with current
|
// is called again, that means we need to overwrite the ranges with current
|
||||||
// information.
|
// information.
|
||||||
textRanges.Clear();
|
textRanges.Clear();
|
||||||
|
|
||||||
nsTextRange newRange;
|
TextRange newRange;
|
||||||
// No matter if we have display attribute info or not,
|
// No matter if we have display attribute info or not,
|
||||||
// we always pass in at least one range to NS_TEXT_TEXT
|
// we always pass in at least one range to NS_TEXT_TEXT
|
||||||
newRange.mStartOffset = 0;
|
newRange.mStartOffset = 0;
|
||||||
@@ -1530,7 +1530,7 @@ nsTextStore::RecordCompositionUpdateAction()
|
|||||||
if (FAILED(GetRangeExtent(range, &start, &length)))
|
if (FAILED(GetRangeExtent(range, &start, &length)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nsTextRange newRange;
|
TextRange newRange;
|
||||||
newRange.mStartOffset = uint32_t(start - mComposition.mStart);
|
newRange.mStartOffset = uint32_t(start - mComposition.mStart);
|
||||||
// The end of the last range in the array is
|
// The end of the last range in the array is
|
||||||
// always kept at the end of composition
|
// 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) {
|
if (lastRange.mStartOffset == newRange.mStartOffset) {
|
||||||
// Replace range if last range is the same as this one
|
// Replace range if last range is the same as this one
|
||||||
// So that ranges don't overlap and confuse the editor
|
// 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
|
// doesn't support XOR drawing), unfortunately. For now, we should change
|
||||||
// the range style to undefined.
|
// the range style to undefined.
|
||||||
if (!currentSel.IsCollapsed() && textRanges.Length() == 1) {
|
if (!currentSel.IsCollapsed() && textRanges.Length() == 1) {
|
||||||
nsTextRange& range = textRanges[0];
|
TextRange& range = textRanges[0];
|
||||||
LONG start = currentSel.MinOffset();
|
LONG start = currentSel.MinOffset();
|
||||||
LONG end = currentSel.MaxOffset();
|
LONG end = currentSel.MaxOffset();
|
||||||
if ((LONG)range.mStartOffset == start - mComposition.mStart &&
|
if ((LONG)range.mStartOffset == start - mComposition.mStart &&
|
||||||
@@ -1596,7 +1596,7 @@ nsTextStore::RecordCompositionUpdateAction()
|
|||||||
// The caret position has to be collapsed.
|
// The caret position has to be collapsed.
|
||||||
LONG caretPosition = currentSel.MaxOffset();
|
LONG caretPosition = currentSel.MaxOffset();
|
||||||
caretPosition -= mComposition.mStart;
|
caretPosition -= mComposition.mStart;
|
||||||
nsTextRange caretRange;
|
TextRange caretRange;
|
||||||
caretRange.mStartOffset = caretRange.mEndOffset = uint32_t(caretPosition);
|
caretRange.mStartOffset = caretRange.mEndOffset = uint32_t(caretPosition);
|
||||||
caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||||
textRanges.AppendElement(caretRange);
|
textRanges.AppendElement(caretRange);
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ protected:
|
|||||||
// For compositionupdate and compositionend
|
// For compositionupdate and compositionend
|
||||||
nsString mData;
|
nsString mData;
|
||||||
// For compositionupdate
|
// For compositionupdate
|
||||||
nsTArray<nsTextRange> mRanges;
|
nsTArray<mozilla::TextRange> mRanges;
|
||||||
// For selectionset
|
// For selectionset
|
||||||
bool mSelectionReversed;
|
bool mSelectionReversed;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user