return NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype, mBaseURI);
nsresult rv = NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype, mBaseURI); nsCOMPtr<nsIDocShell> docShell; nsContentUtils::GetDocShellFromCaller(getter_AddRefs(docShell)); if (docShell) { nsCOMPtr<nsIPresContext> presContext; docShell->GetPresContext(getter_AddRefs(presContext)); if (presContext) { nsCOMPtr<nsISupports> container; presContext->GetContainer(getter_AddRefs(container)); nsCOMPtr<nsIDocument> document = do_QueryInterface(*aReturn); if (document) { document->SetContainer(container); } } }  return rv;
nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,                                     const nsAString& aQualifiedName,                                     nsIDOMDocumentType* aDoctype,                                     nsIDOMDocument** aReturn){    NS_ENSURE_ARG_POINTER(aReturn);    *aReturn = nsnull;    if (aDoctype) {    nsCOMPtr<nsIDOMDocument> owner;    aDoctype->GetOwnerDocument(getter_AddRefs(owner));    if (owner) {      return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;    }  }  return NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype,                           mBaseURI);}