Bug 1718924 - part 8: Add OffsetEntry::OffsetInTextInBlockIsInRangeOrEndOffset() r=m_kato

Depends on D119154

Differential Revision: https://phabricator.services.mozilla.com/D119155
This commit is contained in:
Masayuki Nakano 2021-07-13 09:06:04 +00:00
parent 36c6e61f3c
commit 9ccb5fd526

View File

@ -59,6 +59,11 @@ class OffsetEntry final {
uint32_t EndOffsetInTextInBlock() const {
return mOffsetInTextInBlock + mLength;
}
bool OffsetInTextInBlockIsInRangeOrEndOffset(
uint32_t aOffsetInTextInBlock) const {
return aOffsetInTextInBlock >= mOffsetInTextInBlock &&
aOffsetInTextInBlock <= EndOffsetInTextInBlock();
}
OwningNonNull<Text> mTextNode;
uint32_t mOffsetInTextNode;
@ -1676,8 +1681,7 @@ nsresult TextServicesDocument::SetSelectionInternal(uint32_t aOffset,
endTextNode = entry->mTextNode;
endNodeOffset = entry->EndOffsetInTextNode();
}
} else if (endOffset >= entry->mOffsetInTextInBlock &&
endOffset <= entry->EndOffsetInTextInBlock()) {
} else if (entry->OffsetInTextInBlockIsInRangeOrEndOffset(endOffset)) {
endTextNode = entry->mTextNode;
endNodeOffset =
entry->mOffsetInTextNode + endOffset - entry->mOffsetInTextInBlock;