nsCOMPtr<nsIScriptGlobalObject> globalObject; doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(globalObject);
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(doc->GetScriptGlobalObject());
PresShell::DoCopy(){  nsCOMPtr<nsIDocument> doc;  GetDocument(getter_AddRefs(doc));  if (!doc) return NS_ERROR_FAILURE;  nsCOMPtr<nsISelection> sel;  nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));  if (NS_FAILED(rv))     return rv;  if (!sel)     return NS_ERROR_FAILURE;  // Now we have the selection.  Make sure it's nonzero:  PRBool isCollapsed;  sel->GetIsCollapsed(&isCollapsed);  if (isCollapsed)    return NS_OK;  // call the copy code  rv = nsCopySupport::HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard);  if (NS_FAILED(rv))    return rv;  // Now that we have copied, update the Paste menu item  nsCOMPtr<nsIScriptGlobalObject> globalObject;  doc->GetScriptGlobalObject(getter_AddRefs(globalObject));    nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(globalObject);  if (domWindow)  {    domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"));  }    return NS_OK;}