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();