Bug 1448760 - Don't try to center window after load when the size mode is not normal. r?bz
MozReview-Commit-ID: Ainh34XuvFg
--- a/toolkit/content/tests/chrome/test_maximized_persist.xul
+++ b/toolkit/content/tests/chrome/test_maximized_persist.xul
@@ -91,16 +91,23 @@
// Open a new window again to check persisted sizemode.
win = openWindow();
await SimpleTest.promiseFocus(win);
checkWindow("when reopen to normal", win, win.STATE_NORMAL, WIDTH, HEIGHT);
// And maximize the window again for next test.
await changeSizeMode(() => win.maximize());
win.close();
+ // Open a new window again with centerscreen which shouldn't revert
+ // the persisted sizemode.
+ win = openWindow("centerscreen");
+ await SimpleTest.promiseFocus(win);
+ checkWindow("when open with centerscreen", win, win.STATE_MAXIMIZED);
+ win.close();
+
// Linux doesn't seem to persist sizemode across opening window
// with specified size, so mark it expected fail for now.
let todo = navigator.platform.includes('Linux');
let checkWindowMayFail = todo ? todoCheckWindow : checkWindow;
// Open a new window with size specified.
win = openWindow("width=400,height=400");
await SimpleTest.promiseFocus(win);
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -2353,17 +2353,18 @@ nsXULWindow::SizeShell()
// Now that we have set the window's final size, we can re-do its
// positioning so that it is properly constrained to the screen.
if (positionSet) {
LoadPositionFromXUL(specWidth, specHeight);
}
LoadMiscPersistentAttributesFromXUL();
- if (mChromeLoaded && mCenterAfterLoad && !positionSet) {
+ if (mChromeLoaded && mCenterAfterLoad && !positionSet &&
+ mWindow->SizeMode() == nsSizeMode_Normal) {
Center(parentWindow, parentWindow ? false : true, false);
}
}
NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow(nsIXULBrowserWindow * *aXULBrowserWindow)
{
NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow);
return NS_OK;