nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(aWindow)); NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aWindow)); NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
nsSelectionCommandsBase::GetPresShellFromWindow(nsIDOMWindow *aWindow, nsIPresShell **aPresShell){  *aPresShell = nsnull;  nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(aWindow));  NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);  nsIDocShell *docShell = sgo->GetDocShell();  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);  return docShell->GetPresShell(aPresShell);}