Bug 755202 - Simplify GetChildNodesForOperation; r=ehsan

This commit is contained in:
Ms2ger 2012-05-18 10:29:39 +02:00
Родитель d767c897ff
Коммит 8c2895ff99
1 изменённых файлов: 10 добавлений и 18 удалений

Просмотреть файл

@ -5957,26 +5957,18 @@ nsresult
nsHTMLEditRules::GetChildNodesForOperation(nsIDOMNode *inNode, nsHTMLEditRules::GetChildNodesForOperation(nsIDOMNode *inNode,
nsCOMArray<nsIDOMNode>& outArrayOfNodes) nsCOMArray<nsIDOMNode>& outArrayOfNodes)
{ {
NS_ENSURE_TRUE(inNode, NS_ERROR_NULL_POINTER); nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNodeList> childNodes;
nsresult res = inNode->GetChildNodes(getter_AddRefs(childNodes)); for (nsIContent* child = node->GetFirstChild();
NS_ENSURE_SUCCESS(res, res); child;
NS_ENSURE_TRUE(childNodes, NS_ERROR_NULL_POINTER); child = child->GetNextSibling()) {
PRUint32 childCount; nsIDOMNode* childNode = child->AsDOMNode();
res = childNodes->GetLength(&childCount); if (!outArrayOfNodes.AppendObject(childNode)) {
NS_ENSURE_SUCCESS(res, res);
PRUint32 i;
nsCOMPtr<nsIDOMNode> 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))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
} }
return res; return NS_OK;
} }