Bug 1366176 - Part 1: Initialize aOutIndex to the last range in the Selection as a fallback in case we don't add a range later in AddItem. r=smaug, a=gchang
authorMats Palmgren <mats@mozilla.com>
Tue, 23 May 2017 19:09:26 +0200
changeset 585405 e118bcc44c7e3847b91c0970a92a97a1e04aa48d
parent 585404 38c9c1ad194a58d08440919f0c4618993917315b
child 585406 c0eb4040fa9cfc25b7df54944176ff1fe9e66102
push id61106
push userbmo:dkeeler@mozilla.com
push dateFri, 26 May 2017 21:26:31 +0000
reviewerssmaug, gchang
bugs1366176
milestone54.0
Bug 1366176 - Part 1: Initialize aOutIndex to the last range in the Selection as a fallback in case we don't add a range later in AddItem. r=smaug, a=gchang MozReview-Commit-ID: Dgl7MwXMjYs
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -3843,17 +3843,17 @@ Selection::AddItem(nsRange* aItem, int32
     return NS_ERROR_NULL_POINTER;
   if (!aItem->IsPositioned())
     return NS_ERROR_UNEXPECTED;
 
   NS_ASSERTION(aOutIndex, "aOutIndex can't be null");
 
   if (mUserInitiated) {
     AutoTArray<RefPtr<nsRange>, 4> rangesToAdd;
-    *aOutIndex = -1;
+    *aOutIndex = int32_t(mRanges.Length()) - 1;
 
     nsIDocument* doc = GetParentObject();
     bool selectEventsEnabled =
       nsFrameSelection::sSelectionEventsEnabled ||
       (doc && nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()));
 
     if (!aNoStartSelect &&
         mSelectionType == SelectionType::eNormal &&