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 396403 e118bcc44c7e3847b91c0970a92a97a1e04aa48d
parent 396402 38c9c1ad194a58d08440919f0c4618993917315b
child 396404 c0eb4040fa9cfc25b7df54944176ff1fe9e66102
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 &&