зеркало из https://github.com/mozilla/pjs.git
Bug 755202 - Simplify GetChildNodesForOperation; r=ehsan
This commit is contained in:
Родитель
d767c897ff
Коммит
8c2895ff99
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче