Don't let the pres context's visible area get permanently set to an unconstrained height when we call ResizeReflow with an unconstrained height during SizeToContent. b=371508 r+sr=roc a=blocking1.9+

This commit is contained in:
dbaron@dbaron.org 2008-03-12 15:04:45 -07:00
Родитель f51b08f359
Коммит f7a428516e
3 изменённых файлов: 19 добавлений и 11 удалений

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

@ -3084,11 +3084,10 @@ 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;
}
// Protect against bogus returns here
NS_ENSURE_TRUE(shellArea.width != NS_UNCONSTRAINEDSIZE &&
shellArea.height != NS_UNCONSTRAINEDSIZE,
NS_ERROR_FAILURE);
width = presContext->AppUnitsToDevPixels(shellArea.width);
height = presContext->AppUnitsToDevPixels(shellArea.height);

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

@ -2489,14 +2489,17 @@ NS_IMETHODIMP
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
{
NS_PRECONDITION(!mIsReflowing, "Shouldn't be in reflow here!");
NS_PRECONDITION(aWidth != NS_UNCONSTRAINEDSIZE,
"shouldn't use unconstrained widths anymore");
// 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)) {
if (!rootFrame && aHeight == NS_UNCONSTRAINEDSIZE) {
// We can't do the work needed for SizeToContent without a root
// frame, and we want to return before setting the visible area.
return NS_ERROR_NOT_AVAILABLE;
}
@ -2542,6 +2545,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
batch.EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
}
if (aHeight == NS_UNCONSTRAINEDSIZE) {
mPresContext->SetVisibleArea(
nsRect(0, 0, aWidth, rootFrame->GetRect().height));
}
if (!mIsDestroying) {
CreateResizeEventTimer();
}

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

@ -262,7 +262,7 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
// Reflow the main content first so that the placeholders of the
// fixed-position frames will be in the right places on an initial
// reflow.
nsRect kidRect(0,0,aReflowState.availableWidth,aReflowState.availableHeight);
nscoord kidHeight = 0;
nsresult rv = NS_OK;
@ -284,10 +284,11 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
kidReflowState.SetComputedHeight(aReflowState.availableHeight);
rv = ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
0, 0, 0, aStatus);
kidRect.width = kidDesiredSize.width;
kidRect.height = kidDesiredSize.height;
kidHeight = kidDesiredSize.height;
FinishReflowChild(kidFrame, aPresContext, nsnull, kidDesiredSize, 0, 0, 0);
} else {
kidHeight = mFrames.FirstChild()->GetSize().height;
}
}
@ -300,7 +301,7 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
// return our child's intrinsic size.
aDesiredSize.height = aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE
? aReflowState.availableHeight
: kidRect.height;
: kidHeight;
// Make a copy of the reflow state and change the computed width and height
// to reflect the available space for the fixed items