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
This commit is contained in:
roc+%cs.cmu.edu
2005-06-29 04:17:21 +00:00
parent 4a29541c83
commit 38bb755f3e
3 changed files with 30 additions and 12 deletions

View File

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

View File

@@ -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;

View File

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