From 38bb755f3ec6d84de0768e2cea606976517d03cf Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 29 Jun 2005 04:17:21 +0000 Subject: [PATCH] Bug 293504. Make MEW/max-width calculations in scrollframes consistent with regular reflow about how we handle the scrollbar width. r+sr=dbaron,a=chofmann git-svn-id: svn://10.0.0.236/trunk@175285 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/generic/nsBlockReflowContext.cpp | 3 +++ mozilla/layout/generic/nsGfxScrollFrame.cpp | 21 +++++++++++++------ mozilla/layout/generic/nsHTMLReflowState.cpp | 18 ++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp index 7993a89adc8..a7fe15dc4db 100644 --- a/mozilla/layout/generic/nsBlockReflowContext.cpp +++ b/mozilla/layout/generic/nsBlockReflowContext.cpp @@ -549,6 +549,9 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace, nscoord oldComputedWidth = aFrameRS.mComputedWidth; aFrameRS.availableWidth = NS_UNCONSTRAINEDSIZE; + // XXX Is this really correct? This means we don't compute the + // correct maximum width if the element's width is determined by + // its 'width' style aFrameRS.mComputedWidth = NS_UNCONSTRAINEDSIZE; rv = mFrame->Reflow(mPresContext, mMetrics, aFrameRS, aFrameReflowStatus); diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 96b606b53c5..af36506467a 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -434,19 +434,28 @@ nsHTMLScrollFrame::TryLayout(ScrollReflowState* aState, // their content box can be squeezed down to 0, as they will either create // a scrollbar so that content of the scrollframe will not leak out or it // will cut the content at the frame boundaries. - aState->mMaxElementWidth = vScrollbarActualWidth + - aState->mReflowState.mComputedPadding.LeftRight() + - aState->mReflowState.AdjustIntrinsicMinContentWidthForStyle(0); + + // The width of the vertical scrollbar comes out of the budget for the + // content width (see above where we include the scrollbar width before + // we call ComputeInsideBorderSize, which overrides the given + // width with the style computed width if there is one). So allow + // the vertical scrollbar width to be overridden by style information + // here, too. + nscoord minContentWidth = + aState->mReflowState.AdjustIntrinsicMinContentWidthForStyle(vScrollbarActualWidth); + aState->mMaxElementWidth = minContentWidth + + aState->mReflowState.mComputedPadding.LeftRight(); // borders get added on the way out of Reflow() } if (aKidMetrics.mFlags & NS_REFLOW_CALC_MAX_WIDTH) { + // We need to do what we did above: include the vertical scrollbar width in the + // content width before applying style. nscoord kidMaxWidth = aKidMetrics.mMaximumWidth; if (kidMaxWidth != NS_UNCONSTRAINEDSIZE) { nscoord kidContentMaxWidth = kidMaxWidth - - aState->mReflowState.mComputedPadding.LeftRight(); + aState->mReflowState.mComputedPadding.LeftRight() + vScrollbarActualWidth; NS_ASSERTION(kidContentMaxWidth >= 0, "max-width didn't include padding?"); - kidMaxWidth = vScrollbarActualWidth + - aState->mReflowState.mComputedPadding.LeftRight() + + kidMaxWidth = aState->mReflowState.mComputedPadding.LeftRight() + aState->mReflowState.AdjustIntrinsicContentWidthForStyle(kidContentMaxWidth); } aState->mMaximumWidth = kidMaxWidth; diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 898904b17ca..6b1054a1fb9 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -386,9 +386,12 @@ nsHTMLReflowState::AdjustIntrinsicMinContentWidthForStyle(nscoord aWidth) const if (eStyleUnit_Percent == widthUnit) { aWidth = 0; } else if (eStyleUnit_Coord == widthUnit) { - NS_ASSERTION(NS_UNCONSTRAINEDSIZE != mComputedWidth, - "Should be a computed width here"); - aWidth = mComputedWidth; + // Sometimes we can get an unconstrained size here because we're + // computing the maximum-width. Although it doesn't seem right + // for max-width computation to change our computed width. + if (NS_UNCONSTRAINEDSIZE != mComputedWidth) { + aWidth = mComputedWidth; + } } nsStyleUnit maxWidthUnit = mStylePosition->mMaxWidth.GetUnit(); @@ -415,9 +418,12 @@ nsHTMLReflowState::AdjustIntrinsicContentWidthForStyle(nscoord aWidth) const { nsStyleUnit widthUnit = mStylePosition->mWidth.GetUnit(); if (eStyleUnit_Coord == widthUnit) { - NS_ASSERTION(NS_UNCONSTRAINEDSIZE != mComputedWidth, - "Should be a computed width here"); - aWidth = mComputedWidth; + // Sometimes we can get an unconstrained size here because we're + // computing the maximum-width. Although it doesn't seem right + // for max-width computation to change our computed width. + if (NS_UNCONSTRAINEDSIZE != mComputedWidth) { + aWidth = mComputedWidth; + } } nsStyleUnit maxWidthUnit = mStylePosition->mMaxWidth.GetUnit();