Protect against sizeToContent being called on windows with no content a bit.

Bug 293781, r+sr=roc, a=asa
This commit is contained in:
bzbarsky%mit.edu 2005-05-13 19:47:38 +00:00
parent 620102c0b8
commit 689b3ce693
2 changed files with 15 additions and 3 deletions

View File

@ -2901,6 +2901,11 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
// so how big is it?
nsRect shellArea = presContext->GetVisibleArea();
if (shellArea.width == NS_UNCONSTRAINEDSIZE ||
shellArea.height == NS_UNCONSTRAINEDSIZE) {
// Protect against bogus returns here
return NS_ERROR_FAILURE;
}
pixelScale = presContext->TwipsToPixels();
width = PRInt32((float)shellArea.width*pixelScale);
height = PRInt32((float)shellArea.height*pixelScale);

View File

@ -2958,14 +2958,21 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
if (mCaret)
mCaret->EraseCaret();
// If we don't have a root frame yet, that means we haven't had our initial
// reflow... If that's the case, and aWidth or aHeight is unconstrained,
// ignore them altogether.
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame &&
(aWidth == NS_UNCONSTRAINEDSIZE || aHeight == NS_UNCONSTRAINEDSIZE)) {
return NS_ERROR_NOT_AVAILABLE;
}
if (mPresContext) {
nsRect r(0, 0, aWidth, aHeight);
mPresContext->SetVisibleArea(r);
}
// If we don't have a root frame yet, that means we haven't had our initial
// reflow...
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
// Kick off a top-down reflow
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,