Bug 1649121: part 56) Factor `DetermineFirstNode` out of `ContentIteratorBase::Initializer`. r=masayuki

Hides details.

Differential Revision: https://phabricator.services.mozilla.com/D84160
This commit is contained in:
Mirko Brodesser 2020-07-22 00:54:31 +00:00
Родитель 9f2b9f55fa
Коммит 864cb782b0
1 изменённых файлов: 19 добавлений и 16 удалений

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

@ -196,6 +196,7 @@ class MOZ_STACK_CLASS ContentIteratorBase::Initializer final {
nsresult Run();
private:
void DetermineFirstNode();
[[nodiscard]] nsresult DetermineLastNode();
bool IsCollapsedNonCharacterRange() const;
@ -249,8 +250,25 @@ nsresult ContentIteratorBase::Initializer::Run() {
return NS_OK;
}
// Find first node in range.
DetermineFirstNode();
const nsresult rv = DetermineLastNode();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
};
// If either first or last is null, they both have to be null!
if (!mIterator.mFirst || !mIterator.mLast) {
mIterator.mFirst = nullptr;
mIterator.mLast = nullptr;
}
mIterator.mCurNode = mIterator.mFirst;
mIterator.mIsDone = !mIterator.mCurNode;
return NS_OK;
}
void ContentIteratorBase::Initializer::DetermineFirstNode() {
nsIContent* cChild = nullptr;
// Try to get the child at our starting point. This might return null if
@ -319,21 +337,6 @@ nsresult ContentIteratorBase::Initializer::Run() {
}
}
}
const nsresult rv = DetermineLastNode();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
};
// If either first or last is null, they both have to be null!
if (!mIterator.mFirst || !mIterator.mLast) {
mIterator.mFirst = nullptr;
mIterator.mLast = nullptr;
}
mIterator.mCurNode = mIterator.mFirst;
mIterator.mIsDone = !mIterator.mCurNode;
return NS_OK;
}
nsresult ContentIteratorBase::Initializer::DetermineLastNode() {