diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index 40a52f426891..936eb751ffd9 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -169,8 +169,6 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin if (isAbsoluteChild) { nsIReflowCommand::ReflowType type; - nsIFrame* newFrames; - PRInt32 numFrames = 0; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); @@ -187,7 +185,7 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin if (frameState & NS_FRAME_IS_DIRTY) { nsReflowStatus status; ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState, - newFrames, PR_TRUE, status); + f, PR_TRUE, status); } } @@ -263,8 +261,21 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat rv = htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus); // Because we don't know the size of a replaced element until after we reflow - // it 'auto' margins must be computed now + // it 'auto' margins must be computed now, and we need to take into account + // min-max information if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) { + // Factor in any minimum and maximum size information + if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) { + kidDesiredSize.width = kidReflowState.mComputedMaxWidth; + } else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) { + kidDesiredSize.width = kidReflowState.mComputedMinWidth; + } + if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) { + kidDesiredSize.height = kidReflowState.mComputedMaxHeight; + } else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) { + kidDesiredSize.height = kidReflowState.mComputedMinHeight; + } + // Get the containing block width/height nscoord containingBlockWidth, containingBlockHeight; kidReflowState.ComputeContainingBlockRectangle(&aReflowState, diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 3adf6fbef4b0..4302905f981a 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -479,22 +479,25 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, } else { // Any remaining 'auto' values for 'left', 'right', 'margin-left', or // 'margin-right' are replaced with 0 (their default value) - leftIsAuto = PR_FALSE; - rightIsAuto = PR_FALSE; - marginLeftIsAuto = PR_FALSE; - marginRightIsAuto = PR_FALSE; - mComputedWidth = containingBlockWidth - mComputedOffsets.left - mComputedMargin.left - mComputedBorderPadding.left - mComputedBorderPadding.right - mComputedMargin.right - mComputedOffsets.right; - } - // Factor in any minimum and maximum size information - if (mComputedWidth > mComputedMaxWidth) { - mComputedWidth = mComputedMaxWidth; - } else if (mComputedWidth < mComputedMinWidth) { - mComputedWidth = mComputedMinWidth; + // Factor in any minimum and maximum size information + if (mComputedWidth > mComputedMaxWidth) { + mComputedWidth = mComputedMaxWidth; + } else if (mComputedWidth < mComputedMinWidth) { + mComputedWidth = mComputedMinWidth; + } else { + // Note that we wait until after checkin minimum and maximum size + // information, because if we use the minimum or maximum value instead + // then the rules are applied again and that means margin recalculation + leftIsAuto = PR_FALSE; + rightIsAuto = PR_FALSE; + marginLeftIsAuto = PR_FALSE; + marginRightIsAuto = PR_FALSE; + } } } else { @@ -505,7 +508,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, ComputeHorizontalValue(containingBlockWidth, widthUnit, mStylePosition->mWidth, mComputedWidth); } - + // Factor in any minimum and maximum size information if (mComputedWidth > mComputedMaxWidth) { mComputedWidth = mComputedMaxWidth; @@ -617,14 +620,6 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, if (NS_FRAME_IS_REPLACED(mFrameType)) { mComputedHeight = NS_INTRINSICSIZE; } else { - // Replace any 'auto' on 'margin-top' or 'margin-bottom' with 0 (their - // default values) - marginTopIsAuto = PR_FALSE; - marginBottomIsAuto = PR_FALSE; - - // If 'bottom' is 'auto', then replace it with '0' (its default value), too - bottomIsAuto = PR_FALSE; - // Solve for the value of 'height' if (NS_AUTOHEIGHT == containingBlockHeight) { // If the containing block's height was not explicitly specified (i.e., @@ -632,6 +627,9 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, mComputedHeight = NS_AUTOHEIGHT; } else { + // Replace any 'auto' on 'margin-top' or 'margin-bottom' with 0 (their + // default values). If 'bottom' is 'auto', then replace it with '0' (its + // default value), too mComputedHeight = containingBlockHeight - mComputedOffsets.top - mComputedMargin.top - mComputedBorderPadding.top - mComputedBorderPadding.bottom - @@ -642,6 +640,13 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, mComputedHeight = mComputedMaxHeight; } else if (mComputedHeight < mComputedMinHeight) { mComputedHeight = mComputedMinHeight; + } else { + // Note that we wait until after checkin minimum and maximum size + // information, because if we use the minimum or maximum value instead + // then the rules are applied again and that means margin recalculation + marginTopIsAuto = PR_FALSE; + marginBottomIsAuto = PR_FALSE; + bottomIsAuto = PR_FALSE; } } } diff --git a/layout/html/base/src/nsAbsoluteContainingBlock.cpp b/layout/html/base/src/nsAbsoluteContainingBlock.cpp index 40a52f426891..936eb751ffd9 100644 --- a/layout/html/base/src/nsAbsoluteContainingBlock.cpp +++ b/layout/html/base/src/nsAbsoluteContainingBlock.cpp @@ -169,8 +169,6 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin if (isAbsoluteChild) { nsIReflowCommand::ReflowType type; - nsIFrame* newFrames; - PRInt32 numFrames = 0; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); @@ -187,7 +185,7 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin if (frameState & NS_FRAME_IS_DIRTY) { nsReflowStatus status; ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState, - newFrames, PR_TRUE, status); + f, PR_TRUE, status); } } @@ -263,8 +261,21 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat rv = htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus); // Because we don't know the size of a replaced element until after we reflow - // it 'auto' margins must be computed now + // it 'auto' margins must be computed now, and we need to take into account + // min-max information if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) { + // Factor in any minimum and maximum size information + if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) { + kidDesiredSize.width = kidReflowState.mComputedMaxWidth; + } else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) { + kidDesiredSize.width = kidReflowState.mComputedMinWidth; + } + if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) { + kidDesiredSize.height = kidReflowState.mComputedMaxHeight; + } else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) { + kidDesiredSize.height = kidReflowState.mComputedMinHeight; + } + // Get the containing block width/height nscoord containingBlockWidth, containingBlockHeight; kidReflowState.ComputeContainingBlockRectangle(&aReflowState, diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp index 3adf6fbef4b0..4302905f981a 100644 --- a/layout/html/base/src/nsHTMLReflowState.cpp +++ b/layout/html/base/src/nsHTMLReflowState.cpp @@ -479,22 +479,25 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, } else { // Any remaining 'auto' values for 'left', 'right', 'margin-left', or // 'margin-right' are replaced with 0 (their default value) - leftIsAuto = PR_FALSE; - rightIsAuto = PR_FALSE; - marginLeftIsAuto = PR_FALSE; - marginRightIsAuto = PR_FALSE; - mComputedWidth = containingBlockWidth - mComputedOffsets.left - mComputedMargin.left - mComputedBorderPadding.left - mComputedBorderPadding.right - mComputedMargin.right - mComputedOffsets.right; - } - // Factor in any minimum and maximum size information - if (mComputedWidth > mComputedMaxWidth) { - mComputedWidth = mComputedMaxWidth; - } else if (mComputedWidth < mComputedMinWidth) { - mComputedWidth = mComputedMinWidth; + // Factor in any minimum and maximum size information + if (mComputedWidth > mComputedMaxWidth) { + mComputedWidth = mComputedMaxWidth; + } else if (mComputedWidth < mComputedMinWidth) { + mComputedWidth = mComputedMinWidth; + } else { + // Note that we wait until after checkin minimum and maximum size + // information, because if we use the minimum or maximum value instead + // then the rules are applied again and that means margin recalculation + leftIsAuto = PR_FALSE; + rightIsAuto = PR_FALSE; + marginLeftIsAuto = PR_FALSE; + marginRightIsAuto = PR_FALSE; + } } } else { @@ -505,7 +508,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, ComputeHorizontalValue(containingBlockWidth, widthUnit, mStylePosition->mWidth, mComputedWidth); } - + // Factor in any minimum and maximum size information if (mComputedWidth > mComputedMaxWidth) { mComputedWidth = mComputedMaxWidth; @@ -617,14 +620,6 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, if (NS_FRAME_IS_REPLACED(mFrameType)) { mComputedHeight = NS_INTRINSICSIZE; } else { - // Replace any 'auto' on 'margin-top' or 'margin-bottom' with 0 (their - // default values) - marginTopIsAuto = PR_FALSE; - marginBottomIsAuto = PR_FALSE; - - // If 'bottom' is 'auto', then replace it with '0' (its default value), too - bottomIsAuto = PR_FALSE; - // Solve for the value of 'height' if (NS_AUTOHEIGHT == containingBlockHeight) { // If the containing block's height was not explicitly specified (i.e., @@ -632,6 +627,9 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, mComputedHeight = NS_AUTOHEIGHT; } else { + // Replace any 'auto' on 'margin-top' or 'margin-bottom' with 0 (their + // default values). If 'bottom' is 'auto', then replace it with '0' (its + // default value), too mComputedHeight = containingBlockHeight - mComputedOffsets.top - mComputedMargin.top - mComputedBorderPadding.top - mComputedBorderPadding.bottom - @@ -642,6 +640,13 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext, mComputedHeight = mComputedMaxHeight; } else if (mComputedHeight < mComputedMinHeight) { mComputedHeight = mComputedMinHeight; + } else { + // Note that we wait until after checkin minimum and maximum size + // information, because if we use the minimum or maximum value instead + // then the rules are applied again and that means margin recalculation + marginTopIsAuto = PR_FALSE; + marginBottomIsAuto = PR_FALSE; + bottomIsAuto = PR_FALSE; } } }