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,18 +2952,20 @@ nsGlobalWindow::SetInnerWidth(PRInt32 aInnerWidth)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
PRInt32 width;
width = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerWidth));
if (presContext) {
PRInt32 width;
width = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerWidth));
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
PRInt32 notused, height = 0;
docShellAsWin->GetSize(&notused, &height);
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
PRInt32 notused, height = 0;
docShellAsWin->GetSize(&notused, &height);
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);
}
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,18 +3025,20 @@ nsGlobalWindow::SetInnerHeight(PRInt32 aInnerHeight)
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
PRInt32 height;
height = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerHeight));
if (presContext) {
PRInt32 height;
height = presContext->AppUnitsToDevPixels(
nsPresContext::CSSPixelsToAppUnits(aInnerHeight));
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
PRInt32 width = 0, notused;
docShellAsWin->GetSize(&width, &notused);
NS_ENSURE_SUCCESS(treeOwner->
SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);
}
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
PRInt32 width = 0, notused;
docShellAsWin->GetSize(&width, &notused);
NS_ENSURE_SUCCESS(treeOwner->
SizeShellTo(docShellAsItem, width, height),
NS_ERROR_FAILURE);
return NS_OK;
}