Bug 1269047 - Remove chained ENSURE calls from GetStartNodeAndOffset. r=ehsan
authorEric Rahm <erahm@mozilla.com>
Mon, 02 May 2016 21:25:56 -0700
changeset 295773 e2d39735ca01cdf4522fd184f0b7ac13ac2111b8
parent 295772 1dea6c46f236e3637c9368cadb6ddc6671c12f0f
child 295774 b844f8c5b19230e212ec32b39fd8385466e475b7
push id76079
push usererahm@mozilla.com
push dateTue, 03 May 2016 04:26:08 +0000
treeherdermozilla-inbound@e2d39735ca01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1269047
milestone49.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 1269047 - Remove chained ENSURE calls from GetStartNodeAndOffset. r=ehsan
editor/libeditor/nsEditor.cpp
editor/libeditor/nsHTMLEditRules.cpp
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -3661,17 +3661,19 @@ nsEditor::GetStartNodeAndOffset(Selectio
                                        nsIDOMNode **outStartNode,
                                        int32_t *outStartOffset)
 {
   NS_ENSURE_TRUE(outStartNode && outStartOffset && aSelection, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> startNode;
   nsresult rv = GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode),
                                       outStartOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
 
   if (startNode) {
     NS_ADDREF(*outStartNode = startNode->AsDOMNode());
   } else {
     *outStartNode = nullptr;
   }
   return NS_OK;
 }
@@ -3682,17 +3684,19 @@ nsEditor::GetStartNodeAndOffset(Selectio
 {
   MOZ_ASSERT(aSelection);
   MOZ_ASSERT(aStartNode);
   MOZ_ASSERT(aStartOffset);
 
   *aStartNode = nullptr;
   *aStartOffset = 0;
 
-  NS_ENSURE_TRUE(aSelection->RangeCount(), NS_ERROR_FAILURE);
+  if (!aSelection->RangeCount()) {
+    return NS_ERROR_FAILURE;
+  }
 
   const nsRange* range = aSelection->GetRangeAt(0);
   NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
 
   NS_ENSURE_TRUE(range->IsPositioned(), NS_ERROR_FAILURE);
 
   NS_IF_ADDREF(*aStartNode = range->GetStartParent());
   *aStartOffset = range->StartOffset();
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -7842,17 +7842,20 @@ nsHTMLEditRules::ConfirmSelectionInBody(
 
   // get the selection start location
   nsCOMPtr<nsIDOMNode> selNode, temp, parent;
   int32_t selOffset;
   NS_ENSURE_STATE(mHTMLEditor);
   nsresult res = mHTMLEditor->GetStartNodeAndOffset(selection,
                                                     getter_AddRefs(selNode),
                                                     &selOffset);
-  NS_ENSURE_SUCCESS(res, res);
+  if (NS_FAILED(res)) {
+    return res;
+  }
+
   temp = selNode;
 
   // check that selNode is inside body
   while (temp && !nsTextEditUtils::IsBody(temp))
   {
     res = temp->GetParentNode(getter_AddRefs(parent));
     temp = parent;
   }