зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1745862 - part 3: Make `RangeBoundaryBase::DetermineOffsetFromReference` check `mRef->IsBeingRemoved` before computing its index r=mbrodesser
`nsINode::ComputeIndexOf` may be expensive especially when the node is not in the parent node. Therefore, `DetermineOffsetFromReference` should check whether `mRef` has already been removed from the child node chain of `mParent`. Then, it explains the reason why `ComputeIndexOf` may return `Nothing` clearer. Depends on D135190 Differential Revision: https://phabricator.services.mozilla.com/D135823
This commit is contained in:
Родитель
e4e35dbacd
Коммит
396dde1072
|
@ -206,15 +206,15 @@ class RangeBoundaryBase {
|
|||
MOZ_ASSERT(mRef->GetParentNode() == mParent);
|
||||
MOZ_ASSERT(mOffset.isNothing());
|
||||
|
||||
const Maybe<uint32_t> index = mParent->ComputeIndexOf(mRef);
|
||||
// If mRef is **being** removed from mParent, ComputeIndexOf returns
|
||||
// Nothing because mRef has already been removed from the child node chain
|
||||
// of mParent.
|
||||
if (index.isNothing()) {
|
||||
if (mRef->IsBeingRemoved()) {
|
||||
// ComputeIndexOf would return nothing because mRef has already been
|
||||
// removed from the child node chain of mParent.
|
||||
return;
|
||||
}
|
||||
|
||||
const Maybe<uint32_t> index = mParent->ComputeIndexOf(mRef);
|
||||
MOZ_ASSERT(*index != UINT32_MAX);
|
||||
mOffset.emplace(*index + 1u);
|
||||
mOffset.emplace(MOZ_LIKELY(index.isSome()) ? *index + 1u : 0u);
|
||||
}
|
||||
|
||||
void InvalidateOffset() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче