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

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

Issue 1880393005: [css-grid] Fix alignment with content distribution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 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/LayoutTests/fast/css-grid-layout/grid-content-alignment-and-self-alignment-spanning-expected.txt ('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 c289e73157282f2d53cb848b2e832d14ca529527..7880cbfeb9d2c387ec4d9bb8633c59ac593e3b96 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -1967,17 +1967,15 @@ LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child, GridSizi
case GridAxisCenter: {
size_t childEndLine = rowsSpan.endLine();
LayoutUnit endOfRow = m_rowPositions[childEndLine];
- // m_rowPositions include gutters so we need to subtract them to get the actual end position for a given
- // row (this does not have to be done for the last track as there are no more m_rowPositions after it)
+ // m_rowPositions include distribution offset (because of content alignment) and gutters
+ // so we need to subtract them to get the actual end position for a given row
+ // (this does not have to be done for the last track as there are no more m_columnPositions after it).
LayoutUnit trackGap = guttersSize(ForRows, 2);
- if (childEndLine < m_rowPositions.size() - 1)
+ if (childEndLine < m_rowPositions.size() - 1) {
endOfRow -= trackGap;
- LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHeight();
- // The track's start and end lines may be not adjacent because of content alignment, so we assume the stored
- // lines are all start plus a content-alignment distribution offset.
- // We must subtract last line's offset because is not part of the track the items belongs to.
- if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.size() - 1)
endOfRow -= m_offsetBetweenRows;
+ }
+ LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHeight();
OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef(), ItemPositionStretch).overflow();
LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfRow - startOfRow, childBreadth);
return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
@@ -2004,17 +2002,15 @@ LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD
case GridAxisCenter: {
size_t childEndLine = columnsSpan.endLine();
LayoutUnit endOfColumn = m_columnPositions[childEndLine];
- // m_columnPositions include gutters so we need to subtract them to get the actual end position for a given
- // column (this does not have to be done for the last track as there are no more m_columnPositions after it)
+ // m_columnPositions include distribution offset (because of content alignment) and gutters
+ // so we need to subtract them to get the actual end position for a given column
+ // (this does not have to be done for the last track as there are no more m_columnPositions after it).
LayoutUnit trackGap = guttersSize(ForColumns, 2);
- if (childEndLine < m_columnPositions.size() - 1)
+ if (childEndLine < m_columnPositions.size() - 1) {
endOfColumn -= trackGap;
- LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidth();
- // The track's start and end lines may be not adjacent because of content alignment, so we assume the stored
- // lines are all start plus a content-alignment distribution offset.
- // We must subtract last line's offset because is not part of the track the items belongs to.
- if (childEndLine - childStartLine > 1 && childEndLine < m_columnPositions.size() - 1)
endOfColumn -= m_offsetBetweenColumns;
+ }
+ LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidth();
LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(child.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childBreadth);
return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-content-alignment-and-self-alignment-spanning-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698