void HandleEvent() {  nsRefPtr<PresShell> presShell = NS_STATIC_CAST(PresShell*, owner); presShell->mDummyLayoutRequestEventPosted = PR_FALSE; presShell->RemoveDummyLayoutRequest(); }
PresShell::HandleEvent(nsIView         *aView, nsGUIEvent*     aEvent, nsEventStatus*  aEventStatus, PRBool          aForceHandle, PRBool&         aHandled) { NS_ASSERTION(aView, "null view"); aHandled = PR_TRUE;  if (mIsDestroying || mIsReflowing || mChangeNestCount) { return NS_OK; }  #ifdef ACCESSIBILITY if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT) { return HandleEventInternal(aEvent, aView, NS_EVENT_FLAG_INIT, aEventStatus); } #endif   if (aEvent->message == NS_THEMECHANGED && mPresContext) { mPresContext->ThemeChanged(); return NS_OK; }    if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext) { nsIViewManager* vm = GetViewManager(); if (vm) {     nsIView *view; vm->GetRootView(view); if (view == aView) { aHandled = PR_TRUE; *aEventStatus = nsEventStatus_eConsumeDoDefault; mPresContext->SysColorChanged(); return NS_OK; } } return NS_OK; }  nsIFrame* frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());  nsresult rv = NS_OK;  if (frame) { PushCurrentEventInfo(nsnull, nsnull);   nsCOMPtr<nsIEventStateManager> manager; if ((NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) || aEvent->message == NS_CONTEXTMENU_KEY)) {  nsIEventStateManager *esm = mPresContext->EventStateManager();  esm->GetFocusedContent(getter_AddRefs(mCurrentEventContent));  esm->GetFocusedFrame(&mCurrentEventFrame); if (!mCurrentEventFrame) { #if defined(MOZ_X11) if (NS_IS_IME_EVENT(aEvent)) {       nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); if (ourWindow) { nsIFocusController *focusController = ourWindow->GetRootFocusController(); if (focusController) { PRBool active = PR_FALSE;  focusController->GetActive(&active); if (!active) {  nsCOMPtr<nsIDOMElement> focusedElement; focusController->GetFocusedElement(getter_AddRefs(focusedElement)); if (focusedElement) {  mCurrentEventContent = do_QueryInterface(focusedElement); } } } } } #endif  if (!mCurrentEventContent) { mCurrentEventContent = mDocument->GetRootContent(); } mCurrentEventFrame = nsnull; } if (mCurrentEventContent && InZombieDocument(mCurrentEventContent)) { return RetargetEventToParent(aView, aEvent, aEventStatus, aForceHandle, aHandled, mCurrentEventContent); } } else if (!InClipRect(frame, aEvent->point)) {     if (aForceHandle) { mCurrentEventFrame = frame; } else { mCurrentEventFrame = nsnull; } aHandled = PR_FALSE; rv = NS_OK; } else {       nsPoint eventPoint = frame->GetPosition(); eventPoint += aEvent->point;  nsPoint originOffset; nsIView *view = nsnull; frame->GetOriginToViewOffset(originOffset, &view);  NS_ASSERTION(view == aView, "view != aView"); if (view == aView) eventPoint -= originOffset;  rv = frame->GetFrameForPoint(eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame); if (NS_FAILED(rv)) { rv = frame->GetFrameForPoint(eventPoint, NS_FRAME_PAINT_LAYER_FLOATS, &mCurrentEventFrame); if (NS_FAILED(rv)) { rv = frame->GetFrameForPoint(eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame); if (NS_FAILED (rv)) { if (aForceHandle) { mCurrentEventFrame = frame; } else { mCurrentEventFrame = nsnull; } aHandled = PR_FALSE; rv = NS_OK; } } }  if (mCurrentEventFrame) { nsCOMPtr<nsIContent> targetElement; mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, getter_AddRefs(targetElement));     if (targetElement) {         while (targetElement && !targetElement->IsContentOfType(nsIContent::eELEMENT)) { targetElement = targetElement->GetParent(); }   if (!targetElement) { mCurrentEventContent = nsnull; mCurrentEventFrame = nsnull; } else if (targetElement != mCurrentEventContent) { mCurrentEventContent = targetElement; } } }  } if (GetCurrentEventFrame()) { rv = HandleEventInternal(aEvent, aView, NS_EVENT_FLAG_INIT, aEventStatus); }  #ifdef NS_DEBUG if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (GetCurrentEventFrame())) { nsIView *oldView = mCurrentTargetView; nsPoint offset(0,0); nsRect oldTargetRect(mCurrentTargetRect); mCurrentTargetRect = mCurrentEventFrame->GetRect(); mCurrentTargetView = mCurrentEventFrame->GetView(); if (!mCurrentTargetView ) { mCurrentEventFrame->GetOffsetFromView(offset, &mCurrentTargetView); } if (mCurrentTargetView) { mCurrentTargetRect.x = offset.x; mCurrentTargetRect.y = offset.y;  if ((mCurrentTargetRect != oldTargetRect) || (mCurrentTargetView != oldView)) {  nsIViewManager* vm = GetViewManager(); if (vm) { vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0); if (oldView) vm->UpdateView(oldView,oldTargetRect,0); } } } } #endif PopCurrentEventInfo(); } else {    if (!NS_EVENT_NEEDS_FRAME(aEvent)) { mCurrentEventFrame = nsnull; return HandleEventInternal(aEvent, aView, NS_EVENT_FLAG_INIT, aEventStatus); } else if (NS_IS_KEY_EVENT(aEvent)) {   return RetargetEventToParent(aView, aEvent, aEventStatus, aForceHandle, aHandled, mCurrentEventContent); }  aHandled = PR_FALSE; }  return rv; }
  void HandleEvent() {    // Hold a ref here, just in case, since we can trigger DOM event dispatch    nsRefPtr<PresShell> presShell = NS_STATIC_CAST(PresShell*, owner);    presShell->mDummyLayoutRequestEventPosted = PR_FALSE;    presShell->RemoveDummyLayoutRequest();  }