From 08c926ac634192bcae288a805aa817a8f066372b Mon Sep 17 00:00:00 2001 From: Johnny Stenback Date: Fri, 19 Mar 2010 15:06:13 -0700 Subject: [PATCH] Fixing bug 550905. Don't use uninitialized values. r=jonas@sicking.cc --- dom/base/nsGlobalWindow.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 203af2b916f6..4ad2a65ec282 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3671,33 +3671,34 @@ nsGlobalWindow::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop) nsContentUtils::HidePopupsInDocument(doc); #endif - PRInt32 screenLeft, screenTop, screenWidth, screenHeight; - PRInt32 winLeft, winTop, winWidth, winHeight; - nsGlobalWindow* rootWindow = static_cast(GetPrivateRoot()); if (rootWindow) { rootWindow->FlushPendingNotifications(Flush_Layout); } - // Get the window size nsCOMPtr treeOwner; GetTreeOwner(getter_AddRefs(treeOwner)); - if (treeOwner) - treeOwner->GetPositionAndSize(&winLeft, &winTop, &winWidth, &winHeight); - // convert those values to CSS pixels - // XXX four separate retrievals of the prescontext - winLeft = DevToCSSIntPixels(winLeft); - winTop = DevToCSSIntPixels(winTop); - winWidth = DevToCSSIntPixels(winWidth); - winHeight = DevToCSSIntPixels(winHeight); - - // Get the screen dimensions - // XXX This should use nsIScreenManager once it's fully fleshed out. nsCOMPtr screen; GetScreen(getter_AddRefs(screen)); - if (screen) { + + if (treeOwner && screen) { + PRInt32 screenLeft, screenTop, screenWidth, screenHeight; + PRInt32 winLeft, winTop, winWidth, winHeight; + + // Get the window size + treeOwner->GetPositionAndSize(&winLeft, &winTop, &winWidth, &winHeight); + + // convert those values to CSS pixels + // XXX four separate retrievals of the prescontext + winLeft = DevToCSSIntPixels(winLeft); + winTop = DevToCSSIntPixels(winTop); + winWidth = DevToCSSIntPixels(winWidth); + winHeight = DevToCSSIntPixels(winHeight); + + // Get the screen dimensions + // XXX This should use nsIScreenManager once it's fully fleshed out. screen->GetAvailLeft(&screenLeft); screen->GetAvailWidth(&screenWidth); screen->GetAvailHeight(&screenHeight); @@ -3713,9 +3714,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop) #else screen->GetAvailTop(&screenTop); #endif - } - if (screen && treeOwner) { if (aLeft) { if (screenLeft+screenWidth < *aLeft+winWidth) *aLeft = screenLeft+screenWidth - winWidth;