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

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

Issue 2808453002: [css-grid] Use Optional to represent indefinite lengths (Closed)
Patch Set: Changes after review Created 3 years, 8 months 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/Source/core/layout/GridTrackSizingAlgorithm.cpp ('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 ca5f7132ecc47b1412c352b407aead2e70f0e116..00063fdfbd0cb655efaa568ff209418cbe955474 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -284,8 +284,8 @@ void LayoutGrid::layoutBlock(bool relayoutChildren) {
// Once grid's indefinite height is resolved, we can compute the
// available free space for Content Alignment.
if (!cachedHasDefiniteLogicalHeight()) {
- m_trackSizingAlgorithm.freeSpace(ForRows) =
- logicalHeight() - trackBasedLogicalHeight;
+ m_trackSizingAlgorithm.setFreeSpace(
+ ForRows, logicalHeight() - trackBasedLogicalHeight);
}
// TODO (lajava): We need to compute baselines after step 2 so
@@ -436,7 +436,7 @@ void LayoutGrid::computeTrackSizesForIndefiniteSize(
LayoutUnit& minIntrinsicSize,
LayoutUnit& maxIntrinsicSize) const {
algo.setup(direction, numTracks(direction, grid), IntrinsicSizeComputation,
- LayoutUnit(), LayoutUnit());
+ WTF::nullopt, WTF::nullopt);
algo.run();
minIntrinsicSize = algo.minContentSize();
@@ -1046,8 +1046,8 @@ static const StyleContentAlignmentData& contentAlignmentNormalBehavior() {
void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(
GridTrackSizingDirection direction) {
- LayoutUnit& availableSpace = m_trackSizingAlgorithm.freeSpace(direction);
- if (availableSpace <= 0 ||
+ Optional<LayoutUnit> freeSpace = m_trackSizingAlgorithm.freeSpace(direction);
+ if (!freeSpace || freeSpace.value() <= 0 ||
(direction == ForColumns &&
styleRef().resolvedJustifyContentDistribution(
contentAlignmentNormalBehavior()) != ContentDistributionStretch) ||
@@ -1071,14 +1071,13 @@ void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(
if (numberOfAutoSizedTracks < 1)
return;
- LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks;
+ LayoutUnit sizeToIncrease = freeSpace.value() / numberOfAutoSizedTracks;
for (const auto& trackIndex : autoSizedTracksIndex) {
GridTrack* track = allTracks.data() + trackIndex;
LayoutUnit baseSize = track->baseSize() + sizeToIncrease;
track->setBaseSize(baseSize);
}
-
- availableSpace = LayoutUnit();
+ m_trackSizingAlgorithm.setFreeSpace(direction, LayoutUnit());
}
void LayoutGrid::layoutGridItems() {
@@ -1345,7 +1344,8 @@ void LayoutGrid::populateGridPositionsForDirection(
size_t numberOfLines = numberOfTracks + 1;
size_t lastLine = numberOfLines - 1;
ContentAlignmentData offset = computeContentPositionAndDistributionOffset(
- direction, m_trackSizingAlgorithm.freeSpace(direction), numberOfTracks);
+ direction, m_trackSizingAlgorithm.freeSpace(direction).value(),
+ numberOfTracks);
auto& positions = isRowAxis ? m_columnPositions : m_rowPositions;
positions.resize(numberOfLines);
auto borderAndPadding =
« no previous file with comments | « third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698