Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2480493002: [css-grid] Use min|max-sizes to compute flex fraction (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/flex-sizing-rows-min-max-height.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/flex-sizing-rows-min-max-height.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698