mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
Bug 336576, Crash when window gets destroyed during contextmenu event, r+sr=bz
This commit is contained in:
parent
b8edab6c11
commit
b360361e20
@ -142,10 +142,6 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
|
||||
return nsPoint(0, 0);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> eventWidget = ((nsGUIEvent*)mEvent)->widget;
|
||||
if (!eventWidget)
|
||||
return mClientPoint;
|
||||
|
||||
//My god, man, there *must* be a better way to do this.
|
||||
nsCOMPtr<nsIWidget> docWidget;
|
||||
nsIPresShell *presShell = mPresContext->GetPresShell();
|
||||
@ -156,6 +152,10 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> eventWidget = ((nsGUIEvent*)mEvent)->widget;
|
||||
if (!eventWidget || !docWidget)
|
||||
return mClientPoint;
|
||||
|
||||
nsPoint pt = mEvent->refPoint;
|
||||
|
||||
// BUG 296004 (see also BUG 242833)
|
||||
|
@ -1945,7 +1945,12 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent)
|
||||
{
|
||||
nsIPresShell* shell = aPresContext->PresShell();
|
||||
nsIPresShell* shell = aPresContext->GetPresShell();
|
||||
if (!shell) {
|
||||
// Nothing to do.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
if (nsnull == *aDOMEvent) {
|
||||
|
@ -2543,6 +2543,29 @@ nsEventStateManager::AfterDispatchEvent()
|
||||
}
|
||||
}
|
||||
|
||||
class nsESMEventCB : public nsDispatchingCallback
|
||||
{
|
||||
public:
|
||||
nsESMEventCB(nsIContent* aTarget) : mTarget(aTarget) {}
|
||||
|
||||
virtual void HandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
{
|
||||
if (aVisitor.mPresContext) {
|
||||
nsIPresShell* shell = aVisitor.mPresContext->GetPresShell();
|
||||
if (shell) {
|
||||
nsIFrame* frame = shell->GetPrimaryFrameFor(mTarget);
|
||||
if (frame) {
|
||||
frame->HandleEvent(aVisitor.mPresContext,
|
||||
(nsGUIEvent*) aVisitor.mEvent,
|
||||
&aVisitor.mEventStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> mTarget;
|
||||
};
|
||||
|
||||
nsIFrame*
|
||||
nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
||||
nsIContent* aTargetContent,
|
||||
@ -2564,18 +2587,22 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
||||
BeforeDispatchEvent();
|
||||
nsIFrame* targetFrame = nsnull;
|
||||
if (aTargetContent) {
|
||||
nsESMEventCB callback(aTargetContent);
|
||||
nsEventDispatcher::Dispatch(aTargetContent, mPresContext, &event, nsnull,
|
||||
&status);
|
||||
&status, &callback);
|
||||
|
||||
nsIPresShell *shell = mPresContext->GetPresShell();
|
||||
nsIPresShell *shell = mPresContext ? mPresContext->GetPresShell() : nsnull;
|
||||
if (shell) {
|
||||
// Although the primary frame was checked in event callback,
|
||||
// it may not be the same object after event dispatching and handling.
|
||||
// So we need to refetch it.
|
||||
targetFrame = shell->GetPrimaryFrameFor(aTargetContent);
|
||||
if (targetFrame) {
|
||||
SetFrameExternalReference(targetFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetFrame) {
|
||||
targetFrame->HandleEvent(mPresContext, &event, &status);
|
||||
SetFrameExternalReference(targetFrame);
|
||||
}
|
||||
|
||||
AfterDispatchEvent();
|
||||
|
||||
mCurrentTargetContent = nsnull;
|
||||
|
Loading…
x
Reference in New Issue
Block a user