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..b948ca76ea24851283bd76c3ca56eeb61574f5c7 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,9 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important) |
return false; |
} |
+ case CSSPropertyJustifyContent: |
+ parsedValue = parseContentDistributionOverflowPosition(); |
+ break; |
case CSSPropertyJustifySelf: |
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
return parseItemPositionOverflowPosition(propId, important); |
@@ -4029,11 +4033,29 @@ 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; |
} |
+static bool isAlignmentOverflowKeyword(CSSValueID id) |
+{ |
+ return id == CSSValueTrue || id == CSSValueSafe; |
+} |
+ |
static bool isItemPositionKeyword(CSSValueID id) |
{ |
return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
@@ -4066,6 +4088,50 @@ 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 (isAlignmentOverflowKeyword(value->id)) { |
+ 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 || !isAlignmentOverflowKeyword(value->id)) |
+ return nullptr; |
+ overflow = value->id; |
+ } |
+ |
+ // The grammar states that we should have at least <content-distribution> or |
+ // <content-position> ([ <content-distribution>? && <content-position>? ]!). |
+ 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>? ] |
@@ -4091,12 +4157,12 @@ bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, |
position = cssValuePool().createIdentifierValue(value->id); |
value = m_valueList->next(); |
if (value) { |
- if (value->id == CSSValueTrue || value->id == CSSValueSafe) |
+ if (isAlignmentOverflowKeyword(value->id)) |
overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id); |
else |
return false; |
} |
- } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) { |
+ } else if (isAlignmentOverflowKeyword(value->id)) { |
overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id); |
value = m_valueList->next(); |
if (value && isItemPositionKeyword(value->id)) |