Stop reflowing the viewport with constrained height. (Bug 467881) r+sr=roc

This commit is contained in:
L. David Baron 2009-01-29 12:39:22 -08:00
parent c3eeb84be5
commit a1538274bb
4 changed files with 18 additions and 22 deletions

View File

@ -6582,12 +6582,7 @@ PresShell::DoReflow(nsIFrame* target)
// Don't pass size directly to the reflow state, since a
// constrained height implies page/column breaking.
// Exception: the root frame always uses a constrained reflow
nsSize reflowSize;
if (target != rootFrame)
reflowSize = nsSize(size.width, NS_UNCONSTRAINEDSIZE);
else
reflowSize = size;
nsSize reflowSize(size.width, NS_UNCONSTRAINEDSIZE);
nsHTMLReflowState reflowState(mPresContext, target, rcx, reflowSize);
// fix the computed height

View File

@ -239,14 +239,10 @@ void
nsHTMLReflowState::SetComputedHeight(nscoord aComputedHeight)
{
NS_ASSERTION(frame, "Must have a frame!");
// It'd be nice to assert that |frame| is not in reflow, but this fails for
// two reasons:
// It'd be nice to assert that |frame| is not in reflow, but this fails
// because:
//
// 1) Viewport frames reset the computed height on a copy of their reflow
// state when reflowing fixed-pos kids. In that case we actually don't
// want to mess with the resize flags, because comparing the frame's rect
// to the munged computed width is pointless.
// 2) nsFrame::BoxReflow creates a reflow state for its parent. This reflow
// nsFrame::BoxReflow creates a reflow state for its parent. This reflow
// state is not used to reflow the parent, but just as a parent for the
// frame's own reflow state. So given a nsBoxFrame inside some non-XUL
// (like a text control, for example), we'll end up creating a reflow
@ -255,9 +251,7 @@ nsHTMLReflowState::SetComputedHeight(nscoord aComputedHeight)
NS_PRECONDITION(aComputedHeight >= 0, "Invalid computed height");
if (mComputedHeight != aComputedHeight) {
mComputedHeight = aComputedHeight;
if (frame->GetType() != nsGkAtoms::viewportFrame) { // Or check GetParent()?
InitResizeFlags(frame->PresContext());
}
InitResizeFlags(frame->PresContext());
}
}

View File

@ -445,6 +445,14 @@ public:
// This method doesn't apply min/max computed heights to the value passed in.
void SetComputedHeight(nscoord aComputedHeight);
void SetComputedHeightWithoutResettingResizeFlags(nscoord aComputedHeight) {
// Viewport frames reset the computed height on a copy of their reflow
// state when reflowing fixed-pos kids. In that case we actually don't
// want to mess with the resize flags, because comparing the frame's rect
// to the munged computed width is pointless.
mComputedHeight = aComputedHeight;
}
void SetTruncated(const nsHTMLReflowMetrics& aMetrics, nsReflowStatus* aStatus) const;
PRBool WillReflowAgainForClearance() const {

View File

@ -231,9 +231,8 @@ ViewportFrame::AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) c
aReflowState->SetComputedWidth(aReflowState->ComputedWidth() -
scrollbars.LeftRight());
aReflowState->availableWidth -= scrollbars.LeftRight();
aReflowState->SetComputedHeight(aReflowState->ComputedHeight() -
scrollbars.TopBottom());
// XXX why don't we also adjust "aReflowState->availableHeight"?
aReflowState->SetComputedHeightWithoutResettingResizeFlags(
aReflowState->ComputedHeight() - scrollbars.TopBottom());
return nsPoint(scrollbars.left, scrollbars.top);
}
return nsPoint(0, 0);
@ -278,7 +277,7 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
kidFrame, availableSpace);
// Reflow the frame
kidReflowState.SetComputedHeight(aReflowState.availableHeight);
kidReflowState.SetComputedHeight(aReflowState.ComputedHeight());
rv = ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
0, 0, 0, aStatus);
kidHeight = kidDesiredSize.height;
@ -296,8 +295,8 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.width = aReflowState.availableWidth;
// Being flowed initially at an unconstrained height means we should
// return our child's intrinsic size.
aDesiredSize.height = aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE
? aReflowState.availableHeight
aDesiredSize.height = aReflowState.ComputedHeight() != NS_UNCONSTRAINEDSIZE
? aReflowState.ComputedHeight()
: kidHeight;
// Make a copy of the reflow state and change the computed width and height