Bug 1700051: part 31.3) Move `mSoftEnd` to `SoftText`. r=smaug

Depends on D112542

Differential Revision: https://phabricator.services.mozilla.com/D112543
This commit is contained in:
Mirko Brodesser 2021-04-20 07:49:11 +00:00
Родитель f9be3581cf
Коммит 64c83abf72
2 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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.