diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index c1bd1ef6668d..4e5e1348fc2a 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -822,14 +822,6 @@ nsBaseWidget::InfallibleMakeFullScreen(bool aFullScreen, nsIScreen* aScreen) { HideWindowChrome(aFullScreen); - nsCOMPtr screen = aScreen; - if (!screen) { - screen = GetWidgetScreen(); - if (!screen) { - return; - } - } - if (aFullScreen) { if (!mOriginalBounds) { mOriginalBounds = new LayoutDeviceIntRect(); @@ -837,26 +829,25 @@ nsBaseWidget::InfallibleMakeFullScreen(bool aFullScreen, nsIScreen* aScreen) *mOriginalBounds = GetScreenBounds(); // Move to top-left corner of screen and size to the screen dimensions - int32_t left, top, width, height; - if (NS_SUCCEEDED(screen->GetRectDisplayPix(&left, &top, &width, &height))) { - Resize(left, top, width, height, true); + nsCOMPtr screen = aScreen; + if (!screen) { + screen = GetWidgetScreen(); + } + if (screen) { + int32_t left, top, width, height; + if (NS_SUCCEEDED(screen->GetRectDisplayPix(&left, &top, &width, &height))) { + Resize(left, top, width, height, true); + } } } else if (mOriginalBounds) { - int32_t left, top, width, height; - if (NS_FAILED(screen->GetAvailRectDisplayPix(&left, &top, - &width, &height))) { - return; - } - gfx::Rect screenRect(left, top, width, height); - gfx::Rect rect; if (BoundsUseDesktopPixels()) { DesktopRect deskRect = *mOriginalBounds / GetDesktopToDeviceScale(); - rect = deskRect.ToUnknownRect(); + Resize(deskRect.X(), deskRect.Y(), + deskRect.Width(), deskRect.Height(), true); } else { - rect = gfx::Rect(mOriginalBounds->ToUnknownRect()); + Resize(mOriginalBounds->X(), mOriginalBounds->Y(), + mOriginalBounds->Width(), mOriginalBounds->Height(), true); } - rect = rect.MoveInsideAndClamp(screenRect); - Resize(rect.x, rect.y, rect.width, rect.height, true); } }