From 02636c5f4514829c2beda66f867155106a15cd2d Mon Sep 17 00:00:00 2001 From: "Olli.Pettay@helsinki.fi" Date: Mon, 12 Nov 2007 11:09:09 -0800 Subject: [PATCH] Bug 403514, Crash when closing tab with CTRL+W, r+sr=dbaron,a=schrep --- content/events/src/nsDOMUIEvent.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index b280257b7e29..1567fce8a7c7 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -154,7 +154,11 @@ nsPoint nsDOMUIEvent::GetClientPoint() { } nsPoint pt(0, 0); - nsIFrame* rootFrame = mPresContext->PresShell()->GetRootFrame(); + nsIPresShell* shell = mPresContext->PresShell(); + if (!shell) { + return pt; + } + nsIFrame* rootFrame = shell->GetRootFrame(); if (rootFrame) pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame); @@ -196,11 +200,15 @@ nsDOMUIEvent::GetPagePoint() if (((nsGUIEvent*)mEvent)->widget) { // Native event; calculate using presentation nsPoint pt(0, 0); - nsIScrollableFrame* scrollframe = - mPresContext->PresShell()->GetRootScrollFrameAsScrollable(); + nsIPresShell* shell = mPresContext->PresShell(); + if (!shell) { + return pt; + } + nsIScrollableFrame* scrollframe = shell->GetRootScrollFrameAsScrollable(); + if (scrollframe) pt += scrollframe->GetScrollPosition(); - nsIFrame* rootFrame = mPresContext->PresShell()->GetRootFrame(); + nsIFrame* rootFrame = shell->GetRootFrame(); if (rootFrame) pt += nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame); return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),