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

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

Issue 2176533002: [css-grid] Implementing stretch alignment in orthogonal flows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied suggested changes. Created 4 years, 5 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/LayoutTests/fast/css-grid-layout/grid-align-justify-stretch-with-orthogonal-flows.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 e9d00961ae56359570e6530bdc8e647c2c108593..41984699821333ce86aaf1761665d2fca441a680 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -2194,20 +2194,23 @@ void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child)
auto& childStyle = child.styleRef();
bool isHorizontalMode = isHorizontalWritingMode();
- bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto() : childStyle.width().isAuto();
- bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !childStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style()).isAuto();
- if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment(styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) {
- // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it.
- // TODO (lajava): grid track sizing and positioning do not support orthogonal modes yet.
- if (child.isHorizontalWritingMode() == isHorizontalMode) {
- LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(child.overrideContainingBlockContentLogicalHeight(), child);
- LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, LayoutUnit(-1));
- child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight());
- if (desiredLogicalHeight != child.logicalHeight()) {
- // TODO (lajava): Can avoid laying out here in some cases. See https://webkit.org/b/87905.
- child.setLogicalHeight(LayoutUnit());
- child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
- }
+ bool childHasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto() : childStyle.width().isAuto();
+ bool childHasAutoSizeInRowAxis = isHorizontalMode ? childStyle.width().isAuto() : childStyle.height().isAuto();
+ bool allowedToStretchChildAlongColumnAxis = childHasAutoSizeInColumnAxis && !hasAutoMarginsInColumnAxis(child);
+ bool allowedToStretchChildAlongRowAxis = childHasAutoSizeInRowAxis && !hasAutoMarginsInRowAxis(child);
+ bool stretchingAlongRowAxis = ComputedStyle::resolveJustification(styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch;
+ bool stretchingAlongColumnAxis = ComputedStyle::resolveAlignment(styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch;
+
+ GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(child, ForRows);
+ bool allowedToStretchChildBlockSize = childBlockDirection == ForRows ? allowedToStretchChildAlongColumnAxis && stretchingAlongColumnAxis : allowedToStretchChildAlongRowAxis && stretchingAlongRowAxis;
+ if (allowedToStretchChildBlockSize) {
+ LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(overrideContainingBlockContentSizeForChild(child, childBlockDirection), child);
+ LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, LayoutUnit(-1));
+ child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight());
+ if (desiredLogicalHeight != child.logicalHeight()) {
+ // TODO (lajava): Can avoid laying out here in some cases. See https://webkit.org/b/87905.
+ child.setLogicalHeight(LayoutUnit());
+ child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
}
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-align-justify-stretch-with-orthogonal-flows.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698