Bug 1954751: SelectionManager::SelectionRangeChanged: Fail gracefully if the range's closest common ancestor is null. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D242113
This commit is contained in:
James Teh 2025-03-24 22:30:25 +00:00
parent b999769951
commit 213a09599f

View file

@ -219,6 +219,11 @@ bool SelectionManager::SelectionRangeChanged(SelectionType aType,
dom::Document* doc = start->OwnerDoc();
MOZ_ASSERT(doc);
nsINode* node = aRange.GetClosestCommonInclusiveAncestor();
if (!node) {
// Bug 1954751: This can happen when a Selection is being garbage collected,
// but it's unclear exactly what other circumstances are involved.
return false;
}
HyperTextAccessible* acc = nsAccUtils::GetTextContainer(node);
if (!acc) {
return true;