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..55bf74fa309f447994c956136a3344daaacce34e 100644 |
| --- a/Source/core/rendering/RenderBox.cpp |
| +++ b/Source/core/rendering/RenderBox.cpp |
| @@ -2244,11 +2244,8 @@ void RenderBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues) |
| computedValues.m_margins.m_start = minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth); |
| computedValues.m_margins.m_end = minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth); |
| } else { |
| - LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; |
| - if (avoidsFloats() && cb->containsFloats()) |
| - containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidth(); |
| bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection(); |
| - computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, computedValues.m_extent, |
| + computeInlineDirectionMargins(cb, containerLogicalWidth, 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); |
| } |
| @@ -2445,31 +2442,35 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo |
| marginEndLength.setValue(0); |
| } |
| + LayoutUnit availableWidth = containerWidth; |
|
Julien - ping for review
2014/03/10 20:27:01
Everyone is passing containingBlockLogicalWidthFor
rune
2014/03/12 12:21:37
containingBlockLogicalWidthForContent() is a virtu
|
| + if (avoidsFloats() && containingBlock->containsFloats()) |
| + availableWidth = containingBlockAvailableLineWidth(); |
| + |
| // 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; |
| } |