Chromium Code Reviews| Index: Source/core/css/CSSComputedStyleDeclaration.cpp |
| diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp |
| index 1c1eb5780f5380fa6fc7e183fc073d7bb97ed3fa..2d3fafa60f8ed1fffbe23f6ee37174ebba48c5ab 100644 |
| --- a/Source/core/css/CSSComputedStyleDeclaration.cpp |
| +++ b/Source/core/css/CSSComputedStyleDeclaration.cpp |
| @@ -136,6 +136,7 @@ static const CSSPropertyID staticComputableProperties[] = { |
| CSSPropertyHeight, |
| CSSPropertyImageRendering, |
| CSSPropertyIsolation, |
| + CSSPropertyJustifyItems, |
| CSSPropertyJustifySelf, |
| CSSPropertyLeft, |
| CSSPropertyLetterSpacing, |
| @@ -1554,12 +1555,15 @@ Node* CSSComputedStyleDeclaration::styledNode() const |
| return m_node.get(); |
| } |
| -static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment) |
| +static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, LegacyPosition isLegacy) |
| { |
| RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); |
| + if (isLegacy == LegacyPositionTrue) |
| + result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
| result->append(CSSPrimitiveValue::create(itemPosition)); |
| if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlignmentDefault) |
| result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| + ASSERT(result->length() <= 2); |
| return result.release(); |
| } |
| @@ -1886,7 +1890,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
| case CSSPropertyAlignContent: |
| return cssValuePool().createValue(style->alignContent()); |
| case CSSPropertyAlignItems: |
| - return valueForItemPositionWithOverflowAlignment(style->alignItems(), style->alignItemsOverflowAlignment()); |
| + return valueForItemPositionWithOverflowAlignment(style->alignItems(), style->alignItemsOverflowAlignment(), LegacyPositionFalse); |
| case CSSPropertyAlignSelf: { |
| ItemPosition alignSelf = style->alignSelf(); |
| if (alignSelf == ItemPositionAuto) { |
| @@ -1896,7 +1900,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
| else |
| alignSelf = ItemPositionStretch; |
| } |
| - return valueForItemPositionWithOverflowAlignment(alignSelf, style->alignSelfOverflowAlignment()); |
| + return valueForItemPositionWithOverflowAlignment(alignSelf, style->alignSelfOverflowAlignment(), LegacyPositionFalse); |
| } |
| case CSSPropertyFlex: |
| return valuesForShorthandProperty(flexShorthand()); |
| @@ -2027,8 +2031,43 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
| return CSSPrimitiveValue::create(style->imageRendering()); |
| case CSSPropertyIsolation: |
| return cssValuePool().createValue(style->isolation()); |
| - case CSSPropertyJustifySelf: |
| - return valueForItemPositionWithOverflowAlignment(style->justifySelf(), style->justifySelfOverflowAlignment()); |
| + case CSSPropertyJustifyItems: { |
| + ItemPosition justifyItems = style->justifyItems(); |
| + LegacyPosition isLegacy = style->justifyItemsIsLegacy(); |
| + if (justifyItems == ItemPositionAuto) { |
| + Node* parent = styledNode->parentNode(); |
| + // If the inherited value of justify-items includes the legacy keyword, 'auto' |
| + // computes to the the inherited value. |
| + if (parent && parent->computedStyle() && parent->computedStyle()->justifyItemsIsLegacy()) { |
| + justifyItems = parent->computedStyle()->justifyItems(); |
| + isLegacy = parent->computedStyle()->justifyItemsIsLegacy(); |
| + // Otherwise, auto computes to: |
| + } else if (style->isDisplayFlexibleOrGridBox()) { |
| + // 'stretch' for flex containers and grid containers. |
| + justifyItems = ItemPositionStretch; |
| + } else { |
| + // 'start' for everything else. |
| + justifyItems = ItemPositionStart; |
| + } |
|
Julien - ping for review
2014/06/26 17:37:20
I would like this to be tested. This is not possib
jfernandez
2014/06/26 22:36:05
Such logic is already covered by the provided layo
|
| + } |
| + return valueForItemPositionWithOverflowAlignment(justifyItems, style->justifyItemsOverflowAlignment(), isLegacy); |
| + } |
| + case CSSPropertyJustifySelf: { |
| + ItemPosition justifySelf = style->justifySelf(); |
| + if (justifySelf == ItemPositionAuto) { |
| + // The auto keyword computes to stretch on absolutely-positioned elements, |
| + if (style->position() == AbsolutePosition) { |
| + justifySelf = ItemPositionStretch; |
| + } else { |
| + // and to the computed value of justify-items on the parent (minus |
| + // any legacy keywords) on all other boxes. |
| + Node* parent = styledNode->parentNode(); |
| + if (parent && parent->computedStyle()) |
| + justifySelf = parent->computedStyle()->justifyItems(); |
| + } |
| + } |
|
Julien - ping for review
2014/06/26 17:37:20
Ditto.
jfernandez
2014/06/26 22:36:05
Done.
|
| + return valueForItemPositionWithOverflowAlignment(justifySelf, style->justifySelfOverflowAlignment(), LegacyPositionFalse); |
| + } |
| case CSSPropertyLeft: |
| return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
| case CSSPropertyLetterSpacing: |