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
authorMats Palmgren <mats@mozilla.com>
Tue, 23 May 2017 19:09:26 +0200
changeset 360256 9ddc1f41c0086e9bc0a30fc01fe54e1270a697c1
parent 360255 d2362e9dcb5bdb1aaec1ce71d415c34f24668166
child 360257 68cc11b0c3f5f8282d037c9460951e6633985422
push id31872
push userryanvm@gmail.com
push dateTue, 23 May 2017 22:11:58 +0000
treeherdermozilla-central@96e18bec9fc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1366176
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 MozReview-Commit-ID: Dgl7MwXMjYs
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -3859,17 +3859,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 &&