diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 7e9f9cc38975..cd8e106b504b 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -5957,26 +5957,18 @@ nsresult nsHTMLEditRules::GetChildNodesForOperation(nsIDOMNode *inNode, nsCOMArray& outArrayOfNodes) { - NS_ENSURE_TRUE(inNode, NS_ERROR_NULL_POINTER); - - nsCOMPtr childNodes; - nsresult res = inNode->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); - - PRUint32 i; - nsCOMPtr node; - for (i = 0; i < childCount; i++) - { - res = childNodes->Item( i, getter_AddRefs(node)); - NS_ENSURE_TRUE(node, NS_ERROR_FAILURE); - if (!outArrayOfNodes.AppendObject(node)) + nsCOMPtr node = do_QueryInterface(inNode); + NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); + + for (nsIContent* child = node->GetFirstChild(); + child; + child = child->GetNextSibling()) { + nsIDOMNode* childNode = child->AsDOMNode(); + if (!outArrayOfNodes.AppendObject(childNode)) { return NS_ERROR_FAILURE; + } } - return res; + return NS_OK; }