From 12f19abd5fafc1399e3ca9847b8d7fb15d711bd9 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.4) Move `mSoftTextValid` to `SoftText`. r=smaug Depends on D112543 Differential Revision: https://phabricator.services.mozilla.com/D112544 --- extensions/spellcheck/src/mozInlineSpellWordUtil.cpp | 16 ++++++++-------- extensions/spellcheck/src/mozInlineSpellWordUtil.h | 9 ++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp index 8b5d7dd6dd98..7e7ae1f6a8ba 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ -263,7 +263,7 @@ nsresult mozInlineSpellWordUtil::SetPositionAndEnd(nsINode* aPositionNode, } nsresult mozInlineSpellWordUtil::EnsureWords() { - if (mSoftTextValid) return NS_OK; + if (mSoftText.mIsValid) return NS_OK; AdjustSoftBeginAndBuildSoftText(); mRealWords.Clear(); @@ -273,7 +273,7 @@ nsresult mozInlineSpellWordUtil::EnsureWords() { } mRealWords = realWords.unwrap(); - mSoftTextValid = true; + mSoftText.mIsValid = true; return NS_OK; } @@ -300,7 +300,7 @@ nsresult mozInlineSpellWordUtil::GetRangeForWord(nsINode* aWordNode, // Set our soft end and start NodeOffset pt(aWordNode, aWordOffset); - if (!mSoftTextValid || pt != mSoftText.mBegin || pt != mSoftText.mEnd) { + if (!mSoftText.mIsValid || pt != mSoftText.mBegin || pt != mSoftText.mEnd) { InvalidateWords(); mSoftText.mBegin = mSoftText.mEnd = pt; nsresult rv = EnsureWords(); @@ -937,7 +937,7 @@ auto mozInlineSpellWordUtil::BuildRealWords() const int32_t mozInlineSpellWordUtil::MapDOMPositionToSoftTextOffset( NodeOffset aNodeOffset) const { - if (!mSoftTextValid) { + if (!mSoftText.mIsValid) { NS_ERROR("Soft text must be valid if we're to map into it"); return -1; } @@ -998,9 +998,9 @@ bool FindLastNongreaterOffset(const nsTArray& aContainer, NodeOffset mozInlineSpellWordUtil::MapSoftTextOffsetToDOMPosition( int32_t aSoftTextOffset, DOMMapHint aHint) const { - NS_ASSERTION(mSoftTextValid, + NS_ASSERTION(mSoftText.mIsValid, "Soft text must be valid if we're to map out of it"); - if (!mSoftTextValid) return NodeOffset(nullptr, -1); + if (!mSoftText.mIsValid) return NodeOffset(nullptr, -1); // Find the last mapping, if any, such that mSoftTextOffset <= aSoftTextOffset size_t index; @@ -1057,9 +1057,9 @@ int32_t mozInlineSpellWordUtil::FindRealWordContaining( aSoftTextOffset, hint.get(), static_cast(aSearchForward))); } - NS_ASSERTION(mSoftTextValid, + NS_ASSERTION(mSoftText.mIsValid, "Soft text must be valid if we're to map out of it"); - if (!mSoftTextValid) return -1; + if (!mSoftText.mIsValid) return -1; // Find the last word, if any, such that mSoftTextOffset <= aSoftTextOffset size_t index; diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.h b/extensions/spellcheck/src/mozInlineSpellWordUtil.h index d3d37f4c1ee9..850ad7a6d659 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h @@ -126,6 +126,8 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { NodeOffset mBegin = NodeOffset(nullptr, 0); NodeOffset mEnd = NodeOffset(nullptr, 0); + + bool mIsValid = false; }; SoftText mSoftText; @@ -137,8 +139,7 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { : mDocument(&aDocument), mIsContentEditableOrDesignMode(aIsContentEditableOrDesignMode), mRootNode(&aRootNode), - mNextWordIndex(-1), - mSoftTextValid(false) {} + mNextWordIndex(-1) {} // cached stuff for the editor const RefPtr mDocument; @@ -184,9 +185,7 @@ class MOZ_STACK_CLASS mozInlineSpellWordUtil { RealWords mRealWords; int32_t mNextWordIndex; - bool mSoftTextValid; - - void InvalidateWords() { mSoftTextValid = false; } + void InvalidateWords() { mSoftText.mIsValid = false; } nsresult EnsureWords(); int32_t MapDOMPositionToSoftTextOffset(NodeOffset aNodeOffset) const; -- 2.11.4.GIT