Chromium Code Reviews| Index: Source/core/layout/LayoutGrid.cpp |
| diff --git a/Source/core/layout/LayoutGrid.cpp b/Source/core/layout/LayoutGrid.cpp |
| index bbc127fec4d4b4a5055d2b86284633e04ea4c9ea..e456e8d38377871dfada9635547ec24e2e0b1c8d 100644 |
| --- a/Source/core/layout/LayoutGrid.cpp |
| +++ b/Source/core/layout/LayoutGrid.cpp |
| @@ -1275,7 +1275,7 @@ void LayoutGrid::layoutGridItems() |
| // Stretching logic might force a child layout, so we need to run it before the layoutIfNeeded |
| // call to avoid unnecessary relayouts. This might imply that child margins, needed to correctly |
| // determine the available space before stretching, are not set yet. |
| - applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockContentLogicalHeight); |
| + applyStretchAlignmentToChildIfNeeded(*child); |
| child->layoutIfNeeded(); |
| @@ -1453,9 +1453,24 @@ static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay |
| return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeight + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
| } |
| -bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) const |
| +bool LayoutGrid::hasAutoSizeInColumnAxisForChild(const LayoutBox& child) const |
| { |
| - return child.style()->logicalHeight().isAuto() && !child.style()->marginBeforeUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); |
| + return isHorizontalWritingMode() ? child.style()->height().isAuto() : child.style()->width().isAuto(); |
| +} |
| + |
| +bool LayoutGrid::hasAutoSizeInRowAxisForChild(const LayoutBox& child) const |
| +{ |
| + return isHorizontalWritingMode() ? child.style()->width().isAuto() : child.style()->height().isAuto(); |
| +} |
| + |
| +bool LayoutGrid::allowedToStretchChildAlongColumnAxis(const LayoutBox& child) const |
| +{ |
| + return hasAutoSizeInColumnAxisForChild(child) && !child.style()->marginBeforeUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); |
| +} |
| + |
| +bool LayoutGrid::allowedToStretchChildAlongRowAxis(const LayoutBox& child) const |
| +{ |
| + return hasAutoSizeInRowAxisForChild(child) && !child.style()->marginStartUsing(style()).isAuto() && !child.style()->marginEndUsing(style()).isAuto(); |
| } |
| // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| @@ -1523,18 +1538,27 @@ LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni |
| } |
| // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| -void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUnit gridAreaBreadthForChild) |
| +void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) |
| { |
| - if (!allowedToStretchLogicalHeightForChild(child) || ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch) { |
| - child.clearOverrideLogicalContentHeight(); |
| - return; |
| + child.clearOverrideSize(); |
| + |
| + if (!allowedToStretchChildAlongRowAxis(child) || ComputedStyle::resolveJustification(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch) { |
| + if (hasAutoSizeInRowAxisForChild(child)) { |
| + LayoutUnit childPreferredWidth = std::min(child.maxPreferredLogicalWidth(), child.overrideContainingBlockContentLogicalWidth() - child.marginLogicalWidth()); |
|
Manuel Rego
2015/07/13 12:40:07
This is what's breaking "min-width: auto;".
From
jfernandez
2015/07/14 13:36:08
That's correct, thanks for pointing it out.
|
| + child.setOverrideLogicalContentWidth(childPreferredWidth - child.borderAndPaddingLogicalWidth()); |
| + if (childPreferredWidth != child.logicalWidth()) |
| + child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| + } |
| } |
| + if (!allowedToStretchChildAlongColumnAxis(child) || ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch) |
| + return; |
| + |
| bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode(); |
| // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it. |
| // FIXME: grid track sizing and positioning do not support orthogonal modes yet. |
| if (!hasOrthogonalWritingMode) { |
| - LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(gridAreaBreadthForChild, child); |
| + LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); |
| LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, -1); |
| // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905. |