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

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

Issue 1136283006: [CSS Grid Layout] Avoid using StyleAdjuster to resolve 'auto' values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed some layout tests failures. Created 5 years, 7 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 | « Source/core/layout/LayoutFlexibleBox.cpp ('k') | Source/core/style/ComputedStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutGrid.cpp
diff --git a/Source/core/layout/LayoutGrid.cpp b/Source/core/layout/LayoutGrid.cpp
index a0d7ab63dac0d07a1878c0398bd05c13002dd313..f0b4a9acc0a96884ab8a309728c2438741bad8a8 100644
--- a/Source/core/layout/LayoutGrid.cpp
+++ b/Source/core/layout/LayoutGrid.cpp
@@ -444,8 +444,8 @@ void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
// and there is space available, except if there are flexible track, which will occupy the whole
// available space.
bool needToStretch = flexibleSizedTracksIndex.isEmpty() && !sizingData.contentSizedTracksIndex.isEmpty()
- && ((direction == ForColumns && style()->justifyContentDistribution() == ContentDistributionStretch)
- || (direction == ForRows && style()->alignContentDistribution() == ContentDistributionStretch));
+ && ((direction == ForColumns && style()->resolvedJustifyContentDistribution() == ContentDistributionStretch)
+ || (direction == ForRows && style()->resolvedAlignContentDistribution() == ContentDistributionStretch));
const size_t tracksSize = tracks.size();
if (!hasUndefinedRemainingSpace) {
Vector<GridTrack*> tracksForDistribution(tracksSize);
@@ -1363,7 +1363,8 @@ LayoutUnit LayoutGrid::endOfColumnForChild(const LayoutBox& child) const
LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalPosition.next().toInt()];
// FIXME: This might not work as expected with orthogonal writing-modes.
- LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.style()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logicalWidth() + child.marginLogicalWidth());
+ OverflowAlignment overflow = ComputedStyle::resolvedJustifySelfOverflow(styleRef(), child.styleRef());
+ LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(overflow, startOfColumn, endOfColumn, child.logicalWidth() + child.marginLogicalWidth());
return columnPosition + offsetFromColumnPosition;
}
@@ -1391,7 +1392,8 @@ LayoutUnit LayoutGrid::centeredColumnPositionForChild(const LayoutBox& child) co
LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalPosition.next().toInt()];
LayoutUnit columnPosition = startOfColumn + marginStartForChild(child);
// FIXME: This might not work as expected with orthogonal writing-modes.
- LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.style()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logicalWidth() + child.marginLogicalWidth());
+ OverflowAlignment overflow = ComputedStyle::resolvedJustifySelfOverflow(styleRef(), child.styleRef());
+ LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(overflow, startOfColumn, endOfColumn, child.logicalWidth() + child.marginLogicalWidth());
return columnPosition + offsetFromColumnPosition / 2;
}
@@ -1400,7 +1402,7 @@ LayoutUnit LayoutGrid::columnPositionForChild(const LayoutBox& child) const
{
bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
- switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), ItemPositionStretch)) {
+ switch (ComputedStyle::resolvedJustifySelfPosition(styleRef(), child.styleRef(), ItemPositionStretch)) {
case ItemPositionSelfStart:
// For orthogonal writing-modes, this computes to 'start'
// FIXME: grid track sizing and positioning do not support orthogonal modes yet.
@@ -1462,7 +1464,8 @@ LayoutUnit LayoutGrid::endOfRowForChild(const LayoutBox& child) const
LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
- LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.style()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() + child.marginLogicalHeight());
+ OverflowAlignment overflow = ComputedStyle::resolvedAlignSelfOverflow(styleRef(), child.styleRef());
+ LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(overflow, startOfRow, endOfRow, child.logicalHeight() + child.marginLogicalHeight());
return rowPosition + offsetFromRowPosition;
}
@@ -1486,7 +1489,8 @@ LayoutUnit LayoutGrid::centeredRowPositionForChild(const LayoutBox& child) const
LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPosition.toInt()];
LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
- LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.style()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() + child.marginLogicalHeight());
+ OverflowAlignment overflow = ComputedStyle::resolvedAlignSelfOverflow(styleRef(), child.styleRef());
+ LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(overflow, startOfRow, endOfRow, child.logicalHeight() + child.marginLogicalHeight());
return rowPosition + offsetFromRowPosition / 2;
}
@@ -1505,7 +1509,7 @@ bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c
// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox.
bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const
{
- if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch)
+ if (ComputedStyle::resolvedAlignSelfPosition(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch)
return false;
return isHorizontalWritingMode() && child.style()->height().isAuto();
@@ -1569,7 +1573,7 @@ LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni
// FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to LayoutBox.
void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUnit gridAreaBreadthForChild)
{
- if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch)
+ if (ComputedStyle::resolvedAlignSelfPosition(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretch)
return;
bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
@@ -1595,7 +1599,7 @@ void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn
LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const
{
bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
- switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch)) {
+ switch (ComputedStyle::resolvedAlignSelfPosition(styleRef(), child.styleRef(), ItemPositionStretch)) {
case ItemPositionSelfStart:
// If orthogonal writing-modes, this computes to 'start'.
// FIXME: grid track sizing and positioning do not support orthogonal modes yet.
@@ -1731,8 +1735,8 @@ static bool contentDistributionOffset(LayoutUnit availableFreeSpace, ContentPosi
void LayoutGrid::computeContentPositionAndDistributionColumnOffset(LayoutUnit availableFreeSpace, GridSizingData& sizingData) const
{
- ContentPosition position = styleRef().justifyContentPosition();
- ContentDistributionType distribution = styleRef().justifyContentDistribution();
+ ContentPosition position = styleRef().resolvedJustifyContentPosition();
+ ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution();
// If <content-distribution> value can't be applied, 'position' will become the associated
// <content-position> fallback value.
if (contentDistributionOffset(availableFreeSpace, position, distribution, sizingData.columnTracks.size(), sizingData.columnsPositionOffset, sizingData.columnsDistributionOffset))
@@ -1777,8 +1781,8 @@ void LayoutGrid::computeContentPositionAndDistributionColumnOffset(LayoutUnit av
void LayoutGrid::computeContentPositionAndDistributionRowOffset(LayoutUnit availableFreeSpace, GridSizingData& sizingData) const
{
- ContentPosition position = styleRef().alignContentPosition();
- ContentDistributionType distribution = styleRef().alignContentDistribution();
+ ContentPosition position = styleRef().resolvedAlignContentPosition();
+ ContentDistributionType distribution = styleRef().resolvedAlignContentDistribution();
// If <content-distribution> value can't be applied, 'position' will become the associated
// <content-position> fallback value.
if (contentDistributionOffset(availableFreeSpace, position, distribution, sizingData.rowTracks.size(), sizingData.rowsPositionOffset, sizingData.rowsDistributionOffset))
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.cpp ('k') | Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698