diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 0f86bc2e50fc..10d0d20e42c1 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -149,7 +149,9 @@ nsXULWindow::nsXULWindow(PRUint32 aChromeFlags) mPersistentAttributesMask(0), mChromeFlags(aChromeFlags), // best guess till we have a widget - mAppPerDev(nsPresContext::AppUnitsPerCSSPixel()) + mAppPerDev(nsPresContext::AppUnitsPerCSSPixel()), + mIgnoreXULSize(PR_FALSE), + mIgnoreXULPosition(PR_FALSE) { } @@ -573,8 +575,14 @@ NS_IMETHODIMP nsXULWindow::SetPosition(PRInt32 aX, PRInt32 aY) zoom state. this is important when these two states are competing while the window is being opened. but it should probably just always be so. */ mWindow->SetSizeMode(nsSizeMode_Normal); - + NS_ENSURE_SUCCESS(mWindow->Move(aX, aY), NS_ERROR_FAILURE); + if (!mChromeLoaded) { + // If we're called before the chrome is loaded someone obviously wants this + // window at this position. We don't persist this one-time position. + mIgnoreXULPosition = PR_TRUE; + return NS_OK; + } PersistentAttributesDirty(PAD_POSITION); SavePersistentAttributes(); return NS_OK; @@ -595,6 +603,12 @@ NS_IMETHODIMP nsXULWindow::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint) mIntrinsicallySized = PR_FALSE; NS_ENSURE_SUCCESS(mWindow->Resize(aCX, aCY, aRepaint), NS_ERROR_FAILURE); + if (!mChromeLoaded) { + // If we're called before the chrome is loaded someone obviously wants this + // window at this size. We don't persist this one-time size. + mIgnoreXULSize = PR_TRUE; + return NS_OK; + } PersistentAttributesDirty(PAD_SIZE); SavePersistentAttributes(); return NS_OK; @@ -616,6 +630,13 @@ NS_IMETHODIMP nsXULWindow::SetPositionAndSize(PRInt32 aX, PRInt32 aY, mIntrinsicallySized = PR_FALSE; NS_ENSURE_SUCCESS(mWindow->Resize(aX, aY, aCX, aCY, aRepaint), NS_ERROR_FAILURE); + if (!mChromeLoaded) { + // If we're called before the chrome is loaded someone obviously wants this + // window at this size and position. We don't persist this one-time setting. + mIgnoreXULPosition = PR_TRUE; + mIgnoreXULSize = PR_TRUE; + return NS_OK; + } PersistentAttributesDirty(PAD_POSITION | PAD_SIZE); SavePersistentAttributes(); return NS_OK; @@ -978,7 +999,8 @@ void nsXULWindow::OnChromeLoaded() mChromeLoaded = PR_TRUE; ApplyChromeFlags(); SyncAttributesToWidget(); - LoadSizeFromXUL(); + if (!mIgnoreXULSize) + LoadSizeFromXUL(); if (mIntrinsicallySized) { // (if LoadSizeFromXUL set the size, mIntrinsicallySized will be false) nsCOMPtr cv; @@ -988,7 +1010,7 @@ void nsXULWindow::OnChromeLoaded() markupViewer->SizeToContent(); } - PRBool positionSet = PR_TRUE; + PRBool positionSet = !mIgnoreXULPosition; nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); #if defined(XP_UNIX) && !defined(XP_MACOSX) // don't override WM placement on unix for independent, top-level windows diff --git a/xpfe/appshell/src/nsXULWindow.h b/xpfe/appshell/src/nsXULWindow.h index 55a724fec3a3..126df3f4cadd 100644 --- a/xpfe/appshell/src/nsXULWindow.h +++ b/xpfe/appshell/src/nsXULWindow.h @@ -169,6 +169,8 @@ protected: PRPackedBool mCenterAfterLoad; PRPackedBool mIsHiddenWindow; PRPackedBool mLockedUntilChromeLoad; + PRPackedBool mIgnoreXULSize; + PRPackedBool mIgnoreXULPosition; PRUint32 mContextFlags; PRUint32 mBlurSuppressionLevel; PRUint32 mPersistentAttributesDirty; // persistentAttributes