From d29734ba6f68c84132ffe4612ed502187750e87a Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Mon, 23 Feb 2009 03:22:00 +0000 Subject: [PATCH] Stop reflowing the viewport with constrained height. (Bug 467881) r+sr=roc a1.9.0.8=dveditz git-svn-id: svn://10.0.0.236/trunk@256292 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 7 +------ mozilla/layout/generic/nsHTMLReflowState.cpp | 14 ++++---------- mozilla/layout/generic/nsHTMLReflowState.h | 8 ++++++++ mozilla/layout/generic/nsViewportFrame.cpp | 11 +++++------ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index bdb6b1933d7..366aa039a8a 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -6200,12 +6200,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/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 1ea4a7e512b..01fe240f8ca 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -261,14 +261,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 @@ -277,9 +273,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/mozilla/layout/generic/nsHTMLReflowState.h b/mozilla/layout/generic/nsHTMLReflowState.h index 2c560b9de78..9973a09ce2e 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.h +++ b/mozilla/layout/generic/nsHTMLReflowState.h @@ -468,6 +468,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/mozilla/layout/generic/nsViewportFrame.cpp b/mozilla/layout/generic/nsViewportFrame.cpp index 0275a1695e4..401ff4c1bbe 100644 --- a/mozilla/layout/generic/nsViewportFrame.cpp +++ b/mozilla/layout/generic/nsViewportFrame.cpp @@ -234,9 +234,8 @@ nsPoint 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); @@ -281,7 +280,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; @@ -299,8 +298,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