Bug 1275914 part.1 TextComposition should store target clause offset from start of the composition instead of start of the editor r=smaug

It's enough to store target clause offset from start of the composition and better to modify mCompositionStartOffset because when even if mCompositionStartOffset is changed, we don't need to modify the target clause offset.

This patch renames mCompositionTargetOffset to mTargetClauseOffsetInComposition.

MozReview-Commit-ID: 1wt2OTUUjkY

--HG--
extra : rebase_source : 1bb87899c6f2e374252aaa00535915d42c6bb29d
This commit is contained in:
Masayuki Nakano 2016-06-02 14:26:47 +09:00
Родитель 66d817730e
Коммит 7716923106
2 изменённых файлов: 12 добавлений и 10 удалений

Просмотреть файл

@ -58,7 +58,7 @@ TextComposition::TextComposition(nsPresContext* aPresContext,
, mTabParent(aTabParent)
, mNativeContext(aCompositionEvent->mNativeIMEContext)
, mCompositionStartOffset(0)
, mCompositionTargetOffset(0)
, mTargetClauseOffsetInComposition(0)
, mIsSynthesizedForTests(aCompositionEvent->mFlags.mIsSynthesizedForTests)
, mIsComposing(false)
, mIsEditorHandlingEvent(false)
@ -452,10 +452,9 @@ TextComposition::OnCompositionEventHandled(
NS_WARNING("Cannot get start offset of IME composition");
mCompositionStartOffset = 0;
}
mCompositionTargetOffset = mCompositionStartOffset;
mTargetClauseOffsetInComposition = 0;
} else if (aCompositionEvent->CausesDOMTextEvent()) {
mCompositionTargetOffset =
mCompositionStartOffset + aCompositionEvent->TargetClauseOffset();
mTargetClauseOffsetInComposition = aCompositionEvent->TargetClauseOffset();
} else {
return;
}

Просмотреть файл

@ -111,9 +111,12 @@ public:
}
/**
* the offset of first selected clause or start of of compositon
* the offset of first selected clause or start of composition
*/
uint32_t OffsetOfTargetClause() const { return mCompositionTargetOffset; }
uint32_t NativeOffsetOfTargetClause() const
{
return mCompositionStartOffset + mTargetClauseOffsetInComposition;
}
/**
* Returns true if there is non-empty composition string and it's not fixed.
@ -216,9 +219,9 @@ private:
// Offset of the composition string from start of the editor
uint32_t mCompositionStartOffset;
// Offset of the selected clause of the composition string from start of the
// editor
uint32_t mCompositionTargetOffset;
// Offset of the selected clause of the composition string from
// mCompositionStartOffset
uint32_t mTargetClauseOffsetInComposition;
// See the comment for IsSynthesizedForTests().
bool mIsSynthesizedForTests;
@ -260,7 +263,7 @@ private:
: mPresContext(nullptr)
, mNativeContext(nullptr)
, mCompositionStartOffset(0)
, mCompositionTargetOffset(0)
, mTargetClauseOffsetInComposition(0)
, mIsSynthesizedForTests(false)
, mIsComposing(false)
, mIsEditorHandlingEvent(false)