Fix percentage heights on auto-width floats. Bug 216303, r+sr=dbaron

This commit is contained in:
bzbarsky%mit.edu 2005-01-24 23:38:11 +00:00
Родитель 9b52d61dc2
Коммит 14d73e6a25
2 изменённых файлов: 8 добавлений и 33 удалений

Просмотреть файл

@ -5420,31 +5420,6 @@ nsBlockFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
////////////////////////////////////////////////////////////////////////
// Float support
static void InitReflowStateForFloat(nsHTMLReflowState* aState, nsPresContext* aPresContext)
{
/* We build a different reflow context based on the width attribute of the block
* when it's a float.
* Auto-width floats need to have their containing-block size set explicitly.
* factoring in other floats that impact it.
* It's possible this should be quirks-only.
*/
// XXXldb We should really fix this in nsHTMLReflowState::InitConstraints instead.
const nsStylePosition* position = aState->frame->GetStylePosition();
nsStyleUnit widthUnit = position->mWidth.GetUnit();
if (eStyleUnit_Auto == widthUnit) {
// Initialize the reflow state and constrain the containing block's
// width and height to the available width and height.
aState->Init(aPresContext, aState->availableWidth, aState->availableHeight);
} else {
// Initialize the reflow state and use the containing block's
// computed width and height (or derive appropriate values for an
// absolutely positioned frame).
aState->Init(aPresContext);
}
}
nsresult
nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
nsPlaceholderFrame* aPlaceholder,
@ -5519,9 +5494,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState,
floatFrame,
nsSize(availSpace.width, availSpace.height),
aState.mReflowState.reason, PR_FALSE);
InitReflowStateForFloat(&floatRS, aState.mPresContext);
aState.mReflowState.reason);
// Setup a block reflow state to reflow the float.
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowState,
@ -5583,9 +5556,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
nsHTMLReflowState redoFloatRS(aState.mPresContext, aState.mReflowState,
floatFrame,
nsSize(availSpace.width, availSpace.height),
aState.mReflowState.reason, PR_FALSE);
InitReflowStateForFloat(&redoFloatRS, aState.mPresContext);
aState.mReflowState.reason);
clearanceFrame = nsnull;
do {

Просмотреть файл

@ -1846,6 +1846,8 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
mComputedWidth = NS_SHRINKWRAPWIDTH;
} else {
NS_ASSERTION(eStyleUnit_Auto == mStylePosition->mWidth.GetUnit(),
"How did we get here?");
// The CSS2 spec says the computed width should be 0; however, that's
// not what Nav and IE do and even the spec doesn't really want that
// to happen.
@ -1853,8 +1855,10 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
// Instead, have the element shrink wrap its width
mComputedWidth = NS_SHRINKWRAPWIDTH;
// Limnit the width to the containing block width
nscoord widthFromCB = aContainingBlockWidth;
// Limit the width to the available width. This factors in
// other floats that impact this float.
// XXX It's possible that this should be quirks-only. Probable, in fact.
nscoord widthFromCB = availableWidth;
if (NS_UNCONSTRAINEDSIZE != widthFromCB) {
widthFromCB -= mComputedBorderPadding.left + mComputedBorderPadding.right +
mComputedMargin.left + mComputedMargin.right;