!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
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;    }  }    // Try script event handlers first  nsresult ret;  ret = nsGenericHTMLContainerFormElement::HandleDOMEvent(aPresContext,                                                          aEvent, aDOMEvent,                                                          aFlags,                                                          aEventStatus);  if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&      !(aFlags & NS_EVENT_FLAG_CAPTURE)) {    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 (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->HandleEventWithTarget(&event, nsnull, form,                                             NS_EVENT_FLAG_INIT, &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;    }  }  return ret;}