Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 flexFraction = std::max( | 866 flexFraction = std::max( |
| 867 flexFraction, | 867 flexFraction, |
| 868 findFlexFactorUnitSize( | 868 findFlexFactorUnitSize( |
| 869 tracks, span, direction, | 869 tracks, span, direction, |
| 870 maxContentForChild(*gridItem, direction, sizingData))); | 870 maxContentForChild(*gridItem, direction, sizingData))); |
| 871 } | 871 } |
| 872 } | 872 } |
| 873 } | 873 } |
| 874 } | 874 } |
| 875 | 875 |
| 876 // We don't need to redo the fr computation for widths ever because at layout | |
| 877 // time we always have the right available space (with min|max-width | |
| 878 // constraints already considered). That's why we can skip this step for | |
| 879 // indefinite widths (which only appear during intrinsic size computation). | |
| 880 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
| |
| 881 LayoutUnit rowsSize = computeTrackBasedLogicalHeight(sizingData); | |
| 882 for (const auto& trackIndex : flexibleSizedTracksIndex) { | |
| 883 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); | |
| 884 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); | |
| 885 LayoutUnit baseSize = std::max( | |
| 886 oldBaseSize, | |
| 887 LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex())); | |
| 888 rowsSize += baseSize - oldBaseSize; | |
| 889 } | |
| 890 | |
| 891 auto minSize = computeContentLogicalHeight( | |
| 892 MinSize, styleRef().logicalMinHeight(), LayoutUnit(-1)); | |
| 893 auto maxSize = computeContentLogicalHeight( | |
| 894 MaxSize, styleRef().logicalMaxHeight(), LayoutUnit(-1)); | |
| 895 | |
| 896 // Redo the flex fraction computation using min|max-height as definite | |
| 897 // available space in case the total height is smaller than min-height | |
| 898 // or larger than max-height. | |
| 899 bool checkMinSize = minSize && rowsSize < minSize; | |
| 900 bool checkMaxSize = maxSize != -1 && rowsSize > maxSize; | |
| 901 if (checkMinSize || checkMaxSize) { | |
| 902 LayoutUnit freeSpace(-1); | |
|
jfernandez
2016/11/04 11:30:43
freeSpace = checkMaxSize ? maxSize : -1;
svillar
2016/11/04 11:42:06
Acknowledged.
| |
| 903 if (checkMaxSize) | |
| 904 freeSpace = maxSize; | |
| 905 freeSpace = | |
| 906 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.
| |
| 907 guttersSize(ForRows, 0, gridRowCount(), sizingData.sizingOperation); | |
| 908 | |
| 909 flexFraction = findFlexFactorUnitSize( | |
| 910 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), | |
| 911 direction, freeSpace); | |
|
jfernandez
2016/11/04 11:30:43
Perhaps using here ForRows, instead of direction,
svillar
2016/11/04 11:42:06
Acknowledged.
| |
| 912 } | |
| 913 } | |
| 914 | |
| 876 for (const auto& trackIndex : flexibleSizedTracksIndex) { | 915 for (const auto& trackIndex : flexibleSizedTracksIndex) { |
| 877 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); | 916 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); |
| 878 | 917 |
| 879 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); | 918 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); |
| 880 LayoutUnit baseSize = | 919 LayoutUnit baseSize = |
| 881 std::max(oldBaseSize, | 920 std::max(oldBaseSize, |
| 882 LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex())); | 921 LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex())); |
| 883 if (LayoutUnit increment = baseSize - oldBaseSize) { | 922 if (LayoutUnit increment = baseSize - oldBaseSize) { |
| 884 tracks[trackIndex].setBaseSize(baseSize); | 923 tracks[trackIndex].setBaseSize(baseSize); |
| 885 freeSpace -= increment; | 924 freeSpace -= increment; |
| (...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3436 if (!m_gridItemArea.isEmpty()) | 3475 if (!m_gridItemArea.isEmpty()) |
| 3437 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3476 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 3438 } | 3477 } |
| 3439 | 3478 |
| 3440 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3479 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
| 3441 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3480 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 3442 return m_hasDefiniteLogicalHeight.value(); | 3481 return m_hasDefiniteLogicalHeight.value(); |
| 3443 } | 3482 } |
| 3444 | 3483 |
| 3445 } // namespace blink | 3484 } // namespace blink |
| OLD | NEW |