Chromium Code Reviews| Index: Source/core/rendering/RenderBox.cpp |
| diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp |
| index 39befae260204bc7a2b5b40e9d6460cfa6e6109a..c137bb8062fc6bafb1ebe6ff81bebb5f5ac5d908 100644 |
| --- a/Source/core/rendering/RenderBox.cpp |
| +++ b/Source/core/rendering/RenderBox.cpp |
| @@ -2669,6 +2669,9 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo |
| } |
| } |
| + if (hasOverrideContainingBlockLogicalWidth()) |
| + return overrideContainingBlockContentLogicalWidth(); |
| + |
| if (containingBlock->isBox()) |
| return toRenderBox(containingBlock)->clientLogicalWidth(); |
| @@ -2709,6 +2712,9 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM |
| } |
| } |
| + if (hasOverrideContainingBlockLogicalHeight()) |
| + return overrideContainingBlockContentLogicalHeight(); |
| + |
| if (containingBlock->isBox()) { |
| const RenderBlock* cb = containingBlock->isRenderBlock() ? |
| toRenderBlock(containingBlock) : containingBlock->containingBlock(); |
| @@ -2735,14 +2741,37 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM |
| return heightResult; |
| } |
| +static LayoutUnit computeInlineStaticPositionGridItem(Length& logicalLeft, Length& logicalRight, const RenderBox* child, LayoutUnit containerLogicalWidth) |
|
Julien - ping for review
2014/10/23 15:24:43
computeInlineStaticPositionForGridItem (note the '
Manuel Rego
2014/10/23 21:51:12
Acknowledged. Next time I'll try to use XYZ to get
|
| +{ |
| + ASSERT(child->parent()->isRenderGrid()); |
| + |
| + LayoutUnit staticPosition = 0; |
| + if (child->parent()->style()->direction() == LTR) { |
| + if (!logicalLeft.isAuto()) |
| + staticPosition += valueForLength(logicalLeft, containerLogicalWidth); |
| + else if (!logicalRight.isAuto()) |
| + staticPosition -= valueForLength(logicalRight, containerLogicalWidth); |
| + } else { |
| + if (!logicalRight.isAuto()) |
| + staticPosition += valueForLength(logicalRight, containerLogicalWidth); |
| + else if (!logicalLeft.isAuto()) |
| + staticPosition -= valueForLength(logicalLeft, containerLogicalWidth); |
| + } |
| + return staticPosition; |
| +} |
| + |
| static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalWidth) |
| { |
| - if (!logicalLeft.isAuto() || !logicalRight.isAuto()) |
| + if ((!logicalLeft.isAuto() || !logicalRight.isAuto()) && !child->parent()->isRenderGrid()) |
| return; |
| + LayoutUnit staticPosition = 0; |
| + if (child->parent()->isRenderGrid()) |
| + staticPosition = computeInlineStaticPositionGridItem(logicalLeft, logicalRight, child, containerLogicalWidth); |
| + |
| // FIXME: The static distance computation has not been patched for mixed writing modes yet. |
| if (child->parent()->style()->direction() == LTR) { |
| - LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft(); |
| + staticPosition += child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft(); |
| for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) { |
| if (curr->isBox()) { |
| staticPosition += toRenderBox(curr)->logicalLeft(); |
| @@ -2760,7 +2789,7 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh |
| logicalLeft.setValue(Fixed, staticPosition); |
| } else { |
| RenderBox* enclosingBox = child->parent()->enclosingBox(); |
| - LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft(); |
| + staticPosition += child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft(); |
| for (RenderObject* curr = child->parent(); curr; curr = curr->container()) { |
| if (curr->isBox()) { |
| if (curr != containerBlock) { |
| @@ -3103,13 +3132,29 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re |
| computeLogicalLeftPositionedOffset(computedValues.m_position, this, computedValues.m_extent, containerBlock, containerLogicalWidth); |
| } |
| -static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom, const RenderBox* child, const RenderBoxModelObject* containerBlock) |
| +static LayoutUnit computeBlockStaticPositionGridItem(Length& logicalTop, Length& logicalBottom, const RenderBox* child, LayoutUnit containerLogicalHeight) |
|
Manuel Rego
2014/10/23 21:51:12
Using "for" here too.
|
| { |
| - if (!logicalTop.isAuto() || !logicalBottom.isAuto()) |
| + ASSERT(child->parent()->isRenderGrid()); |
| + |
| + LayoutUnit staticPosition = 0; |
| + if (!logicalTop.isAuto()) |
| + staticPosition += valueForLength(logicalTop, containerLogicalHeight); |
| + else if (!logicalBottom.isAuto()) |
| + staticPosition -= valueForLength(logicalBottom, containerLogicalHeight); |
| + return staticPosition; |
| +} |
| + |
| +static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalHeight) |
| +{ |
| + if ((!logicalTop.isAuto() || !logicalBottom.isAuto()) && !child->parent()->isRenderGrid()) |
| return; |
| + LayoutUnit staticLogicalTop = 0; |
| + if (child->parent()->isRenderGrid()) |
| + staticLogicalTop = computeBlockStaticPositionGridItem(logicalTop, logicalBottom, child, containerLogicalHeight); |
| + |
| // FIXME: The static distance computation has not been patched for mixed writing modes. |
| - LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - containerBlock->borderBefore(); |
| + staticLogicalTop += child->layer()->staticBlockPosition() - containerBlock->borderBefore(); |
| for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) { |
| if (curr->isBox() && !curr->isTableRow()) |
| staticLogicalTop += toRenderBox(curr)->logicalTop(); |
| @@ -3162,7 +3207,7 @@ void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp |
| // see FIXME 1 |
| // Calculate the static distance if needed. |
| - computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, containerBlock); |
| + computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, containerBlock, containerLogicalHeight); |
| // Calculate constraint equation values for 'height' case. |
| LayoutUnit logicalHeight = computedValues.m_extent; |
| @@ -3568,7 +3613,7 @@ void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu |
| * with the element's static position. |
| \*-----------------------------------------------------------------------*/ |
| // see FIXME 1 |
| - computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock); |
| + computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock, containerLogicalHeight); |
| /*-----------------------------------------------------------------------*\ |
| * 3. If 'bottom' is 'auto', replace any 'auto' on 'margin-top' or |