nsCOMPtr<nsIDOMNodeList> childNodes; res = parentElement->GetChildNodes(getter_AddRefs(childNodes)); if (NS_FAILED(res)) return res; if (!childNodes) return NS_ERROR_NULL_POINTER;  nsCOMPtr<nsIDOMNode>grandParent; parentElement->GetParentNode(getter_AddRefs(grandParent)); PRInt32 offsetInParent; res = GetChildOffset(parentElement, grandParent, offsetInParent); if (NS_FAILED(res)) return res;  PRUint32 childCount; childNodes->GetLength(&childCount); PRInt32 i=childCount-1; for ( ; ((NS_SUCCEEDED(res)) && (0<=i)); i--)
parentElement = do_QueryInterface(parentNode); nsAutoString parentTag; parentElement->GetTagName(parentTag); PRBool isRoot; IsRootTag(parentTag, isRoot); if (aParentTag.EqualsIgnoreCase(parentTag))
nsHTMLEditor::RemoveParentFromBlockContent(const nsString &aParentTag, nsIDOMRange *aRange){  if (!aRange) { return NS_ERROR_NULL_POINTER; }  nsresult res;  nsCOMPtr<nsIDOMNode>startParent;  res = aRange->GetStartParent(getter_AddRefs(startParent));  if (NS_FAILED(res)) return res;  if (!startParent) return NS_ERROR_NULL_POINTER;  nsCOMPtr<nsIDOMNode>parentNode;  nsCOMPtr<nsIDOMElement>parentElement;  res = startParent->GetParentNode(getter_AddRefs(parentNode));  if (NS_FAILED(res)) return res;  while (parentNode)  {    parentElement = do_QueryInterface(parentNode);    nsAutoString parentTag;    parentElement->GetTagName(parentTag);    PRBool isRoot;    IsRootTag(parentTag, isRoot);    if (aParentTag.EqualsIgnoreCase(parentTag))    {      // go through list backwards so deletes don't interfere with the iteration      nsCOMPtr<nsIDOMNodeList> childNodes;      res = parentElement->GetChildNodes(getter_AddRefs(childNodes));      if (NS_FAILED(res)) return res;      if (!childNodes) return NS_ERROR_NULL_POINTER;      nsCOMPtr<nsIDOMNode>grandParent;      parentElement->GetParentNode(getter_AddRefs(grandParent));      PRInt32 offsetInParent;      res = GetChildOffset(parentElement, grandParent, offsetInParent);      if (NS_FAILED(res)) return res;      PRUint32 childCount;      childNodes->GetLength(&childCount);      PRInt32 i=childCount-1;      for ( ; ((NS_SUCCEEDED(res)) && (0<=i)); i--)      {        nsCOMPtr<nsIDOMNode> childNode;        res = childNodes->Item(i, getter_AddRefs(childNode));        if (NS_FAILED(res)) return res;        if (!childNode) return NS_ERROR_NULL_POINTER;        res = DeleteNode(childNode);        if (NS_FAILED(res)) return res;        res = InsertNode(childNode, grandParent, offsetInParent);        if (NS_FAILED(res)) return res;      }      res = DeleteNode(parentElement);      if (NS_FAILED(res)) { return res; }      break;    }    else if (PR_TRUE==isRoot) {  // hit a local root node, terminate loop      break;    }    res = parentElement->GetParentNode(getter_AddRefs(parentNode));    if (NS_FAILED(res)) return res;  }  return res;}