Chromium Code Reviews| Index: Source/core/rendering/RenderBox.cpp |
| diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp |
| index 760eab0aad7d7832b5fed5c1e2a2aff48cfc7088..ff463b3c37acdcf44bed72442e5d04076f93d0fe 100644 |
| --- a/Source/core/rendering/RenderBox.cpp |
| +++ b/Source/core/rendering/RenderBox.cpp |
| @@ -2248,7 +2248,7 @@ void RenderBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues) |
| if (avoidsFloats() && cb->containsFloats()) |
| containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidth(); |
| bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection(); |
| - computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, computedValues.m_extent, |
| + computeInlineDirectionMargins(cb, containerLogicalWidth, containerLogicalWidthForAutoMargins, computedValues.m_extent, |
| hasInvertedDirection ? computedValues.m_margins.m_end : computedValues.m_margins.m_start, |
| hasInvertedDirection ? computedValues.m_margins.m_start : computedValues.m_margins.m_end); |
| } |
| @@ -2422,7 +2422,7 @@ bool RenderBox::autoWidthShouldFitContent() const |
| || node()->hasTagName(textareaTag) || (node()->hasTagName(legendTag) && !style()->hasOutOfFlowPosition())); |
| } |
| -void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const |
| +void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit availableWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const |
| { |
| const RenderStyle* containingBlockStyle = containingBlock->style(); |
| Length marginStartLength = style()->marginStartUsing(containingBlockStyle); |
| @@ -2446,30 +2446,30 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo |
| } |
| // Case One: The object is being centered in the containing block's available logical width. |
| - if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth) |
| + if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < availableWidth) |
| || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containingBlock->style()->textAlign() == WEBKIT_CENTER)) { |
| // Other browsers center the margin box for align=center elements so we match them here. |
| LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, containerWidth); |
| LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, containerWidth); |
| - LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2); |
| + LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (availableWidth - childWidth - marginStartWidth - marginEndWidth) / 2); |
| marginStart = centeredMarginBoxStart + marginStartWidth; |
| - marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; |
| + marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; |
| return; |
| } |
| // Case Two: The object is being pushed to the start of the containing block's available logical width. |
| - if (marginEndLength.isAuto() && childWidth < containerWidth) { |
| + if (marginEndLength.isAuto() && childWidth < availableWidth) { |
| marginStart = valueForLength(marginStartLength, containerWidth); |
| - marginEnd = containerWidth - childWidth - marginStart; |
| + marginEnd = availableWidth - childWidth - marginStart; |
| return; |
| } |
| // Case Three: The object is being pushed to the end of the containing block's available logical width. |
| bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT) |
| || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT)); |
| - if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEndFromTextAlign) { |
| + if ((marginStartLength.isAuto() && childWidth < availableWidth) || pushToEndFromTextAlign) { |
| marginEnd = valueForLength(marginEndLength, containerWidth); |
| - marginStart = containerWidth - childWidth - marginEnd; |
| + marginStart = availableWidth - childWidth - marginEnd; |
| return; |
| } |
| @@ -2545,7 +2545,8 @@ void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica |
| if (isTable()) { |
| if (hasPerpendicularContainingBlock) { |
| bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style(), style()); |
| - computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), computedValues.m_extent, |
| + LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForContent(); |
|
Julien - ping for review
2014/03/06 23:05:05
I seems weird that we always use containingBlockLo
rune
2014/03/07 14:20:24
Done that now. I also added a layout test showing
|
| + computeInlineDirectionMargins(cb, containerLogicalWidth, containerLogicalWidth, computedValues.m_extent, |
| shouldFlipBeforeAfter ? computedValues.m_margins.m_after : computedValues.m_margins.m_before, |
| shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after); |
| } |
| @@ -2598,7 +2599,8 @@ void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica |
| if (hasPerpendicularContainingBlock) { |
| bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style(), style()); |
| - computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), heightResult, |
| + LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForContent(); |
| + computeInlineDirectionMargins(cb, containerLogicalWidth, containerLogicalWidth, heightResult, |
| shouldFlipBeforeAfter ? computedValues.m_margins.m_after : computedValues.m_margins.m_before, |
| shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after); |
| } |