res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; nsCOMPtr<nsIDOMNode>parent; res = aElement->GetParentNode(getter_AddRefs(parent)); if (NS_SUCCEEDED(res) && parent)
res = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res) && selection)
nsHTMLEditor::SelectElement(nsIDOMElement* aElement){  nsresult res = NS_ERROR_NULL_POINTER;  // Must be sure that element is contained in the document body  if (IsElementInBody(aElement))  {    nsCOMPtr<nsIDOMSelection> selection;    res = GetSelection(getter_AddRefs(selection));    if (NS_FAILED(res)) return res;    if (!selection) return NS_ERROR_NULL_POINTER;    nsCOMPtr<nsIDOMNode>parent;    res = aElement->GetParentNode(getter_AddRefs(parent));    if (NS_SUCCEEDED(res) && parent)    {      PRInt32 offsetInParent;      res = GetChildOffset(aElement, parent, offsetInParent);      if (NS_SUCCEEDED(res))      {        // Collapse selection to just before desired element,        res = selection->Collapse(parent, offsetInParent);        if (NS_SUCCEEDED(res)) {          //  then extend it to just after          res = selection->Extend(parent, offsetInParent+1);        }      }    }  }  return res;}