From 9ccb5fd5268195ba6a6283ae1fbe3cc9da5e919a Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 13 Jul 2021 09:06:04 +0000 Subject: [PATCH] Bug 1718924 - part 8: Add `OffsetEntry::OffsetInTextInBlockIsInRangeOrEndOffset()` r=m_kato Depends on D119154 Differential Revision: https://phabricator.services.mozilla.com/D119155 --- editor/spellchecker/TextServicesDocument.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/spellchecker/TextServicesDocument.cpp b/editor/spellchecker/TextServicesDocument.cpp index 1421088469c8..8d8197dce117 100644 --- a/editor/spellchecker/TextServicesDocument.cpp +++ b/editor/spellchecker/TextServicesDocument.cpp @@ -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 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;