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

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: Created 4 years, 10 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 759a76bc973b09a6c9703e3d93b8884c3212420d..d401cd39f1bd756610f0369b6baf070c6611f127 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 (!parent)
+ 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 (parent)
cbiesinger 2016/02/18 20:13:17 I'd prefer if this function were consistent with r
jfernandez 2016/02/18 21:28:57 Acknowledged.
Timothy Loh 2016/02/25 00:23:17 err.. were you going to do this?
jfernandez 2016/02/25 01:52:37 I wanted to get your feedback before providing a n
+ return parent->ensureComputedStyle()->alignItems();
+ return {ItemPositionNormal, OverflowAlignmentDefault};
}
-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();
}
@@ -1575,16 +1589,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:
@@ -1737,11 +1744,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:

Powered by Google App Engine
This is Rietveld 408576698