Fixing bug 400204. Make window.innerWidth n' friends not throw when accessed on a non-displayed window. r+sr+a=jonas@sicking.cc

This commit is contained in:
jst@mozilla.org 2007-11-11 21:55:22 -08:00
Родитель dc71994164
Коммит a90d100e1d
1 изменённых файлов: 31 добавлений и 25 удалений

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

@ -2915,10 +2915,11 @@ nsGlobalWindow::GetInnerWidth(PRInt32* aInnerWidth)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
*aInnerWidth = nsPresContext::AppUnitsToIntCSSPixels(
presContext->DevPixelsToAppUnits(width));
if (presContext) {
*aInnerWidth = nsPresContext::
AppUnitsToIntCSSPixels(presContext->DevPixelsToAppUnits(width));
}
return NS_OK;
}
@ -2951,8 +2952,8 @@ nsGlobalWindow::SetInnerWidth(PRInt32 aInnerWidth)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
if (presContext) {
PRInt32 width;
width = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerWidth));
@ -2963,6 +2964,8 @@ nsGlobalWindow::SetInnerWidth(PRInt32 aInnerWidth)
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);
}
return NS_OK;
}
@ -2985,10 +2988,11 @@ nsGlobalWindow::GetInnerHeight(PRInt32* aInnerHeight)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
*aInnerHeight = nsPresContext::AppUnitsToIntCSSPixels(
presContext->DevPixelsToAppUnits(height));
if (presContext) {
*aInnerHeight = nsPresContext::
AppUnitsToIntCSSPixels(presContext->DevPixelsToAppUnits(height));
}
return NS_OK;
}
@ -3021,8 +3025,8 @@ nsGlobalWindow::SetInnerHeight(PRInt32 aInnerHeight)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
if (presContext) {
PRInt32 height;
height = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerHeight));
@ -3033,6 +3037,8 @@ nsGlobalWindow::SetInnerHeight(PRInt32 aInnerHeight)
NS_ENSURE_SUCCESS(treeOwner->
SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);
}
return NS_OK;
}