if (nsnull != GetCurrentEventFrame() && NS_OK == rv) { nsIContent* targetContent; if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) { rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
if ((GetCurrentEventFrame() || focusContent) && NS_OK == rv) { if (focusContent) { rv = focusContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
PresShell::HandleEvent(nsIView         *aView,                       nsGUIEvent*     aEvent,                       nsEventStatus&  aEventStatus){  void*     clientData;  nsIFrame* frame;  nsresult  rv = NS_OK;    NS_ASSERTION(!(nsnull == aView), "null view");  if (mIsDestroying || mReflowLockCount > 0) {    return NS_OK;  }  aView->GetClientData(clientData);  frame = (nsIFrame *)clientData;  if (nsnull != frame) {    nsIWebShell* webShell = nsnull;    nsISupports* container;    mPresContext->GetContainer(&container);    if (nsnull != container) {      if (NS_OK != container->QueryInterface(kIWebShellIID, (void**)&webShell)) {        NS_ASSERTION(webShell, "No webshell to grab during event dispatch");      }      NS_RELEASE(container);    }    if (mSelection && aEvent->eventStructType == NS_KEY_EVENT)    {      mSelection->EnableFrameNotification(PR_FALSE);      mSelection->HandleKeyEvent(aEvent);      mSelection->EnableFrameNotification(PR_TRUE); //prevents secondary reset selection called since      //we are a listener now.    }    frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);    NS_IF_RELEASE(mCurrentEventContent);    if (nsnull != GetCurrentEventFrame()) {      //Once we have the targetFrame, handle the event in this order      nsIEventStateManager *manager;      if (NS_OK == mPresContext->GetEventStateManager(&manager)) {        //1. Give event to event manager for pre event state changes and generation of synthetic events.        rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);        //2. Give event to the DOM for third party and JS use.        if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {          nsIContent* targetContent;          if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) {            rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,                                                NS_EVENT_FLAG_INIT, aEventStatus);            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 (nsnull != GetCurrentEventFrame() && NS_OK == rv) {            rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);            //4. Give event to event manager for post event state changes and generation of synthetic events.            if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {              rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);            }          }        }        NS_RELEASE(manager);      }    }    NS_IF_RELEASE(webShell);  }  else {    rv = NS_OK;  }  return rv;}