mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 555642 part.2 IME handlers on Windows shouldn't append caret range if the caret is in the target clause which doesn't have specific style r=m_kato
This commit is contained in:
parent
3645c1dbaf
commit
4047998c2a
@ -1971,8 +1971,8 @@ IMMHandler::CreateTextRangeArray()
|
||||
return textRangeArray.forget();
|
||||
}
|
||||
|
||||
int32_t cursor = mCursorPosition;
|
||||
if (uint32_t(cursor) > mCompositionString.Length()) {
|
||||
uint32_t cursor = static_cast<uint32_t>(mCursorPosition);
|
||||
if (cursor > mCompositionString.Length()) {
|
||||
MOZ_LOG(gIMMLog, LogLevel::Info,
|
||||
("IMM: CreateTextRangeArray, mCursorPosition=%ld. "
|
||||
"This is larger than mCompositionString.Length()=%lu",
|
||||
@ -1980,6 +1980,18 @@ IMMHandler::CreateTextRangeArray()
|
||||
cursor = mCompositionString.Length();
|
||||
}
|
||||
|
||||
// If caret is in the target clause, the target clause will be painted as
|
||||
// normal selection range. Since caret shouldn't be in selection range on
|
||||
// Windows, we shouldn't append caret range in such case.
|
||||
const TextRange* targetClause = textRangeArray->GetTargetClause();
|
||||
if (targetClause &&
|
||||
cursor >= targetClause->mStartOffset &&
|
||||
cursor <= targetClause->mEndOffset) {
|
||||
MOZ_LOG(gIMMLog, LogLevel::Info,
|
||||
("IMM: CreateTextRangeArray, no caret due to it's in the target clause"));
|
||||
return textRangeArray.forget();
|
||||
}
|
||||
|
||||
range.mStartOffset = range.mEndOffset = cursor;
|
||||
range.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
textRangeArray->AppendElement(range);
|
||||
|
@ -2581,12 +2581,22 @@ TSFTextStore::RecordCompositionUpdateAction()
|
||||
}
|
||||
|
||||
// The caret position has to be collapsed.
|
||||
LONG caretPosition = currentSel.MaxOffset();
|
||||
caretPosition -= mComposition.mStart;
|
||||
TextRange caretRange;
|
||||
caretRange.mStartOffset = caretRange.mEndOffset = uint32_t(caretPosition);
|
||||
caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
action->mRanges->AppendElement(caretRange);
|
||||
uint32_t caretPosition =
|
||||
static_cast<uint32_t>(currentSel.MaxOffset() - mComposition.mStart);
|
||||
|
||||
// If caret is in the target clause and it doesn't have specific style,
|
||||
// the target clause will be painted as normal selection range. Since caret
|
||||
// shouldn't be in selection range on Windows, we shouldn't append caret
|
||||
// range in such case.
|
||||
const TextRange* targetClause = action->mRanges->GetTargetClause();
|
||||
if (!targetClause || targetClause->mRangeStyle.IsDefined() ||
|
||||
caretPosition < targetClause->mStartOffset ||
|
||||
caretPosition > targetClause->mEndOffset) {
|
||||
TextRange caretRange;
|
||||
caretRange.mStartOffset = caretRange.mEndOffset = caretPosition;
|
||||
caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
action->mRanges->AppendElement(caretRange);
|
||||
}
|
||||
|
||||
action->mIncomplete = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user