if ((NS_OK == rv) && (nsEventStatus_eIgnore == *aEventStatus) && !(aFlags & NS_EVENT_FLAG_CAPTURE)) { switch (aEvent->message) { case NS_FORM_SELECTED: {     nsCOMPtr<nsIEventStateManager> esm; if (NS_OK == aPresContext->GetEventStateManager(getter_AddRefs(esm))) { esm->SetContentState(this, NS_EVENT_STATE_FOCUS); }  nsIFormControlFrame* formControlFrame = nsnull; rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame); if (NS_SUCCEEDED(rv)) { formControlFrame->SetFocus(PR_TRUE, PR_TRUE);   rv = SelectAll(aPresContext); } } break;  } }
nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,                                      nsEvent* aEvent,                                      nsIDOMEvent** aDOMEvent,                                      PRUint32 aFlags,                                      nsEventStatus* aEventStatus){  // Do not process any DOM events if the element is disabled  PRBool disabled;  nsresult rv = GetDisabled(&disabled);  if (NS_FAILED(rv) || disabled) {    return rv;  }  nsIFormControlFrame* formControlFrame = nsnull;  rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);  nsIFrame* formFrame = nsnull;  if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame)) && formFrame)  {    const nsStyleUserInterface* uiStyle;    formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct *&)uiStyle);    if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||        uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)    {      return NS_OK;    }  }  // We have anonymous content underneath  // that we need to hide.  We need to set the event target now  // to ourselves  {    // If the event is starting here that's fine.  If it's not    // init'ing here it started beneath us and needs modification.    if (!(NS_EVENT_FLAG_INIT & aFlags)) {      if (!*aDOMEvent) {        // We haven't made a DOMEvent yet.  Force making one now.        nsCOMPtr<nsIEventListenerManager> listenerManager;        if (NS_FAILED(rv = mInner.GetListenerManager(getter_AddRefs(listenerManager)))) {          return rv;        }        nsAutoString empty;        if (NS_FAILED(rv = listenerManager->CreateEvent(aPresContext, aEvent, empty, aDOMEvent))) {          return rv;        }      }      if (!*aDOMEvent) {        return NS_ERROR_FAILURE;      }      nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);      if (!privateEvent) {        return NS_ERROR_FAILURE;      }      nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface((nsIDOMHTMLTextAreaElement*)this);      privateEvent->SetTarget(target);    }  }    rv = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,                               aFlags, aEventStatus);  // Finish the special anonymous content processing...  {    // If the event is starting here that's fine.  If it's not    // init'ing here it started beneath us and needs modification.    if (!(NS_EVENT_FLAG_INIT & aFlags)) {      if (!*aDOMEvent) {        return NS_ERROR_FAILURE;      }      nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);      if (!privateEvent) {        return NS_ERROR_FAILURE;      }      // This will reset the target to its original value      privateEvent->SetTarget(nsnull);    }  }  return rv;}