Chromium Code Reviews| Index: Source/core/layout/LayoutBox.cpp |
| diff --git a/Source/core/layout/LayoutBox.cpp b/Source/core/layout/LayoutBox.cpp |
| index 03fb2f6bc1acc1c79604c38c38a190b4fe27416d..f194377ec53015e5dfa9a26142aaa45384c3d831 100644 |
| --- a/Source/core/layout/LayoutBox.cpp |
| +++ b/Source/core/layout/LayoutBox.cpp |
| @@ -588,22 +588,22 @@ LayoutUnit LayoutBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L |
| { |
| const ComputedStyle& styleToUse = styleRef(); |
| if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
| - LayoutUnit maxH = computeLogicalHeightUsing(styleToUse.logicalMaxHeight(), intrinsicContentHeight); |
| + LayoutUnit maxH = computeLogicalHeightUsing(MaxSize, styleToUse.logicalMaxHeight(), intrinsicContentHeight); |
| if (maxH != -1) |
| logicalHeight = std::min(logicalHeight, maxH); |
| } |
| - return std::max(logicalHeight, computeLogicalHeightUsing(styleToUse.logicalMinHeight(), intrinsicContentHeight)); |
| + return std::max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); |
| } |
| LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight, LayoutUnit intrinsicContentHeight) const |
| { |
| const ComputedStyle& styleToUse = styleRef(); |
| if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
| - LayoutUnit maxH = computeContentLogicalHeight(styleToUse.logicalMaxHeight(), intrinsicContentHeight); |
| + LayoutUnit maxH = computeContentLogicalHeight(MaxSize, styleToUse.logicalMaxHeight(), intrinsicContentHeight); |
| if (maxH != -1) |
| logicalHeight = std::min(logicalHeight, maxH); |
| } |
| - return std::max(logicalHeight, computeContentLogicalHeight(styleToUse.logicalMinHeight(), intrinsicContentHeight)); |
| + return std::max(logicalHeight, computeContentLogicalHeight(MinSize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); |
| } |
| void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint& location) |
| @@ -2081,6 +2081,10 @@ LayoutUnit LayoutBox::computeIntrinsicLogicalWidthUsing(const Length& logicalWid |
| LayoutUnit LayoutBox::computeLogicalWidthUsing(SizeType widthType, const Length& logicalWidth, LayoutUnit availableLogicalWidth, const LayoutBlock* cb) const |
| { |
| + if (widthType == MinSize && logicalWidth.isAuto()) { |
|
leviw_travelin_and_unemployed
2015/04/02 22:14:36
Nit: no braces necessary.
cbiesinger
2015/04/03 18:49:17
Done.
|
| + return adjustBorderBoxLogicalWidthForBoxSizing(0); |
| + } |
| + |
| if (!logicalWidth.isIntrinsicOrAuto()) { |
| // FIXME: If the containing block flow is perpendicular to our direction we need to use the available logical height instead. |
| return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWidth, availableLogicalWidth)); |
| @@ -2331,7 +2335,7 @@ void LayoutBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica |
| LayoutUnit heightResult; |
| if (checkMinMaxHeight) { |
| - heightResult = computeLogicalHeightUsing(style()->logicalHeight(), computedValues.m_extent - borderAndPaddingLogicalHeight()); |
| + heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight(), computedValues.m_extent - borderAndPaddingLogicalHeight()); |
| if (heightResult == -1) |
| heightResult = computedValues.m_extent; |
| heightResult = constrainLogicalHeightByMinMax(heightResult, computedValues.m_extent - borderAndPaddingLogicalHeight()); |
| @@ -2367,17 +2371,17 @@ void LayoutBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica |
| } |
| } |
| -LayoutUnit LayoutBox::computeLogicalHeightUsing(const Length& height, LayoutUnit intrinsicContentHeight) const |
| +LayoutUnit LayoutBox::computeLogicalHeightUsing(SizeType heightType, const Length& height, LayoutUnit intrinsicContentHeight) const |
| { |
| - LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(height, intrinsicContentHeight); |
| + LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heightType, height, intrinsicContentHeight); |
| if (logicalHeight != -1) |
| logicalHeight = adjustBorderBoxLogicalHeightForBoxSizing(logicalHeight); |
| return logicalHeight; |
| } |
| -LayoutUnit LayoutBox::computeContentLogicalHeight(const Length& height, LayoutUnit intrinsicContentHeight) const |
| +LayoutUnit LayoutBox::computeContentLogicalHeight(SizeType heightType, const Length& height, LayoutUnit intrinsicContentHeight) const |
| { |
| - LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(height, intrinsicContentHeight); |
| + LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(heightType, height, intrinsicContentHeight); |
| if (heightIncludingScrollbar == -1) |
| return -1; |
| return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heightIncludingScrollbar) - scrollbarLogicalHeight()); |
| @@ -2400,8 +2404,10 @@ LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo |
| return 0; |
| } |
| -LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(const Length& height, LayoutUnit intrinsicContentHeight) const |
| +LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heightType, const Length& height, LayoutUnit intrinsicContentHeight) const |
| { |
| + if (height.isAuto()) |
| + return heightType == MinSize ? 0 : -1; |
| // FIXME(cbiesinger): The css-sizing spec is considering changing what min-content/max-content should resolve to. |
| // If that happens, this code will have to change. |
| if (height.isIntrinsic()) { |
| @@ -2533,18 +2539,21 @@ LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const |
| LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const |
| { |
| - return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred); |
| + return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferred); |
| } |
| LayoutUnit LayoutBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred shouldComputePreferred) const |
| { |
| - LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMinWidth().isPercent()) || style()->logicalMinWidth().isMaxSizeNone() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); |
| - LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMaxWidth().isPercent()) || style()->logicalMaxWidth().isMaxSizeNone() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); |
| + LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMinWidth().isPercent()) || style()->logicalMinWidth().isMaxSizeNone() ? logicalWidth : computeReplacedLogicalWidthUsing(MinSize, style()->logicalMinWidth()); |
| + LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMaxWidth().isPercent()) || style()->logicalMaxWidth().isMaxSizeNone() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style()->logicalMaxWidth()); |
| return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth)); |
| } |
| -LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(const Length& logicalWidth) const |
| +LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(SizeType sizeType, const Length& logicalWidth) const |
| { |
| + if (sizeType == MinSize && logicalWidth.isAuto()) |
| + return adjustContentBoxLogicalWidthForBoxSizing(0); |
| + |
| switch (logicalWidth.type()) { |
| case Fixed: |
| return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()); |
| @@ -2588,7 +2597,7 @@ LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(const Length& logicalWidt |
| LayoutUnit LayoutBox::computeReplacedLogicalHeight() const |
| { |
| - return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight())); |
| + return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); |
| } |
| bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const |
| @@ -2611,15 +2620,18 @@ LayoutUnit LayoutBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU |
| // the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height'). |
| LayoutUnit minLogicalHeight; |
| if (!logicalHeightComputesAsNone(MinSize)) |
| - minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); |
| + minLogicalHeight = computeReplacedLogicalHeightUsing(MinSize, style()->logicalMinHeight()); |
| LayoutUnit maxLogicalHeight = logicalHeight; |
| if (!logicalHeightComputesAsNone(MaxSize)) |
| - maxLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); |
| + maxLogicalHeight = computeReplacedLogicalHeightUsing(MaxSize, style()->logicalMaxHeight()); |
| return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight)); |
| } |
| -LayoutUnit LayoutBox::computeReplacedLogicalHeightUsing(const Length& logicalHeight) const |
| +LayoutUnit LayoutBox::computeReplacedLogicalHeightUsing(SizeType sizeType, const Length& logicalHeight) const |
| { |
| + if (sizeType == MinSize && logicalHeight.isAuto()) |
| + return adjustContentBoxLogicalHeightForBoxSizing(0); |
| + |
| switch (logicalHeight.type()) { |
| case Fixed: |
| return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value()); |
| @@ -2704,7 +2716,7 @@ LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi |
| return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, availableHeight)); |
| } |
| - LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(h, -1); |
| + LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(MainOrPreferredSize, h, -1); |
| if (heightIncludingScrollbar != -1) |
| return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heightIncludingScrollbar) - scrollbarLogicalHeight()); |
| @@ -2947,7 +2959,7 @@ void LayoutBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu |
| computeInlineStaticDistance(logicalLeftLength, logicalRightLength, this, containerBlock, containerLogicalWidth); |
| // Calculate constraint equation values for 'width' case. |
| - computePositionedLogicalWidthUsing(style()->logicalWidth(), containerBlock, containerDirection, |
| + computePositionedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth(), containerBlock, containerDirection, |
| containerLogicalWidth, bordersPlusPadding, |
| logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogicalRight, |
| computedValues); |
| @@ -2956,7 +2968,7 @@ void LayoutBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu |
| if (!style()->logicalMaxWidth().isMaxSizeNone()) { |
| LogicalExtentComputedValues maxValues; |
| - computePositionedLogicalWidthUsing(style()->logicalMaxWidth(), containerBlock, containerDirection, |
| + computePositionedLogicalWidthUsing(MaxSize, style()->logicalMaxWidth(), containerBlock, containerDirection, |
| containerLogicalWidth, bordersPlusPadding, |
| logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogicalRight, |
| maxValues); |
| @@ -2973,7 +2985,7 @@ void LayoutBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu |
| if (!style()->logicalMinWidth().isZero() || style()->logicalMinWidth().isIntrinsic()) { |
| LogicalExtentComputedValues minValues; |
| - computePositionedLogicalWidthUsing(style()->logicalMinWidth(), containerBlock, containerDirection, |
| + computePositionedLogicalWidthUsing(MinSize, style()->logicalMinWidth(), containerBlock, containerDirection, |
| containerLogicalWidth, bordersPlusPadding, |
| logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogicalRight, |
| minValues); |
| @@ -3011,12 +3023,14 @@ LayoutUnit LayoutBox::shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, |
| return std::min(std::max(preferredMinLogicalWidth, availableLogicalWidth), preferredLogicalWidth); |
| } |
| -void LayoutBox::computePositionedLogicalWidthUsing(Length logicalWidth, const LayoutBoxModelObject* containerBlock, TextDirection containerDirection, |
| +void LayoutBox::computePositionedLogicalWidthUsing(SizeType widthSizeType, Length logicalWidth, const LayoutBoxModelObject* containerBlock, TextDirection containerDirection, |
| LayoutUnit containerLogicalWidth, LayoutUnit bordersPlusPadding, |
| const Length& logicalLeft, const Length& logicalRight, const Length& marginLogicalLeft, |
| const Length& marginLogicalRight, LogicalExtentComputedValues& computedValues) const |
| { |
| - if (logicalWidth.isIntrinsic()) |
| + if (widthSizeType == MinSize && logicalWidth.isAuto()) |
| + logicalWidth = Length(0, Fixed); |
| + else if (logicalWidth.isIntrinsic()) |
| logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); |
| // 'left' and 'right' cannot both be 'auto' because one would of been |
| @@ -3249,7 +3263,7 @@ void LayoutBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp |
| // Calculate constraint equation values for 'height' case. |
| LayoutUnit logicalHeight = computedValues.m_extent; |
| - computePositionedLogicalHeightUsing(styleToUse.logicalHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| + computePositionedLogicalHeightUsing(MainOrPreferredSize, styleToUse.logicalHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
| computedValues); |
| @@ -3260,7 +3274,7 @@ void LayoutBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp |
| if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
| LogicalExtentComputedValues maxValues; |
| - computePositionedLogicalHeightUsing(styleToUse.logicalMaxHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| + computePositionedLogicalHeightUsing(MaxSize, styleToUse.logicalMaxHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
| maxValues); |
| @@ -3276,7 +3290,7 @@ void LayoutBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp |
| if (!styleToUse.logicalMinHeight().isZero() || styleToUse.logicalMinHeight().isIntrinsic()) { |
| LogicalExtentComputedValues minValues; |
| - computePositionedLogicalHeightUsing(styleToUse.logicalMinHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| + computePositionedLogicalHeightUsing(MinSize, styleToUse.logicalMinHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
| logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
| minValues); |
| @@ -3317,11 +3331,14 @@ static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const L |
| } |
| } |
| -void LayoutBox::computePositionedLogicalHeightUsing(Length logicalHeightLength, const LayoutBoxModelObject* containerBlock, |
| +void LayoutBox::computePositionedLogicalHeightUsing(SizeType heightSizeType, Length logicalHeightLength, const LayoutBoxModelObject* containerBlock, |
| LayoutUnit containerLogicalHeight, LayoutUnit bordersPlusPadding, LayoutUnit logicalHeight, |
| const Length& logicalTop, const Length& logicalBottom, const Length& marginBefore, |
| const Length& marginAfter, LogicalExtentComputedValues& computedValues) const |
| { |
| + if (heightSizeType == MinSize && logicalHeightLength.isAuto()) |
| + logicalHeightLength = Length(0, Fixed); |
| + |
| // 'top' and 'bottom' cannot both be 'auto' because 'top would of been |
| // converted to the static position in computePositionedLogicalHeight() |
| ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); |