mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-15 04:39:31 +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);
|
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.
|
//My god, man, there *must* be a better way to do this.
|
||||||
nsCOMPtr<nsIWidget> docWidget;
|
nsCOMPtr<nsIWidget> docWidget;
|
||||||
nsIPresShell *presShell = mPresContext->GetPresShell();
|
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;
|
nsPoint pt = mEvent->refPoint;
|
||||||
|
|
||||||
// BUG 296004 (see also BUG 242833)
|
// BUG 296004 (see also BUG 242833)
|
||||||
|
@ -1945,7 +1945,12 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
|
|||||||
nsEvent* aEvent,
|
nsEvent* aEvent,
|
||||||
nsIDOMEvent** aDOMEvent)
|
nsIDOMEvent** aDOMEvent)
|
||||||
{
|
{
|
||||||
nsIPresShell* shell = aPresContext->PresShell();
|
nsIPresShell* shell = aPresContext->GetPresShell();
|
||||||
|
if (!shell) {
|
||||||
|
// Nothing to do.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult ret = NS_OK;
|
nsresult ret = NS_OK;
|
||||||
|
|
||||||
if (nsnull == *aDOMEvent) {
|
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*
|
nsIFrame*
|
||||||
nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
||||||
nsIContent* aTargetContent,
|
nsIContent* aTargetContent,
|
||||||
@ -2564,18 +2587,22 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
|||||||
BeforeDispatchEvent();
|
BeforeDispatchEvent();
|
||||||
nsIFrame* targetFrame = nsnull;
|
nsIFrame* targetFrame = nsnull;
|
||||||
if (aTargetContent) {
|
if (aTargetContent) {
|
||||||
|
nsESMEventCB callback(aTargetContent);
|
||||||
nsEventDispatcher::Dispatch(aTargetContent, mPresContext, &event, nsnull,
|
nsEventDispatcher::Dispatch(aTargetContent, mPresContext, &event, nsnull,
|
||||||
&status);
|
&status, &callback);
|
||||||
|
|
||||||
nsIPresShell *shell = mPresContext->GetPresShell();
|
nsIPresShell *shell = mPresContext ? mPresContext->GetPresShell() : nsnull;
|
||||||
if (shell) {
|
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);
|
targetFrame = shell->GetPrimaryFrameFor(aTargetContent);
|
||||||
|
if (targetFrame) {
|
||||||
|
SetFrameExternalReference(targetFrame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (targetFrame) {
|
|
||||||
targetFrame->HandleEvent(mPresContext, &event, &status);
|
|
||||||
SetFrameExternalReference(targetFrame);
|
|
||||||
}
|
|
||||||
AfterDispatchEvent();
|
AfterDispatchEvent();
|
||||||
|
|
||||||
mCurrentTargetContent = nsnull;
|
mCurrentTargetContent = nsnull;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user