Bug 1385389 - Do not delete the common ancestor ranges hashtable in nsRange::UnregisterCommonAncestor() because chances are we need to recreate it shortly after; r=smaug

This commit is contained in:
Ehsan Akhgari 2017-07-28 14:31:47 -04:00
Родитель 74d36db919
Коммит 4396fda529
1 изменённых файлов: 13 добавлений и 2 удалений

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

@ -430,11 +430,22 @@ nsRange::UnregisterCommonAncestor(nsINode* aNode)
MOZ_ASSERT(ranges); MOZ_ASSERT(ranges);
NS_ASSERTION(ranges->GetEntry(this), "unknown range"); NS_ASSERTION(ranges->GetEntry(this), "unknown range");
bool isNativeAnon = aNode->IsInNativeAnonymousSubtree();
bool removed = false;
if (ranges->Count() == 1) { if (ranges->Count() == 1) {
aNode->ClearCommonAncestorForRangeInSelection(); aNode->ClearCommonAncestorForRangeInSelection();
aNode->GetCommonAncestorRangesPtr().reset(); if (!isNativeAnon) {
// For nodes which are in native anonymous subtrees, we optimize away the
// cost of deallocating the hashtable here because we may need to create
// it again shortly afterward. We don't do this for all nodes in order
// to avoid the additional memory usage unconditionally.
aNode->GetCommonAncestorRangesPtr().reset();
removed = true;
}
UnmarkDescendants(aNode); UnmarkDescendants(aNode);
} else { }
if (!removed) {
ranges->RemoveEntry(this); ranges->RemoveEntry(this);
} }
} }