Bug 1399091 - Avoid adding the same range to multiple selections. r=mats

This commit is contained in:
Catalin Badea 2017-09-24 16:44:51 -04:00
Родитель 8036d190e1
Коммит 98224a4eda
1 изменённых файлов: 7 добавлений и 0 удалений

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

@ -1048,12 +1048,19 @@ nsRange::SetSelection(mozilla::dom::Selection* aSelection)
if (mSelection == aSelection) {
return;
}
// At least one of aSelection and mSelection must be null
// aSelection will be null when we are removing from a selection
// and a range can't be in more than one selection at a time,
// thus mSelection must be null too.
MOZ_ASSERT(!aSelection || !mSelection);
// Extra step in case our parent failed to ensure the above
// invariant.
if (aSelection && mSelection) {
mSelection->RemoveRange(this);
}
mSelection = aSelection;
if (mSelection) {
nsINode* commonAncestor = GetCommonAncestor();