| 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 e294061f630a284ea13a33f3db6fc4fca3bcfac6..fea734b6cb7e6ff6025a6ed7e2d14726aec86bb4 100644
|
| --- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
|
| @@ -37,6 +37,7 @@
|
| namespace blink {
|
|
|
| static const int infinity = -1;
|
| +static const ItemPosition selfAlignmentNormalBehavior = ItemPositionStretch;
|
|
|
| class GridItemWithSpan;
|
|
|
| @@ -1363,7 +1364,7 @@ void LayoutGrid::dirtyGrid()
|
| m_gridIsDirty = true;
|
| }
|
|
|
| -static const StyleContentAlignmentData& normalValueBehavior()
|
| +static const StyleContentAlignmentData& contentAlignmentNormalBehavior()
|
| {
|
| static const StyleContentAlignmentData normalBehavior = {ContentPositionNormal, ContentDistributionStretch};
|
| return normalBehavior;
|
| @@ -1373,8 +1374,8 @@ void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection
|
| {
|
| LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction);
|
| if (availableSpace <= 0
|
| - || (direction == ForColumns && styleRef().resolvedJustifyContentDistribution(normalValueBehavior()) != ContentDistributionStretch)
|
| - || (direction == ForRows && styleRef().resolvedAlignContentDistribution(normalValueBehavior()) != ContentDistributionStretch))
|
| + || (direction == ForColumns && styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()) != ContentDistributionStretch)
|
| + || (direction == ForRows && styleRef().resolvedAlignContentDistribution(contentAlignmentNormalBehavior()) != ContentDistributionStretch))
|
| return;
|
|
|
| // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing function.
|
| @@ -1651,7 +1652,7 @@ static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
|
| // 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 (child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).position() != ItemPositionStretch)
|
| return false;
|
|
|
| return isHorizontalWritingMode() && child.style()->height().isAuto();
|
| @@ -1718,7 +1719,7 @@ void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child)
|
| 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) {
|
| + if (allowedToStretchChildAlongColumnAxis && childStyle.resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).position() == 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) {
|
| @@ -1797,7 +1798,7 @@ GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child)
|
| bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
|
| bool hasSameWritingMode = child.styleRef().writingMode() == styleRef().writingMode();
|
|
|
| - switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch)) {
|
| + switch (child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).position()) {
|
| case ItemPositionSelfStart:
|
| // If orthogonal writing-modes, this computes to 'start'.
|
| // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
|
| @@ -1834,6 +1835,7 @@ GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child)
|
| // crbug.com/234191
|
| return GridAxisStart;
|
| case ItemPositionAuto:
|
| + case ItemPositionNormal:
|
| break;
|
| }
|
|
|
| @@ -1847,7 +1849,7 @@ GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con
|
| bool hasSameDirection = child.styleRef().direction() == styleRef().direction();
|
| bool isLTR = styleRef().isLeftToRightDirection();
|
|
|
| - switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), ItemPositionStretch)) {
|
| + switch (child.styleRef().resolvedJustifySelf(styleRef(), selfAlignmentNormalBehavior).position()) {
|
| case ItemPositionSelfStart:
|
| // For orthogonal writing-modes, this computes to 'start'
|
| // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
|
| @@ -1877,6 +1879,7 @@ GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con
|
| // crbug.com/234191
|
| return GridAxisStart;
|
| case ItemPositionAuto:
|
| + case ItemPositionNormal:
|
| break;
|
| }
|
|
|
| @@ -1912,8 +1915,8 @@ LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const
|
| endOfRow -= guttersSize(ForRows, 2);
|
| LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHeight();
|
| if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.size() - 1)
|
| - endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistribution(normalValueBehavior()), m_rowPositions, childBreadth);
|
| - OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef(), ItemPositionStretch).overflow();
|
| + endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistribution(contentAlignmentNormalBehavior()), m_rowPositions, childBreadth);
|
| + OverflowAlignment overflow = child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).overflow();
|
| LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfRow - startOfRow, childBreadth);
|
| return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
|
| }
|
| @@ -1945,8 +1948,9 @@ LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const
|
| endOfColumn -= guttersSize(ForRows, 2);
|
| LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidth();
|
| if (childEndLine - childStartLine > 1 && childEndLine < m_columnPositions.size() - 1)
|
| - endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContentDistribution(normalValueBehavior()), m_columnPositions, childBreadth);
|
| - LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(child.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childBreadth);
|
| + endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()), m_columnPositions, childBreadth);
|
| + OverflowAlignment overflow = child.styleRef().resolvedJustifySelf(styleRef(), selfAlignmentNormalBehavior).overflow();
|
| + LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfColumn - startOfColumn, childBreadth);
|
| return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2);
|
| }
|
| }
|
| @@ -2008,8 +2012,8 @@ static ContentAlignmentData contentDistributionOffset(const LayoutUnit& availabl
|
| ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(GridTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const
|
| {
|
| bool isRowAxis = direction == ForColumns;
|
| - ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosition(normalValueBehavior()) : styleRef().resolvedAlignContentPosition(normalValueBehavior());
|
| - ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustifyContentDistribution(normalValueBehavior()) : styleRef().resolvedAlignContentDistribution(normalValueBehavior());
|
| + ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosition(contentAlignmentNormalBehavior()) : styleRef().resolvedAlignContentPosition(contentAlignmentNormalBehavior());
|
| + ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()) : styleRef().resolvedAlignContentDistribution(contentAlignmentNormalBehavior());
|
| // If <content-distribution> value can't be applied, 'position' will become the associated
|
| // <content-position> fallback value.
|
| ContentAlignmentData contentAlignment = contentDistributionOffset(availableFreeSpace, position, distribution, numberOfGridTracks);
|
|
|