nsIHTMLDocument* htmlDoc; result = document->QueryInterface(kIHTMLDocumentIID, (void**)&htmlDoc); if (NS_OK == result) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(document)); if (htmlDoc) {
nsHTMLTitleElement::SetText(const nsString& aTitle){  nsresult result = NS_OK;  nsIDOMNode* child;  nsIDocument* document;  result = GetDocument(document);  if (NS_OK == result) {    nsIHTMLDocument* htmlDoc;    result = document->QueryInterface(kIHTMLDocumentIID, (void**)&htmlDoc);    if (NS_OK == result) {      htmlDoc->SetTitle(aTitle);      NS_RELEASE(htmlDoc);    }       NS_RELEASE(document);  }  result = GetFirstChild(&child);  if ((NS_OK == result) && (nsnull != child)) {    nsIDOMText* text;        result = child->QueryInterface(kIDOMTextIID, (void**)&text);    if (NS_OK == result) {      text->SetData(aTitle);      NS_RELEASE(text);    }    NS_RELEASE(child);  }  return result;}