nsCOMPtr<nsIPresContext> presContext; nsGenericHTMLElement::GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; nsGUIEvent event; event.eventStructType = NS_GUI_EVENT; event.message = NS_FORM_SELECTED; event.flags = NS_EVENT_FLAG_NONE; event.widget = nsnull; rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
nsHTMLInputElement::Select(){  nsresult rv = NS_OK;  // first see if we are disabled or not. If disabled then do nothing.  nsAutoString disabled;  if (NS_CONTENT_ATTR_HAS_VALUE == mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, disabled)) {    return rv;  }  // see what type of input we are.  Only select for texts and passwords  PRInt32 type;  GetType(&type);  if (NS_FORM_INPUT_PASSWORD == type ||      NS_FORM_INPUT_TEXT == type) {     // Currently we have to give focus to the text field before we    // can select text in it.  :S    // Just like SetFocus() but without the ScrollIntoView()!    nsCOMPtr<nsIPresContext> presContext;    nsGenericHTMLElement::GetPresContext(this, getter_AddRefs(presContext));    nsCOMPtr<nsIEventStateManager> esm;    if (NS_OK == presContext->GetEventStateManager(getter_AddRefs(esm))) {      esm->SetContentState(this, NS_EVENT_STATE_FOCUS);    }    nsIFormControlFrame* formControlFrame = nsnull;    nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);    if (NS_SUCCEEDED(rv)) {      formControlFrame->SetFocus(PR_TRUE, PR_TRUE);    }    // Now Select all the text!    if (NS_SUCCEEDED(rv)) {      rv = SelectAll(presContext);    }  }  return rv;}