diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index db162814d9a..67c6fe9798a 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -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 diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index af50f019ab0..28635977f8b 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -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()); } } diff --git a/layout/generic/nsHTMLReflowState.h b/layout/generic/nsHTMLReflowState.h index 19e7ba2f42e..016f81b8017 100644 --- a/layout/generic/nsHTMLReflowState.h +++ b/layout/generic/nsHTMLReflowState.h @@ -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 { diff --git a/layout/generic/nsViewportFrame.cpp b/layout/generic/nsViewportFrame.cpp index a53409f8b66..3b9922f6abc 100644 --- a/layout/generic/nsViewportFrame.cpp +++ b/layout/generic/nsViewportFrame.cpp @@ -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