nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(doc->GetScriptGlobalObject());
nsCOMPtr<nsPIDOMWindow> win = doc->GetWindow();
nsHTMLInputElement::SetFocus(nsPresContext* aPresContext){  if (!aPresContext)    return;  // We can't be focus'd if we aren't in a document  nsIDocument* doc = GetCurrentDoc();  if (!doc)    return;  // first see if we are disabled or not. If disabled then do nothing.  if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled)) {    return;  }   // If the window is not active, do not allow the focus to bring the  // window to the front.  We update the focus controller, but do  // nothing else.  nsCOMPtr<nsPIDOMWindow> win =    do_QueryInterface(doc->GetScriptGlobalObject());  if (win) {    nsIFocusController *focusController = win->GetRootFocusController();    PRBool isActive = PR_FALSE;    focusController->GetActive(&isActive);    if (!isActive) {      focusController->SetFocusedWindow(win);      focusController->SetFocusedElement(this);      return;    }  }  nsIEventStateManager *esm = aPresContext->EventStateManager();  if (esm->SetContentState(this, NS_EVENT_STATE_FOCUS)) {    nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE);    if (formControlFrame) {      formControlFrame->SetFocus(PR_TRUE, PR_TRUE);      formControlFrame->ScrollIntoView(aPresContext);    }  }}