nsIFormControlFrame* formControlFrame = nsnull; rv = GetPrimaryFrame(this, formControlFrame, PR_FALSE); if (NS_SUCCEEDED(rv) && formControlFrame) { nsIFrame* formFrame = nsnull; if (NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (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; } }
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;  }  // 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:      {        // Tell the frame about the click        nsIFormControlFrame* formControlFrame = nsnull;        rv = GetPrimaryFrame(this, formControlFrame);        if (NS_SUCCEEDED(rv)) {          formControlFrame->MouseClicked(aPresContext);        }      }      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:      if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {        (*aDOMEvent)->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;}