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.
This commit is contained in:
wolfbeast 2020-04-12 12:52:18 +02:00 committed by Roy Tam
commit 92f7e0e48e
2 changed files with 9 additions and 3 deletions

View file

@ -3844,7 +3844,7 @@ Selection::AddItem(nsRange* aItem, int32_t* aOutIndex, bool aNoStartSelect)
if (mUserInitiated) {
AutoTArray<RefPtr<nsRange>, 4> rangesToAdd;
*aOutIndex = -1;
*aOutIndex = int32_t(mRanges.Length()) - 1;
nsIDocument* doc = GetParentObject();
bool selectEventsEnabled =