nsIDOMWindowInternal * dw = domWin.get();
nsCOMPtr<nsIDOMWindowInternal> domWinInt(do_QueryInterface(domWin)); if (!domWinInt) return nsnull;  nsIDOMWindowInternal * dw = NS_STATIC_CAST(nsIDOMWindowInternal *, domWinInt.get());
DocumentViewerImpl::GetDOMWinForWebShell(nsIWebShell* aWebShell){  NS_ASSERTION(aWebShell, "Pointer is null!");  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebShell));  NS_ASSERTION(docShell, "The DocShell can't be NULL!");  if (!docShell) return nsnull;  nsCOMPtr<nsIPresShell>  presShell;  docShell->GetPresShell(getter_AddRefs(presShell));  NS_ASSERTION(presShell, "The PresShell can't be NULL!");  if (!presShell) return nsnull;  nsCOMPtr<nsIDocument> document;  presShell->GetDocument(getter_AddRefs(document));  if (!document) return nsnull;    nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;  document->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));  if (!scriptGlobalObject) return nsnull;  nsCOMPtr<nsIDOMWindowInternal> domWin = do_QueryInterface(scriptGlobalObject);   if (!domWin) return nsnull;  nsIDOMWindowInternal * dw = domWin.get();  NS_ADDREF(dw);  return dw;}