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

Unified Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied suggested changes. Created 4 years, 9 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
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 82158100fcd84ad2a1b26eed060053aafc4056a3..06338675079958d1f71c2f572bb0f8ea52b2373c 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -373,25 +373,39 @@ 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 resolveJustifySelfAuto(const StyleSelfAlignmentData& data, Node* parent)
{
- if (position != ItemPositionAuto)
- return position;
+ 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))
kochi 2016/03/18 05:19:03 As FlatTreeTraversal::parent() returns shadow host
jfernandez 2016/03/18 13:54:54 This is an interesting question, I don't think it'
+ return {ItemPositionNormal, OverflowAlignmentDefault};
+ return parent->ensureComputedStyle()->justifyItems();
+}
+
+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();
}
@@ -1613,16 +1627,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:
@@ -1775,11 +1782,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(style.justifyItems());
+ case CSSPropertyJustifySelf:
+ return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style.justifySelf(), FlatTreeTraversal::parent(*styledNode)));
case CSSPropertyLeft:
return valueForPositionOffset(style, CSSPropertyLeft, layoutObject);
case CSSPropertyLetterSpacing:
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSProperties.in ('k') | third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698