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

Unified Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 636993002: [CSS Grid Layout] Upgrade justify-content parsing to CSS3 Box Alignment spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Using a custom CSSValue to simplify parsing and style building. Created 6 years, 2 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: 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:

Powered by Google App Engine
This is Rietveld 408576698