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;