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 05a01b709fbfee65abbd54397c163e4667c2d148..c6b87d0c96e9599abf64ebe0404d9b9f23ccc867 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
| @@ -873,6 +873,45 @@ void LayoutGrid::computeUsedBreadthOfGridTracks( |
| } |
| } |
| + // We don't need to redo the fr computation for widths ever because at layout |
| + // time we always have the right available space (with min|max-width |
| + // constraints already considered). That's why we can skip this step for |
| + // indefinite widths (which only appear during intrinsic size computation). |
| + if (direction == ForRows) { |
|
jfernandez
2016/11/04 11:30:43
We will compute the flex tracks' base size twice,
svillar
2016/11/04 11:42:06
Right. I thought about caching the results but I d
|
| + LayoutUnit rowsSize = computeTrackBasedLogicalHeight(sizingData); |
| + for (const auto& trackIndex : flexibleSizedTracksIndex) { |
| + GridTrackSize trackSize = gridTrackSize(direction, trackIndex); |
| + LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); |
| + LayoutUnit baseSize = std::max( |
| + oldBaseSize, |
| + LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex())); |
| + rowsSize += baseSize - oldBaseSize; |
| + } |
| + |
| + auto minSize = computeContentLogicalHeight( |
| + MinSize, styleRef().logicalMinHeight(), LayoutUnit(-1)); |
| + auto maxSize = computeContentLogicalHeight( |
| + MaxSize, styleRef().logicalMaxHeight(), LayoutUnit(-1)); |
| + |
| + // Redo the flex fraction computation using min|max-height as definite |
| + // available space in case the total height is smaller than min-height |
| + // or larger than max-height. |
| + bool checkMinSize = minSize && rowsSize < minSize; |
| + bool checkMaxSize = maxSize != -1 && rowsSize > maxSize; |
| + if (checkMinSize || checkMaxSize) { |
| + LayoutUnit freeSpace(-1); |
|
jfernandez
2016/11/04 11:30:43
freeSpace = checkMaxSize ? maxSize : -1;
svillar
2016/11/04 11:42:06
Acknowledged.
|
| + if (checkMaxSize) |
| + freeSpace = maxSize; |
| + freeSpace = |
| + std::max(freeSpace, minSize) - |
|
jfernandez
2016/11/04 11:30:43
What we should do if maxSize < minSize ?
svillar
2016/11/04 11:42:06
min-size always trumps max-size.
|
| + guttersSize(ForRows, 0, gridRowCount(), sizingData.sizingOperation); |
| + |
| + flexFraction = findFlexFactorUnitSize( |
| + tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), |
| + direction, freeSpace); |
|
jfernandez
2016/11/04 11:30:43
Perhaps using here ForRows, instead of direction,
svillar
2016/11/04 11:42:06
Acknowledged.
|
| + } |
| + } |
| + |
| for (const auto& trackIndex : flexibleSizedTracksIndex) { |
| GridTrackSize trackSize = gridTrackSize(direction, trackIndex); |