if (mCurrentEventContent) { rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull, aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus); } else { nsIContent* targetContent; if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) { rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus); NS_RELEASE(targetContent); } }
PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags, nsEventStatus* aStatus){#ifdef ACCESSIBILITY  if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT)  {    void*     clientData;    aView->GetClientData(clientData);    nsIFrame* frame = (nsIFrame *)clientData;    if (!frame)      return NS_ERROR_FAILURE;    return frame->HandleEvent(mPresContext, (nsGUIEvent*)aEvent, aStatus);  }#endif  nsresult rv = NS_OK;  nsIEventStateManager *manager;  if (NS_OK == mPresContext->GetEventStateManager(&manager) && GetCurrentEventFrame()) {    //1. Give event to event manager for pre event state changes and generation of synthetic events.    rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);    //2. Give event to the DOM for third party and JS use.    if ((GetCurrentEventFrame()) && NS_OK == rv) {      if (mCurrentEventContent) {        rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,                                            aFlags, aStatus);      }      else {        nsIContent* targetContent;        if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {          rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,                                              aFlags, aStatus);          NS_RELEASE(targetContent);        }      }      //3. Give event to the Frames for browser default processing.      // XXX The event isn't translated into the local coordinate space      // of the frame...      if (GetCurrentEventFrame() && NS_OK == rv && aEvent->eventStructType != NS_EVENT) {        rv = mCurrentEventFrame->HandleEvent(mPresContext, (nsGUIEvent*)aEvent, aStatus);      }      //4. Give event to event manager for post event state changes and generation of synthetic events.      if ((GetCurrentEventFrame()) && NS_OK == rv) {        rv = manager->PostHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);      }    }    NS_RELEASE(manager);  }  return rv;}