diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp
index 8158bc57ffb..d96d5e87a17 100644
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -836,8 +836,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
else
{
nsTArray> arrayOfRanges;
- res = GetPromotedRanges(selection, arrayOfRanges, EditAction::align);
- NS_ENSURE_SUCCESS(res, res);
+ GetPromotedRanges(*selection, arrayOfRanges, EditAction::align);
// use these ranges to construct a list of nodes to act on.
nsTArray> arrayOfNodes;
@@ -3379,8 +3378,7 @@ nsHTMLEditRules::WillRemoveList(Selection* aSelection,
nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
nsTArray> arrayOfRanges;
- res = GetPromotedRanges(aSelection, arrayOfRanges, EditAction::makeList);
- NS_ENSURE_SUCCESS(res, res);
+ GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::makeList);
// use these ranges to contruct a list of nodes to act on.
nsCOMArray arrayOfNodes;
@@ -3869,8 +3867,7 @@ nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
// whose children are all in the range
nsTArray> arrayOfRanges;
- res = GetPromotedRanges(aSelection, arrayOfRanges, EditAction::indent);
- NS_ENSURE_SUCCESS(res, res);
+ GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::indent);
// use these ranges to contruct a list of nodes to act on.
nsTArray> array;
@@ -5736,43 +5733,32 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
}
-///////////////////////////////////////////////////////////////////////////
-// GetPromotedRanges: run all the selection range endpoint through
+///////////////////////////////////////////////////////////////////////////////
+// GetPromotedRanges: Run all the selection range endpoint through
// GetPromotedPoint()
-//
-nsresult
-nsHTMLEditRules::GetPromotedRanges(Selection* inSelection,
- nsTArray>& outArrayOfRanges,
+//
+void
+nsHTMLEditRules::GetPromotedRanges(Selection& aSelection,
+ nsTArray>& outArrayOfRanges,
EditAction inOperationType)
{
- NS_ENSURE_TRUE(inSelection, NS_ERROR_NULL_POINTER);
+ uint32_t rangeCount = aSelection.RangeCount();
- int32_t rangeCount;
- nsresult res = inSelection->GetRangeCount(&rangeCount);
- NS_ENSURE_SUCCESS(res, res);
-
- int32_t i;
- nsRefPtr selectionRange;
- nsRefPtr opRange;
+ for (uint32_t i = 0; i < rangeCount; i++) {
+ nsRefPtr selectionRange = aSelection.GetRangeAt(i);
+ MOZ_ASSERT(selectionRange);
- for (i = 0; i < rangeCount; i++)
- {
- selectionRange = inSelection->GetRangeAt(i);
- NS_ENSURE_STATE(selectionRange);
+ // Clone range so we don't muck with actual selection ranges
+ nsRefPtr opRange = selectionRange->CloneRange();
- // clone range so we don't muck with actual selection ranges
- opRange = selectionRange->CloneRange();
-
- // make a new adjusted range to represent the appropriate block content.
- // The basic idea is to push out the range endpoints
- // to truly enclose the blocks that we will affect.
- // This call alters opRange.
+ // Make a new adjusted range to represent the appropriate block content.
+ // The basic idea is to push out the range endpoints to truly enclose the
+ // blocks that we will affect. This call alters opRange.
PromoteRange(*opRange, inOperationType);
-
- // stuff new opRange into array
+
+ // Stuff new opRange into array
outArrayOfRanges.AppendElement(opRange);
}
- return res;
}
@@ -6412,8 +6398,7 @@ nsHTMLEditRules::GetNodesFromSelection(Selection* selection,
// promote selection ranges
nsTArray> arrayOfRanges;
- res = GetPromotedRanges(selection, arrayOfRanges, operation);
- NS_ENSURE_SUCCESS(res, res);
+ GetPromotedRanges(*selection, arrayOfRanges, operation);
// use these ranges to contruct a list of nodes to act on.
nsTArray> array;
@@ -9038,9 +9023,8 @@ nsHTMLEditRules::WillAbsolutePosition(Selection* aSelection,
// whose children are all in the range
nsTArray> arrayOfRanges;
- res = GetPromotedRanges(aSelection, arrayOfRanges,
- EditAction::setAbsolutePosition);
- NS_ENSURE_SUCCESS(res, res);
+ GetPromotedRanges(*aSelection, arrayOfRanges,
+ EditAction::setAbsolutePosition);
// use these ranges to contruct a list of nodes to act on.
nsTArray> array;
diff --git a/editor/libeditor/nsHTMLEditRules.h b/editor/libeditor/nsHTMLEditRules.h
index 64ee1a9fa98..547944e2c22 100644
--- a/editor/libeditor/nsHTMLEditRules.h
+++ b/editor/libeditor/nsHTMLEditRules.h
@@ -272,9 +272,9 @@ protected:
void GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
int32_t aOffset, EditAction actionID,
nsCOMPtr* outNode, int32_t* outOffset);
- nsresult GetPromotedRanges(mozilla::dom::Selection* aSelection,
- nsTArray>& outArrayOfRanges,
- EditAction inOperationType);
+ void GetPromotedRanges(mozilla::dom::Selection& aSelection,
+ nsTArray>& outArrayOfRanges,
+ EditAction inOperationType);
void PromoteRange(nsRange& aRange, EditAction inOperationType);
enum class TouchContent { no, yes };
nsresult GetNodesForOperation(nsTArray>& aArrayOfRanges,