if (!IsInDoc())
nsIDocument* doc = GetCurrentDoc(); if (!doc)
nsHTMLInputElement::SetFocus(nsPresContext* aPresContext){  if (!aPresContext)    return;  // We can't be focus'd if we don't have a document  if (!IsInDoc())    return;  // first see if we are disabled or not. If disabled then do nothing.  nsAutoString disabled;  if (NS_CONTENT_ATTR_HAS_VALUE == GetAttr(kNameSpaceID_None,                                           nsHTMLAtoms::disabled, 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(GetOwnerDoc()->GetScriptGlobalObject());  nsIFocusController *focusController = win->GetRootFocusController();  PRBool isActive = PR_FALSE;  focusController->GetActive(&isActive);  if (!isActive) {    focusController->SetFocusedWindow(win);    focusController->SetFocusedElement(this);    return;  }  aPresContext->EventStateManager()->SetContentState(this,                                                     NS_EVENT_STATE_FOCUS);  nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE);  if (formControlFrame) {    formControlFrame->SetFocus(PR_TRUE, PR_TRUE);    formControlFrame->ScrollIntoView(aPresContext);    // Could call SelectAll(aPresContext) here to automatically    // select text when we receive focus - only for text and password!  }}