Fix crasher in mouse events (bug 185850), r=kmcclusk@netscape.com, sr=roc+moz@cs.cmu.edu

git-svn-id: svn://10.0.0.236/trunk@135453 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jkeiser%netscape.com
2002-12-18 07:13:51 +00:00
parent 0a717d481c
commit 59b8b31b7e
2 changed files with 20 additions and 2 deletions

View File

@@ -2405,12 +2405,23 @@ nsEventStateManager::DispatchMouseEvent(nsIPresContext* aPresContext,
mCurrentTargetContent = aTargetContent;
mCurrentRelatedContent = aRelatedContent;
nsIFrame* targetFrame = aTargetFrame;
if (aTargetContent) {
aTargetContent->HandleDOMEvent(aPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
if (!mCurrentTarget) {
// If current target frame is removed, it's pretty likely something has
// happened to our target frame as well (since it's either a parent or the
// same frame), so we need to re-resolve it. Conversely, if nothing has
// happened to our current target frame, our frame is guaranteed to still
// be around, so we don't need to re-resolve it. (Bug 185850)
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
shell->GetPrimaryFrameFor(aTargetContent, &targetFrame);
}
}
if (aTargetFrame) {
aTargetFrame->HandleEvent(aPresContext, &event, &status);
if (targetFrame) {
targetFrame->HandleEvent(aPresContext, &event, &status);
}
mCurrentTargetContent = nsnull;

View File

@@ -154,6 +154,13 @@ public:
protected:
void UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
/**
* Turn a GUI mouse event into a mouse event targeted at the specified
* content and frame. Do NOT call if you are not planning to target the
* mouse event at an element that is not the current target frame or a parent
* thereof--or if you do, fix the crash protection inside (for bug 185850)
* to work with other frames.
*/
void DispatchMouseEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, PRUint32 aMessage, nsIContent* aTargetContent, nsIFrame* aTargetFrame, nsIContent* aRelatedContent);
void MaybeDispatchMouseEventToIframe(nsIPresContext* aPresContext, nsGUIEvent* aEvent, PRUint32 aMessage);
void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);