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
--- 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 &&