Bug 755204 - Use nsINode::GetChildCount() in nsHTMLEditRules::MakeSureElemStartsOrEndsOnCR; r=ehsan
authorMs2ger <ms2ger@gmail.com>
Fri, 18 May 2012 10:29:39 +0200
changeset 94316 7a335f88e78314bd96bbfad3a34f612212b7a7b1
parent 94315 1dac5c37d56020773a6ecf7470d5cd7385ce1d81
child 94317 b0f2d35f10e94e0945b66009cc29082d9d4df579
push id22706
push userMs2ger@gmail.com
push dateFri, 18 May 2012 08:31:47 +0000
treeherdermozilla-central@4b74c82dd5ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs755204
milestone15.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 755204 - Use nsINode::GetChildCount() in nsHTMLEditRules::MakeSureElemStartsOrEndsOnCR; r=ehsan
editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -8716,29 +8716,23 @@ nsHTMLEditRules::MakeSureElemStartsOrEnd
     }
     else
     {
       foundCR = true;
     }
   }
   if (!foundCR)
   {
+    PRInt32 offset = 0;
+    if (!aStarts) {
+      nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
+      NS_ENSURE_STATE(node);
+      offset = node->GetChildCount();
+    }
     nsCOMPtr<nsIDOMNode> brNode;
-    PRInt32 offset = 0;
-    if (!aStarts)
-    {
-      nsCOMPtr<nsIDOMNodeList> childNodes;
-      res = aNode->GetChildNodes(getter_AddRefs(childNodes));
-      NS_ENSURE_SUCCESS(res, res);
-      NS_ENSURE_TRUE(childNodes, NS_ERROR_NULL_POINTER);
-      PRUint32 childCount;
-      res = childNodes->GetLength(&childCount);
-      NS_ENSURE_SUCCESS(res, res);
-      offset = childCount;
-    }
     res = mHTMLEditor->CreateBR(aNode, offset, address_of(brNode));
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 nsresult
 nsHTMLEditRules::MakeSureElemStartsOrEndsOnCR(nsIDOMNode *aNode)