From 26c888208a11c3e9159fd5c7755abb8a34aeda39 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 12 Apr 2020 12:52:18 +0200 Subject: Issue #1512 - Improve handling of multiple selections. IsSelectionEditable should check whether the focus node and anchor node aren't null before trying to use them. This also changes the initialization of selections' aOutIndex to the last range in the selection as a fallback in case we don't add a range later (in AddItem) which could also end up with a null selection otherwise if the additional selection nodes are removed. --- layout/generic/nsSelection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layout') diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index f2959dc9d..5ccb2d8bf 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -3844,7 +3844,7 @@ Selection::AddItem(nsRange* aItem, int32_t* aOutIndex, bool aNoStartSelect) if (mUserInitiated) { AutoTArray, 4> rangesToAdd; - *aOutIndex = -1; + *aOutIndex = int32_t(mRanges.Length()) - 1; nsIDocument* doc = GetParentObject(); bool selectEventsEnabled = -- cgit v1.2.3