Bug 482687. Remember the appunits-per-devpixel ratio and use it if the window is gone, instead of crashing. r+sr=roc

This commit is contained in:
Zack Weinberg 2009-03-24 13:55:32 +13:00
Родитель 11f2858a67
Коммит 6e8b27bc7b
2 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -146,7 +146,9 @@ nsXULWindow::nsXULWindow()
mBlurSuppressionLevel(0),
mPersistentAttributesDirty(0),
mPersistentAttributesMask(0),
mChromeFlags(nsIWebBrowserChrome::CHROME_ALL)
mChromeFlags(nsIWebBrowserChrome::CHROME_ALL),
// best guess till we have a widget
mAppPerDev(nsPresContext::AppUnitsPerCSSPixel())
{
}
@ -1053,7 +1055,7 @@ PRBool nsXULWindow::LoadPositionFromXUL()
PRInt32 specX = currX;
PRInt32 specY = currY;
nsAutoString posString;
PRInt32 appPerDev = mWindow->GetDeviceContext()->AppUnitsPerDevPixel();
PRInt32 appPerDev = AppUnitsPerDevPixel();
rv = windowElement->GetAttribute(NS_LITERAL_STRING("screenX"), posString);
if (NS_SUCCEEDED(rv)) {
@ -1120,7 +1122,7 @@ PRBool nsXULWindow::LoadSizeFromXUL()
PRInt32 specWidth = currWidth;
PRInt32 specHeight = currHeight;
nsAutoString sizeString;
PRInt32 appPerDev = mWindow->GetDeviceContext()->AppUnitsPerDevPixel();
PRInt32 appPerDev = AppUnitsPerDevPixel();
rv = windowElement->GetAttribute(NS_LITERAL_STRING("width"), sizeString);
if (NS_SUCCEEDED(rv)) {
@ -1463,7 +1465,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
nsAutoString sizeString;
nsAutoString windowElementId;
nsCOMPtr<nsIDOMXULDocument> ownerXULDoc;
PRInt32 appPerDev = mWindow->GetDeviceContext()->AppUnitsPerDevPixel();
PRInt32 appPerDev = AppUnitsPerDevPixel();
{ // fetch docShellElement's ID and XUL owner document
nsCOMPtr<nsIDOMDocument> ownerDoc;
@ -2130,6 +2132,17 @@ NS_IMETHODIMP nsXULWindow::SetXULBrowserWindow(nsIXULBrowserWindow * aXULBrowser
// nsXULWindow: Accessors
//*****************************************************************************
PRInt32 nsXULWindow::AppUnitsPerDevPixel()
{
if (mWindow && mWindow->GetDeviceContext()) {
mAppPerDev = mWindow->GetDeviceContext()->AppUnitsPerDevPixel();
} else {
NS_ERROR("nsXULWindow::AppUnitsPerDevPixel called with no window "
"or no dev context");
}
return mAppPerDev;
}
//*****************************************************************************
//*** nsContentShellInfo: Object Management
//*****************************************************************************

Просмотреть файл

@ -150,6 +150,7 @@ protected:
void SetContentScrollbarVisibility(PRBool aVisible);
PRBool GetContentScrollbarVisibility();
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
PRInt32 AppUnitsPerDevPixel();
nsChromeTreeOwner* mChromeTreeOwner;
nsContentTreeOwner* mContentTreeOwner;
@ -177,6 +178,8 @@ protected:
PRUint32 mPersistentAttributesDirty; // persistentAttributes
PRUint32 mPersistentAttributesMask;
PRUint32 mChromeFlags;
PRUint32 mAppPerDev; // sometimes needed when we can't get
// it from the widget
nsString mTitle;
nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only