Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| index 9ccca19e433b86491892cd6f22ec8b4011ce3fef..4e5e221d420da5f1bccaaa063cb46de47121a641 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| @@ -685,9 +685,10 @@ LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> |
| SubtreeLayoutScope layoutScope(child); |
| LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); |
| LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks); |
| - if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth) { |
| + bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeight() |
| + || (!child.styleRef().logicalHeight().isSpecified() && itemSpansContentSizedOrFlexibleSizedTracks(cachedGridSpan(child, ForRows), ForRows, ContentSizedAndFlexible)); |
|
Manuel Rego
2016/03/14 14:38:09
I've a hard time trying to understand the 2nd part
svillar
2016/03/17 13:33:54
Isn't the function name explicit enough?
|
| + if (shouldClearContainingBlockLogicalHeight || oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth) |
| layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged); |
| - } |
| bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); |
| // We need to clear the stretched height to properly compute logical height during layout. |
| @@ -697,11 +698,11 @@ LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> |
| child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); |
| // If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is |
| // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). |
| - if (child.hasRelativeLogicalHeight()) |
| + if (shouldClearContainingBlockLogicalHeight) |
| child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); |
| child.layoutIfNeeded(); |
| // If the child was stretched we should use its intrinsic height. |
| - return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeight()) + child.marginLogicalHeight(); |
| + return child.logicalHeight() + child.marginLogicalHeight(); |
| } |
| LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirection direction, Vector<GridTrack>& columnTracks) |
| @@ -787,11 +788,13 @@ private: |
| GridSpan m_gridSpan; |
| }; |
| -bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, GridTrackSizingDirection direction) const |
| +bool LayoutGrid::itemSpansContentSizedOrFlexibleSizedTracks(const GridSpan& span, GridTrackSizingDirection direction, SpanMode spanMode) const |
| { |
| + bool checkContentSized = spanMode == ContentSizedAndFlexible; |
| for (const auto& trackPosition : span) { |
| const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition); |
| - if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().isFlex()) |
| + if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().isFlex() |
| + || (checkContentSized && (trackSize.minTrackBreadth().isContentSized() || trackSize.maxTrackBreadth().isContentSized()))) |
| return true; |
| } |
| @@ -810,7 +813,7 @@ void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio |
| const GridSpan& span = cachedGridSpan(*gridItem, direction); |
| if (span.integerSpan() == 1) { |
| resolveContentBasedTrackSizingFunctionsForNonSpanningItems(direction, span, *gridItem, track, sizingData.columnTracks); |
| - } else if (!spanningItemCrossesFlexibleSizedTracks(span, direction)) { |
| + } else if (!itemSpansContentSizedOrFlexibleSizedTracks(span, direction, FlexibleOnly)) { |
| sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, span)); |
| } |
| } |
| @@ -1642,43 +1645,6 @@ static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay |
| return LayoutUnit(); |
| } |
| -static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const LayoutBox& child) |
| -{ |
| - LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogicalHeight(); |
| - return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeight + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
| -} |
| - |
| -// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| -bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const |
| -{ |
|
Manuel Rego
2016/03/14 14:38:09
Shouldn't you remove the method signature in the h
svillar
2016/03/17 13:33:54
Ups forgot about that.
|
| - if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch) |
| - return false; |
| - |
| - return isHorizontalWritingMode() && child.style()->height().isAuto(); |
| -} |
| - |
| -// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| -LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const |
|
Manuel Rego
2016/03/14 14:38:09
Ditto.
|
| -{ |
| - if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child)) |
| - return constrainedChildIntrinsicContentLogicalHeight(child); |
| - return child.size().height(); |
| -} |
| - |
| -// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| -LayoutUnit LayoutGrid::childIntrinsicWidth(const LayoutBox& child) const |
|
Manuel Rego
2016/03/14 14:38:09
Ditto.
|
| -{ |
| - if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child)) |
| - return constrainedChildIntrinsicContentLogicalHeight(child); |
| - return child.size().width(); |
| -} |
| - |
| -// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| -LayoutUnit LayoutGrid::intrinsicLogicalHeightForChild(const LayoutBox& child) const |
|
Manuel Rego
2016/03/14 14:38:09
Ditto.
|
| -{ |
| - return isHorizontalWritingMode() ? childIntrinsicHeight(child) : childIntrinsicWidth(child); |
| -} |
| - |
| // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox. |
| LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const |
| { |