Bug 1965607: Gracefully handle anonymous children in TextLeafPoint::ToDOMPoint. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D248723
This commit is contained in:
committed by
jteh@mozilla.com
parent
886999efe0
commit
37f125f5e9
@@ -586,9 +586,10 @@ std::pair<nsIContent*, uint32_t> TextLeafPoint::ToDOMPoint(
|
||||
MOZ_ASSERT(mOffset == 0 || mOffset == 1);
|
||||
nsIContent* parent = content->GetParent();
|
||||
MOZ_ASSERT(parent);
|
||||
auto childIndex = parent->ComputeIndexOf(content);
|
||||
MOZ_ASSERT(childIndex);
|
||||
return {parent, mOffset == 0 ? *childIndex : *childIndex + 1};
|
||||
// ComputeIndexOf() could return Nothing if this is an anonymous child.
|
||||
if (auto childIndex = parent->ComputeIndexOf(content)) {
|
||||
return {parent, mOffset == 0 ? *childIndex : *childIndex + 1};
|
||||
}
|
||||
}
|
||||
|
||||
// This could be an empty editable container, whitespace or an empty doc. In
|
||||
|
||||
Reference in New Issue
Block a user