From 7355c3600a9a503597640ca6a385a8985616cf9f Mon Sep 17 00:00:00 2001 From: "Olli.Pettay%helsinki.fi" Date: Mon, 12 Nov 2007 12:20:41 +0000 Subject: [PATCH] Bug 401528, Must click twice to open link if fixed positioned div is removed on onmouseup: clicks pass through, r+sr=roc, a=blocking1.9+ git-svn-id: svn://10.0.0.236/trunk@239200 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/src/nsEventStateManager.cpp | 27 +++++++++++++------ mozilla/layout/base/nsPresShell.cpp | 7 +++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3b9e718decd..da2609b98d2 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -2265,12 +2265,10 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, mCurrentTarget = aTargetFrame; mCurrentTargetContent = nsnull; - // All the events we handle below require a frame. - if (!mCurrentTarget) { - if (NS_EVENT_NEEDS_FRAME(aEvent)) { - NS_ERROR("Null frame for an event that requires a frame"); - return NS_ERROR_NULL_POINTER; - } + // Most of the events we handle below require a frame. + // Add special cases here. + if (!mCurrentTarget && + aEvent->message != NS_MOUSE_BUTTON_UP) { return NS_OK; } @@ -2372,9 +2370,22 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, if (!mCurrentTarget) { nsIFrame* targ; GetEventTarget(&targ); - if (!targ) return NS_ERROR_FAILURE; } - ret = CheckForAndDispatchClick(presContext, (nsMouseEvent*)aEvent, aStatus); + if (mCurrentTarget) { + ret = CheckForAndDispatchClick(presContext, (nsMouseEvent*)aEvent, aStatus); + } + if (aView) { + // Make sure viewmanager doesn't continue capturing mouse events. + nsIViewManager* viewMan = aView->GetViewManager(); + if (viewMan) { + nsIView* grabbingView; + viewMan->GetMouseEventGrabber(grabbingView); + if (grabbingView == aView) { + PRBool result; + viewMan->GrabMouseEvents(nsnull, result); + } + } + } nsIPresShell *shell = presContext->GetPresShell(); if (shell) { shell->FrameSelection()->SetMouseDownState(PR_FALSE); diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 66ef465c9ad..ff2337e8911 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5803,10 +5803,9 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, // 3. Give event to event manager for post event state changes and // generation of synthetic events. - if (NS_SUCCEEDED (rv) && - (GetCurrentEventFrame() || !NS_EVENT_NEEDS_FRAME(aEvent))) { - rv = manager->PostHandleEvent(mPresContext, aEvent, mCurrentEventFrame, - aStatus, aView); + if (NS_SUCCEEDED(rv)) { + rv = manager->PostHandleEvent(mPresContext, aEvent, + GetCurrentEventFrame(), aStatus, aView); } } }