Index: Source/core/css/parser/CSSPropertyParser.cpp |
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp |
index b1e2d1cc5495c2fe930e1888fa1f0c29ba8014eb..13be783e2f80cc116a7788e8721a516a72d104ae 100644 |
--- a/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -33,6 +33,7 @@ |
#include "core/css/CSSBasicShapes.h" |
#include "core/css/CSSBorderImage.h" |
#include "core/css/CSSCanvasValue.h" |
+#include "core/css/CSSContentDistributionValue.h" |
#include "core/css/CSSCrossfadeValue.h" |
#include "core/css/CSSCursorImageValue.h" |
#include "core/css/CSSFontFaceSrcValue.h" |
@@ -1202,6 +1203,10 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important) |
return false; |
} |
+ case CSSPropertyJustifyContent: |
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
+ parsedValue = parseContentDistributionOverflowPosition(); |
+ break; |
case CSSPropertyJustifySelf: |
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
return parseItemPositionOverflowPosition(propId, important); |
@@ -4029,6 +4034,19 @@ PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS |
return shape; |
} |
+static bool isContentDistributionKeyword(CSSValueID id) |
+{ |
+ return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
+ || id == CSSValueSpaceEvenly || id == CSSValueStretch; |
+} |
+ |
+static bool isContentPositionKeyword(CSSValueID id) |
+{ |
+ return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
+ || id == CSSValueFlexStart || id == CSSValueFlexEnd |
+ || id == CSSValueLeft || id == CSSValueRight; |
+} |
+ |
static bool isBaselinePositionKeyword(CSSValueID id) |
{ |
return id == CSSValueBaseline || id == CSSValueLastBaseline; |
@@ -4066,6 +4084,49 @@ bool CSSPropertyParser::parseLegacyPosition(CSSPropertyID propId, bool important |
return !m_valueList->next(); |
} |
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOverflowPosition() |
+{ |
+ // auto | <baseline-position> | [ <content-distribution>? && <content-position>? ]! && <overflow-position>? |
+ // <baseline-position> = baseline | last-baseline; |
+ // <content-distribution> = space-between | space-around | space-evenly | stretch; |
+ // <content-position> = center | start | end | flex-start | flex-end | left | right; |
+ // <overflow-position> = true | safe |
+ |
+ // auto | <baseline-position> |
+ CSSParserValue* value = m_valueList->current(); |
+ if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { |
+ m_valueList->next(); |
+ return CSSContentDistributionValue::create(CSSValueInvalid, value->id, CSSValueInvalid); |
+ } |
+ |
+ CSSValueID distribution = CSSValueInvalid; |
+ CSSValueID position = CSSValueInvalid; |
+ CSSValueID overflow = CSSValueInvalid; |
+ if (value->id == CSSValueTrue || value->id == CSSValueSafe) { |
Julien - ping for review
2014/10/28 17:23:05
We should add a helper function for these too!
jfernandez
2014/10/29 11:03:05
Done.
|
+ overflow = value->id; |
+ value = m_valueList->next(); |
+ } |
+ if (value && isContentDistributionKeyword(value->id)) { |
+ distribution = value->id; |
+ value = m_valueList->next(); |
+ } |
+ if (value && isContentPositionKeyword(value->id)) { |
+ position = value->id; |
+ value = m_valueList->next(); |
+ } |
+ if (value) { |
+ if (overflow != CSSValueInvalid || (value->id != CSSValueTrue && value->id != CSSValueSafe)) |
+ return nullptr; |
+ overflow = value->id; |
+ } |
+ |
+ // [ <content-distribution>? && <content-position>? ]! |
Julien - ping for review
2014/10/28 17:23:05
It would be better to state it in English:
// The
jfernandez
2014/10/29 11:03:05
Done.
|
+ if (m_valueList->next() || (position == CSSValueInvalid && distribution == CSSValueInvalid)) |
+ return nullptr; |
+ |
+ return CSSContentDistributionValue::create(distribution, position, overflow); |
+} |
+ |
bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important) |
{ |
// auto | stretch | <baseline-position> | [<item-position> && <overflow-position>? ] |