| Index: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
|
| index 19da7afb077d7826c3fba488e08a0ac4a019bbe8..2e2674a7f2f474d52de0627791ede8b62fcb474a 100644
|
| --- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
|
| +++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
|
| @@ -373,25 +373,60 @@ static PassRefPtrWillBeRawPtr<CSSValue> valueForReflection(const StyleReflection
|
| return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask(), style));
|
| }
|
|
|
| -static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedStyle* style)
|
| +static StyleSelfAlignmentData resolveLegacyJustifyItems(const StyleSelfAlignmentData& data)
|
| {
|
| - if (position != ItemPositionAuto)
|
| - return position;
|
| + if (data.positionType() == LegacyPosition)
|
| + return {data.position(), OverflowAlignmentDefault};
|
| + return data;
|
| +}
|
| +
|
| +static StyleSelfAlignmentData resolveJustifyItemsAuto(const StyleSelfAlignmentData& data, Node* parent)
|
| +{
|
| + if (data.position() != ItemPositionAuto)
|
| + return data;
|
| +
|
| + // If the inherited value of justify-items includes the 'legacy' keyword, 'auto' computes to the inherited value.
|
| + const StyleSelfAlignmentData& inheritedValue = isTreeScopeRoot(parent) ? ComputedStyle::initialDefaultAlignment() : parent->ensureComputedStyle()->justifyItems();
|
| + if (inheritedValue.positionType() == LegacyPosition)
|
| + return inheritedValue;
|
| + if (inheritedValue.position() == ItemPositionAuto)
|
| + return resolveJustifyItemsAuto(inheritedValue, FlatTreeTraversal::parent(*parent));
|
| + return {ItemPositionNormal, OverflowAlignmentDefault};
|
| +}
|
| +
|
| +static StyleSelfAlignmentData resolveJustifySelfAuto(const StyleSelfAlignmentData& data, Node* parent)
|
| +{
|
| + if (data.position() != ItemPositionAuto)
|
| + return data;
|
| +
|
| + // The 'auto' keyword computes to the computed value of justify-items on the parent or 'normal' if the box has no parent.
|
| + if (isTreeScopeRoot(parent))
|
| + return {ItemPositionNormal, OverflowAlignmentDefault};
|
| + return resolveLegacyJustifyItems(resolveJustifyItemsAuto(parent->ensureComputedStyle()->justifyItems(), FlatTreeTraversal::parent(*parent)));
|
| +}
|
| +
|
| +static StyleSelfAlignmentData resolveAlignSelfAuto(const StyleSelfAlignmentData& data, Node* parent)
|
| +{
|
| + if (data.position() != ItemPositionAuto)
|
| + return data;
|
|
|
| if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
|
| - return ItemPositionStretch;
|
| + return {ItemPositionStretch, OverflowAlignmentDefault};
|
|
|
| - return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart;
|
| + // The 'auto' keyword computes to the computed value of align-items on the parent or 'normal' if the box has no parent.
|
| + if (isTreeScopeRoot(parent))
|
| + return {ItemPositionNormal, OverflowAlignmentDefault};
|
| + return parent->ensureComputedStyle()->alignItems();
|
| }
|
|
|
| -static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType)
|
| +static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(const StyleSelfAlignmentData& data)
|
| {
|
| RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
|
| - if (positionType == LegacyPosition)
|
| + if (data.positionType() == LegacyPosition)
|
| result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
|
| - result->append(CSSPrimitiveValue::create(itemPosition));
|
| - if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlignmentDefault)
|
| - result->append(CSSPrimitiveValue::create(overflowAlignment));
|
| + result->append(CSSPrimitiveValue::create(data.position()));
|
| + if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlignmentDefault)
|
| + result->append(CSSPrimitiveValue::create(data.overflow()));
|
| ASSERT(result->length() <= 2);
|
| return result.release();
|
| }
|
| @@ -1611,16 +1646,9 @@ PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID
|
| case CSSPropertyAlignContent:
|
| return valueForContentPositionAndDistributionWithOverflowAlignment(style.alignContent());
|
| case CSSPropertyAlignItems:
|
| - return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegacyPosition);
|
| - case CSSPropertyAlignSelf: {
|
| - ItemPosition position = style.alignSelfPosition();
|
| - if (position == ItemPositionAuto) {
|
| - // TODO(lajava): This code doesn't work for ShadowDOM (see Node::parentComputedStyle)
|
| - const ComputedStyle* parentStyle = styledNode->parentNode() ? styledNode->parentNode()->ensureComputedStyle() : nullptr;
|
| - position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyle, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart;
|
| - }
|
| - return valueForItemPositionWithOverflowAlignment(position, style.alignSelfOverflowAlignment(), NonLegacyPosition);
|
| - }
|
| + return valueForItemPositionWithOverflowAlignment(style.alignItems());
|
| + case CSSPropertyAlignSelf:
|
| + return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style.alignSelf(), FlatTreeTraversal::parent(*styledNode)));
|
| case CSSPropertyFlex:
|
| return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle);
|
| case CSSPropertyFlexBasis:
|
| @@ -1773,11 +1801,9 @@ PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID
|
| case CSSPropertyIsolation:
|
| return cssValuePool().createValue(style.isolation());
|
| case CSSPropertyJustifyItems:
|
| - return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), style.justifyItemsPositionType());
|
| - case CSSPropertyJustifySelf: {
|
| - Node* parent = styledNode->parentNode();
|
| - return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), style.justifySelfOverflowAlignment(), NonLegacyPosition);
|
| - }
|
| + return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style.justifyItems(), FlatTreeTraversal::parent(*styledNode)));
|
| + case CSSPropertyJustifySelf:
|
| + return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style.justifySelf(), FlatTreeTraversal::parent(*styledNode)));
|
| case CSSPropertyLeft:
|
| return valueForPositionOffset(style, CSSPropertyLeft, layoutObject);
|
| case CSSPropertyLetterSpacing:
|
|
|