Added support for "box-sizing" style property

This commit is contained in:
troy%netscape.com 1999-07-28 03:51:37 +00:00
Родитель 0e85f5c4eb
Коммит 3ee32d5915
3 изменённых файлов: 205 добавлений и 32 удалений

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

@ -490,7 +490,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} else { } else {
// Note that we wait until after checkin minimum and maximum size // Note that we wait until after checking minimum and maximum size
// information, because if we use the minimum or maximum value instead // information, because if we use the minimum or maximum value instead
// then the rules are applied again and that means margin recalculation // then the rules are applied again and that means margin recalculation
leftIsAuto = PR_FALSE; leftIsAuto = PR_FALSE;
@ -515,6 +515,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if (mComputedWidth != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
} }
// Calculate any remaining 'auto' values for the offsets and margins // Calculate any remaining 'auto' values for the offsets and margins
@ -666,6 +676,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
if (mComputedHeight < mComputedMinHeight) { if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_AUTOHEIGHT) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} }
// Calculate any remaining 'auto' values for the offsets and margins // Calculate any remaining 'auto' values for the offsets and margins
@ -811,11 +831,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
nsFrame::ListTag(stdout, cbrs->frame); printf(" size=%d,%d\n", containingBlockWidth, containingBlockHeight); nsFrame::ListTag(stdout, cbrs->frame); printf(" size=%d,%d\n", containingBlockWidth, containingBlockHeight);
#endif #endif
// See if the containing block height is based on the size of the // See if the containing block height is based on the size of its
// content // content
if (NS_AUTOHEIGHT == containingBlockHeight) { if (NS_AUTOHEIGHT == containingBlockHeight) {
// See if the containing block is a scrolled frame, i.e. its // See if the containing block is a scrolled frame, i.e. its
// parent is a scroll frame. The prescence of the interveening // parent is a scroll frame. The presence of the intervening
// frame (that the scroll frame scrolls) needs to be hidden from // frame (that the scroll frame scrolls) needs to be hidden from
// the containingBlockHeight calcuation. // the containingBlockHeight calcuation.
if (cbrs->parentReflowState) { if (cbrs->parentReflowState) {
@ -882,10 +902,22 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mWidth, mStylePosition->mWidth,
mComputedWidth); mComputedWidth);
} }
if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth; if (mComputedWidth != NS_INTRINSICSIZE) {
} else if (mComputedWidth < mComputedMinWidth) { // Take into account minimum and maximum sizes
mComputedWidth = mComputedMinWidth; if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth;
} else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth;
}
// See what edge the width applies to (the default is the content
// edge)
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
} }
// Now calculate the computed height // Now calculate the computed height
@ -899,10 +931,22 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mHeight, mStylePosition->mHeight,
mComputedHeight); mComputedHeight);
} }
if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; if (mComputedHeight != NS_INTRINSICSIZE) {
} else if (mComputedHeight < mComputedMinHeight) { // Take into account minimum and maximum sizes
mComputedHeight = mComputedMinHeight; if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight;
}
// See what edge the height applies to (the default is the content
// edge)
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
} }
} else if (NS_CSS_FRAME_TYPE_FLOATING == mFrameType) { } else if (NS_CSS_FRAME_TYPE_FLOATING == mFrameType) {
@ -917,12 +961,24 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mWidth, mStylePosition->mWidth,
mComputedWidth); mComputedWidth);
} }
// Take into account minimum and maximum sizes
if (mComputedWidth > mComputedMaxWidth) { if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth; mComputedWidth = mComputedMaxWidth;
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if ((mComputedWidth > 0) && (mComputedWidth != NS_UNCONSTRAINEDSIZE)) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
// Now calculate the computed height // Now calculate the computed height
if (eStyleUnit_Inherit == heightUnit) { if (eStyleUnit_Inherit == heightUnit) {
mComputedHeight = containingBlockHeight; mComputedHeight = containingBlockHeight;
@ -933,11 +989,23 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mHeight, mStylePosition->mHeight,
mComputedHeight); mComputedHeight);
} }
// Take into account minimum and maximum sizes
if (mComputedHeight > mComputedMaxHeight) { if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) { } else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_AUTOHEIGHT) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} else if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) { } else if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) {
// Internal table elements. The rules vary depending on the type. // Internal table elements. The rules vary depending on the type.
@ -1031,7 +1099,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
mComputedWidth = NS_INTRINSICSIZE; mComputedWidth = NS_INTRINSICSIZE;
} else { } else {
// Block-level non-replaced element in the flow. 'auto' values // Block-level non-replaced element in the flow. 'auto' values
// for margin-left and margin-right become 0 and the sum of the // for margin-left and margin-right become 0, and the sum of the
// areas must equal the width of the content-area of the parent // areas must equal the width of the content-area of the parent
// element. // element.
if (NS_UNCONSTRAINEDSIZE == availableWidth) { if (NS_UNCONSTRAINEDSIZE == availableWidth) {
@ -1057,11 +1125,11 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
} }
} else { } else {
if (eStyleUnit_Inherit == aWidthUnit) { if (eStyleUnit_Inherit == aWidthUnit) {
// Use parent elements width. Note that if its width was // Use parent element's width. Note that if its width was
// 'inherit', then it already did this so we don't need to // 'inherit', then it already did this so we don't need to
// recurse upwards. // recurse upwards.
// //
// We use the containing blocks width here for the "parent" // We use the containing block's width here for the "parent"
// elements width, because we want to skip over any intervening // elements width, because we want to skip over any intervening
// inline elements (since width doesn't apply to them). // inline elements (since width doesn't apply to them).
if (NS_UNCONSTRAINEDSIZE != aContainingBlockWidth) { if (NS_UNCONSTRAINEDSIZE != aContainingBlockWidth) {
@ -1083,11 +1151,20 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if (mComputedWidth != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
// Now that we have the computed-width, compute the side margins // Now that we have the computed-width, compute the side margins
CalculateBlockSideMargins(cbrs, mComputedWidth); CalculateBlockSideMargins(cbrs, mComputedWidth);
} }
// Compute the content height // Compute the content height
if (eStyleUnit_Inherit == aHeightUnit) { if (eStyleUnit_Inherit == aHeightUnit) {
// Use parent elements height (note that if its height was inherit // Use parent elements height (note that if its height was inherit
@ -1114,11 +1191,21 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
ComputeVerticalValue(aContainingBlockHeight, aHeightUnit, ComputeVerticalValue(aContainingBlockHeight, aHeightUnit,
mStylePosition->mHeight, mComputedHeight); mStylePosition->mHeight, mComputedHeight);
} }
// Take into account any min and max values
if (mComputedHeight > mComputedMaxHeight) { if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) { } else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} }
// This code enforces section 10.3.3 of the CSS2 spec for this formula: // This code enforces section 10.3.3 of the CSS2 spec for this formula:

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

@ -490,7 +490,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} else { } else {
// Note that we wait until after checkin minimum and maximum size // Note that we wait until after checking minimum and maximum size
// information, because if we use the minimum or maximum value instead // information, because if we use the minimum or maximum value instead
// then the rules are applied again and that means margin recalculation // then the rules are applied again and that means margin recalculation
leftIsAuto = PR_FALSE; leftIsAuto = PR_FALSE;
@ -515,6 +515,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if (mComputedWidth != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
} }
// Calculate any remaining 'auto' values for the offsets and margins // Calculate any remaining 'auto' values for the offsets and margins
@ -666,6 +676,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
if (mComputedHeight < mComputedMinHeight) { if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_AUTOHEIGHT) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} }
// Calculate any remaining 'auto' values for the offsets and margins // Calculate any remaining 'auto' values for the offsets and margins
@ -811,11 +831,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
nsFrame::ListTag(stdout, cbrs->frame); printf(" size=%d,%d\n", containingBlockWidth, containingBlockHeight); nsFrame::ListTag(stdout, cbrs->frame); printf(" size=%d,%d\n", containingBlockWidth, containingBlockHeight);
#endif #endif
// See if the containing block height is based on the size of the // See if the containing block height is based on the size of its
// content // content
if (NS_AUTOHEIGHT == containingBlockHeight) { if (NS_AUTOHEIGHT == containingBlockHeight) {
// See if the containing block is a scrolled frame, i.e. its // See if the containing block is a scrolled frame, i.e. its
// parent is a scroll frame. The prescence of the interveening // parent is a scroll frame. The presence of the intervening
// frame (that the scroll frame scrolls) needs to be hidden from // frame (that the scroll frame scrolls) needs to be hidden from
// the containingBlockHeight calcuation. // the containingBlockHeight calcuation.
if (cbrs->parentReflowState) { if (cbrs->parentReflowState) {
@ -882,10 +902,22 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mWidth, mStylePosition->mWidth,
mComputedWidth); mComputedWidth);
} }
if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth; if (mComputedWidth != NS_INTRINSICSIZE) {
} else if (mComputedWidth < mComputedMinWidth) { // Take into account minimum and maximum sizes
mComputedWidth = mComputedMinWidth; if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth;
} else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth;
}
// See what edge the width applies to (the default is the content
// edge)
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
} }
// Now calculate the computed height // Now calculate the computed height
@ -899,10 +931,22 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mHeight, mStylePosition->mHeight,
mComputedHeight); mComputedHeight);
} }
if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; if (mComputedHeight != NS_INTRINSICSIZE) {
} else if (mComputedHeight < mComputedMinHeight) { // Take into account minimum and maximum sizes
mComputedHeight = mComputedMinHeight; if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight;
}
// See what edge the height applies to (the default is the content
// edge)
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
} }
} else if (NS_CSS_FRAME_TYPE_FLOATING == mFrameType) { } else if (NS_CSS_FRAME_TYPE_FLOATING == mFrameType) {
@ -917,12 +961,24 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mWidth, mStylePosition->mWidth,
mComputedWidth); mComputedWidth);
} }
// Take into account minimum and maximum sizes
if (mComputedWidth > mComputedMaxWidth) { if (mComputedWidth > mComputedMaxWidth) {
mComputedWidth = mComputedMaxWidth; mComputedWidth = mComputedMaxWidth;
} else if (mComputedWidth < mComputedMinWidth) { } else if (mComputedWidth < mComputedMinWidth) {
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if ((mComputedWidth > 0) && (mComputedWidth != NS_UNCONSTRAINEDSIZE)) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
// Now calculate the computed height // Now calculate the computed height
if (eStyleUnit_Inherit == heightUnit) { if (eStyleUnit_Inherit == heightUnit) {
mComputedHeight = containingBlockHeight; mComputedHeight = containingBlockHeight;
@ -933,11 +989,23 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
mStylePosition->mHeight, mStylePosition->mHeight,
mComputedHeight); mComputedHeight);
} }
// Take into account minimum and maximum sizes
if (mComputedHeight > mComputedMaxHeight) { if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) { } else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_AUTOHEIGHT) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} else if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) { } else if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) {
// Internal table elements. The rules vary depending on the type. // Internal table elements. The rules vary depending on the type.
@ -1031,7 +1099,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
mComputedWidth = NS_INTRINSICSIZE; mComputedWidth = NS_INTRINSICSIZE;
} else { } else {
// Block-level non-replaced element in the flow. 'auto' values // Block-level non-replaced element in the flow. 'auto' values
// for margin-left and margin-right become 0 and the sum of the // for margin-left and margin-right become 0, and the sum of the
// areas must equal the width of the content-area of the parent // areas must equal the width of the content-area of the parent
// element. // element.
if (NS_UNCONSTRAINEDSIZE == availableWidth) { if (NS_UNCONSTRAINEDSIZE == availableWidth) {
@ -1057,11 +1125,11 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
} }
} else { } else {
if (eStyleUnit_Inherit == aWidthUnit) { if (eStyleUnit_Inherit == aWidthUnit) {
// Use parent elements width. Note that if its width was // Use parent element's width. Note that if its width was
// 'inherit', then it already did this so we don't need to // 'inherit', then it already did this so we don't need to
// recurse upwards. // recurse upwards.
// //
// We use the containing blocks width here for the "parent" // We use the containing block's width here for the "parent"
// elements width, because we want to skip over any intervening // elements width, because we want to skip over any intervening
// inline elements (since width doesn't apply to them). // inline elements (since width doesn't apply to them).
if (NS_UNCONSTRAINEDSIZE != aContainingBlockWidth) { if (NS_UNCONSTRAINEDSIZE != aContainingBlockWidth) {
@ -1083,11 +1151,20 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
mComputedWidth = mComputedMinWidth; mComputedWidth = mComputedMinWidth;
} }
// See what edge the width applies to (the default is the content
// edge)
if (mComputedWidth != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedWidth -= mComputedPadding.left + mComputedPadding.right;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedWidth -= mComputedBorderPadding.left + mComputedBorderPadding.right;
}
}
// Now that we have the computed-width, compute the side margins // Now that we have the computed-width, compute the side margins
CalculateBlockSideMargins(cbrs, mComputedWidth); CalculateBlockSideMargins(cbrs, mComputedWidth);
} }
// Compute the content height // Compute the content height
if (eStyleUnit_Inherit == aHeightUnit) { if (eStyleUnit_Inherit == aHeightUnit) {
// Use parent elements height (note that if its height was inherit // Use parent elements height (note that if its height was inherit
@ -1114,11 +1191,21 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext& aPresContext,
ComputeVerticalValue(aContainingBlockHeight, aHeightUnit, ComputeVerticalValue(aContainingBlockHeight, aHeightUnit,
mStylePosition->mHeight, mComputedHeight); mStylePosition->mHeight, mComputedHeight);
} }
// Take into account any min and max values
if (mComputedHeight > mComputedMaxHeight) { if (mComputedHeight > mComputedMaxHeight) {
mComputedHeight = mComputedMaxHeight; mComputedHeight = mComputedMaxHeight;
} else if (mComputedHeight < mComputedMinHeight) { } else if (mComputedHeight < mComputedMinHeight) {
mComputedHeight = mComputedMinHeight; mComputedHeight = mComputedMinHeight;
} }
// See what edge the height applies to (the default is the content
// edge)
if (mComputedHeight != NS_UNCONSTRAINEDSIZE) {
if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
mComputedHeight -= mComputedPadding.top + mComputedPadding.bottom;
} else if (mStylePosition->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
mComputedHeight -= mComputedBorderPadding.top + mComputedBorderPadding.bottom;
}
}
} }
// This code enforces section 10.3.3 of the CSS2 spec for this formula: // This code enforces section 10.3.3 of the CSS2 spec for this formula:

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

@ -143,8 +143,7 @@ struct nsHTMLReflowState : nsReflowState {
// use your intrinsic width as the computed width // use your intrinsic width as the computed width
// //
// For block-level frames, the computed width is based on the width of the // For block-level frames, the computed width is based on the width of the
// containing block and the margin/border/padding areas and the min/max // containing block, the margin/border/padding areas, and the min/max width
// width
nscoord mComputedWidth; nscoord mComputedWidth;
// The computed height specifies the frame's content height, and it does // The computed height specifies the frame's content height, and it does