if (mType == NS_FORM_BUTTON_SUBMIT) {      mForm->ForgetPendingSubmission(); }
nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,                                    nsEvent* aEvent,                                    nsIDOMEvent** aDOMEvent,                                    PRUint32 aFlags,                                    nsEventStatus* aEventStatus){  NS_ENSURE_ARG(aPresContext);  NS_ENSURE_ARG_POINTER(aEventStatus);  // Do not process any DOM events if the element is disabled  PRBool bDisabled;  nsresult rv = GetDisabled(&bDisabled);  if (NS_FAILED(rv) || bDisabled) {    return rv;  }  nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE);  if (formControlFrame) {    nsIFrame* formFrame = nsnull;    CallQueryInterface(formControlFrame, &formFrame);    if (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;    }  }  PRBool bInSubmitClick = mType == NS_FORM_BUTTON_SUBMIT &&                           !(aFlags & NS_EVENT_FLAG_CAPTURE) &&                          !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&                          aEvent->message == NS_MOUSE_LEFT_CLICK &&                          mForm;  if (bInSubmitClick) {    // tell the form that we are about to enter a click handler.    // that means that if there are scripted submissions, the    // latest one will be deferred until after the exit point of the handler.     mForm->OnSubmitClickBegin();  }  // Try script event handlers first  nsresult ret;  ret = nsGenericHTMLContainerFormElement::HandleDOMEvent(aPresContext,                                                          aEvent, aDOMEvent,                                                          aFlags,                                                          aEventStatus);  if (bInSubmitClick) {    // tell the form that we are about to exit a click handler    // so the form knows not to defer subsequent submissions    // the pending ones that were created during the handler    // will be flushed or forgoten.    mForm->OnSubmitClickEnd();  }  if (NS_SUCCEEDED(ret) &&      !(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {    if (nsEventStatus_eIgnore == *aEventStatus) {       switch (aEvent->message) {      case NS_KEY_PRESS:      case NS_KEY_UP:        {          // For backwards compat, trigger buttons with space or enter          // (bug 25300)          nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;          if ((keyEvent->keyCode == NS_VK_RETURN && NS_KEY_PRESS == aEvent->message) ||              keyEvent->keyCode == NS_VK_SPACE  && NS_KEY_UP == aEvent->message) {            nsEventStatus status = nsEventStatus_eIgnore;            nsMouseEvent event;            event.eventStructType = NS_MOUSE_EVENT;            event.message = NS_MOUSE_LEFT_CLICK;            event.isShift = PR_FALSE;            event.isControl = PR_FALSE;            event.isAlt = PR_FALSE;            event.isMeta = PR_FALSE;            event.clickCount = 0;            event.widget = nsnull;            rv = HandleDOMEvent(aPresContext, &event, nsnull,                                NS_EVENT_FLAG_INIT, &status);          }        }        break;// NS_KEY_PRESS      case NS_MOUSE_LEFT_CLICK:        {          if (mForm) {            if (mType == NS_FORM_BUTTON_SUBMIT) {              // tell the form to forget a possible pending submission.              // the reason is that the script returned true (the event was              // ignored) so if there is a stored submission, it will miss              // the name/value of the submitting element, thus we need              // to forget it and the form element will build a new one              mForm->ForgetPendingSubmission();            }            if (mType == NS_FORM_BUTTON_SUBMIT || mType == NS_FORM_BUTTON_RESET) {              nsFormEvent event;              event.eventStructType = NS_FORM_EVENT;              event.message         = (mType == NS_FORM_BUTTON_RESET)                                       ? NS_FORM_RESET : NS_FORM_SUBMIT;              event.originator      = this;              nsEventStatus status  = nsEventStatus_eIgnore;              nsCOMPtr<nsIPresShell> presShell;              aPresContext->GetShell(getter_AddRefs(presShell));              // If |nsIPresShell::Destroy| has been called due to              // handling the event (base class HandleDOMEvent, above),              // the pres context will return a null pres shell.  See              // bug 125624.              if (presShell) {                nsCOMPtr<nsIContent> form(do_QueryInterface(mForm));                presShell->HandleDOMEventWithTarget(form, &event, &status);              }            }          }        }        break;// NS_MOUSE_LEFT_CLICK      case NS_MOUSE_LEFT_BUTTON_DOWN:        {          nsIEventStateManager *stateManager;          if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {            stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE |                                          NS_EVENT_STATE_FOCUS);            NS_RELEASE(stateManager);          }          *aEventStatus = nsEventStatus_eConsumeNoDefault;         }        break;      // cancel all of these events for buttons      case NS_MOUSE_MIDDLE_BUTTON_DOWN:      case NS_MOUSE_MIDDLE_BUTTON_UP:      case NS_MOUSE_MIDDLE_DOUBLECLICK:      case NS_MOUSE_RIGHT_DOUBLECLICK:      case NS_MOUSE_RIGHT_BUTTON_DOWN:      case NS_MOUSE_RIGHT_BUTTON_UP:        {          nsCOMPtr<nsIDOMNSEvent> nsevent;          if (aDOMEvent) {            nsevent = do_QueryInterface(*aDOMEvent);          }          if (nsevent) {            nsevent->PreventBubble();          } else {            ret = NS_ERROR_FAILURE;          }        }        break;      case NS_MOUSE_ENTER_SYNTH:        {          nsIEventStateManager *stateManager;          if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {            stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);            NS_RELEASE(stateManager);          }          *aEventStatus = nsEventStatus_eConsumeNoDefault;         }        break;        // XXX this doesn't seem to do anything yet      case NS_MOUSE_EXIT_SYNTH:        {          nsIEventStateManager *stateManager;          if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {            stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);            NS_RELEASE(stateManager);          }          *aEventStatus = nsEventStatus_eConsumeNoDefault;         }        break;      default:        break;      }	  } else {      switch (aEvent->message) {      case NS_MOUSE_LEFT_CLICK:        if (mForm && mType == NS_FORM_BUTTON_SUBMIT) {          // tell the form to flush a possible pending submission.          // the reason is that the script returned false (the event was          // not ignored) so if there is a stored submission, it needs to          // be submitted immediatelly.          mForm->FlushPendingSubmission();        }        break;// NS_MOUSE_LEFT_CLICK      } //switch    } //if  } //if  return ret;}