From 64c83abf72cb6e6864f246d74bacdd3df1abe5eb Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Tue, 20 Apr 2021 07:49:11 +0000 Subject: [PATCH] Bug 1700051: part 31.3) Move `mSoftEnd` to `SoftText`. r=smaug Depends on D112542 Differential Revision: https://phabricator.services.mozilla.com/D112543 --- .../spellcheck/src/mozInlineSpellWordUtil.cpp | 13 +++++++------ extensions/spellcheck/src/mozInlineSpellWordUtil.h | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp index c8e24287149e..8b5d7dd6dd98 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ -196,7 +196,7 @@ static nsINode* FindNextTextNode(nsINode* aNode, int32_t aOffset, // by the caller of this class by calling this function. If this function is // not called, the soft boundary is the same as the hard boundary. // -// When we reach the soft boundary (mSoftEnd), we keep +// When we reach the soft boundary (mSoftText.mEnd), we keep // going until we reach the end of a word. This allows the caller to set the // end of the range to anything, and we will always check whole multiples of // words. When we reach the hard boundary we stop no matter what. @@ -246,7 +246,7 @@ nsresult mozInlineSpellWordUtil::SetPositionAndEnd(nsINode* aPositionNode, aEndNode = FindNextTextNode(aEndNode, aEndOffset, mRootNode); aEndOffset = 0; } - mSoftEnd = NodeOffset(aEndNode, aEndOffset); + mSoftText.mEnd = NodeOffset(aEndNode, aEndOffset); nsresult rv = EnsureWords(); if (NS_FAILED(rv)) { @@ -300,9 +300,9 @@ nsresult mozInlineSpellWordUtil::GetRangeForWord(nsINode* aWordNode, // Set our soft end and start NodeOffset pt(aWordNode, aWordOffset); - if (!mSoftTextValid || pt != mSoftText.mBegin || pt != mSoftEnd) { + if (!mSoftTextValid || pt != mSoftText.mBegin || pt != mSoftText.mEnd) { InvalidateWords(); - mSoftText.mBegin = mSoftEnd = pt; + mSoftText.mBegin = mSoftText.mEnd = pt; nsresult rv = EnsureWords(); if (NS_FAILED(rv)) { return rv; @@ -837,7 +837,7 @@ void mozInlineSpellWordUtil::AdjustSoftBeginAndBuildSoftText() { // Leave this outside the loop so large heap string allocations can be reused // across iterations while (node) { - if (node == mSoftEnd.mNode) { + if (node == mSoftText.mEnd.mNode) { seenSoftEnd = true; } @@ -851,7 +851,8 @@ void mozInlineSpellWordUtil::AdjustSoftBeginAndBuildSoftText() { if (seenSoftEnd) { // check whether we can stop after this - for (int32_t i = node == mSoftEnd.mNode ? mSoftEnd.mOffset : 0; + for (int32_t i = node == mSoftText.mEnd.mNode ? mSoftText.mEnd.mOffset + : 0; i < int32_t(textFragment->GetLength()); ++i) { if (IsDOMWordSeparator(textFragment->CharAt(i))) { exit = true; diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.h b/extensions/spellcheck/src/mozInlineSpellWordUtil.h index 9abb6c1900c8..d3d37f4c1ee9 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h @@ -125,6 +125,7 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { nsString mValue; NodeOffset mBegin = NodeOffset(nullptr, 0); + NodeOffset mEnd = NodeOffset(nullptr, 0); }; SoftText mSoftText; @@ -136,7 +137,6 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { : mDocument(&aDocument), mIsContentEditableOrDesignMode(aIsContentEditableOrDesignMode), mRootNode(&aRootNode), - mSoftEnd(nullptr, 0), mNextWordIndex(-1), mSoftTextValid(false) {} @@ -146,7 +146,6 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { // range to check, see SetPosition and SetEnd const nsINode* mRootNode; - NodeOffset mSoftEnd; // A list of where we extracted text from, ordered by mSoftTextOffset. A given // DOM node appears at most once in this list.