Chromium Code Reviews| Index: Source/core/css/CSSComputedStyleDeclaration.cpp |
| diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp |
| index 7696f213d8697b8bb6d83a7b7e924da7ec232a32..3c80c611f7c4dd5a95e3e8012f101ca9b9986228 100644 |
| --- a/Source/core/css/CSSComputedStyleDeclaration.cpp |
| +++ b/Source/core/css/CSSComputedStyleDeclaration.cpp |
| @@ -1545,6 +1545,22 @@ static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) |
| return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart; |
| } |
| +static void resolveAlignmentContentAuto(RenderStyle& style) |
| +{ |
| + if (style.justifyContent() != ContentPositionAuto || style.justifyContentDistribution() != ContentDistributionDefault) |
| + return; |
| + |
| + // Block Containers: For table cells, the behavior of the 'auto' depends on the computed |
| + // value of 'vertical-align', otherwise behaves as 'start'. |
| + // Flex Containers: 'auto' computes to 'stretch'. |
| + // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like 'start'. |
| + if (style.isDisplayFlexibleBox()) { |
| + style.setJustifyContent(ContentPositionFlexStart); |
| + } else { |
| + style.setJustifyContent(ContentPositionStart); |
|
Julien - ping for review
2014/10/28 17:23:04
Mutating the RenderStyle is not an option AFAICT:
jfernandez
2014/10/29 11:03:04
Agree. Actually, this logic is not needed since th
|
| + } |
| +} |
| + |
| static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType) |
| { |
| RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); |
| @@ -1557,6 +1573,20 @@ static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig |
| return result.release(); |
| } |
| +static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributionWithOverflowAlignment(ContentPosition position, OverflowAlignment overflowAlignment, ContentDistributionType distribution) |
| +{ |
| + RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); |
| + if (distribution != ContentDistributionDefault) |
| + result->append(CSSPrimitiveValue::create(distribution)); |
| + if (distribution == ContentDistributionDefault || position != ContentPositionAuto) |
| + result->append(CSSPrimitiveValue::create(position)); |
| + if ((position >= ContentPositionCenter || distribution != ContentDistributionDefault) && overflowAlignment != OverflowAlignmentDefault) |
| + result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| + ASSERT(result->length() > 0); |
| + ASSERT(result->length() <= 3); |
| + return result.release(); |
| +} |
| + |
| PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
| { |
| Node* styledNode = this->styledNode(); |
| @@ -1844,7 +1874,8 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
| case CSSPropertyFlexWrap: |
| return cssValuePool().createValue(style->flexWrap()); |
| case CSSPropertyJustifyContent: |
| - return cssValuePool().createValue(style->justifyContent()); |
| + resolveAlignmentContentAuto(*style); |
| + return valueForContentPositionAndDistributionWithOverflowAlignment(style->justifyContent(), style->justifyContentOverflowAlignment(), style->justifyContentDistribution()); |
| case CSSPropertyOrder: |
| return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER); |
| case CSSPropertyFloat: |