Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| index 9a86f904377ac4763d9f1d77a7d9fc6809781bde..109dd96c185ddde80e44d6d9aadd081f6853d52e 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -7,6 +7,7 @@ |
| #include "core/StylePropertyShorthand.h" |
| #include "core/css/CSSBasicShapeValues.h" |
| #include "core/css/CSSCalculationValue.h" |
| +#include "core/css/CSSContentDistributionValue.h" |
| #include "core/css/CSSCounterValue.h" |
| #include "core/css/CSSCrossfadeValue.h" |
| #include "core/css/CSSCursorImageValue.h" |
| @@ -3148,6 +3149,44 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeShapeOutside(CSSParserTokenRange& |
| return list.release(); |
| } |
| +static PassRefPtrWillBeRawPtr<CSSValue> consumeContentDistributionOverflowPosition(CSSParserTokenRange& range) |
| +{ |
| + if (identMatches<CSSValueAuto, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id())) |
| + return CSSContentDistributionValue::create(CSSValueInvalid, range.consumeIncludingWhitespace().id(), CSSValueInvalid); |
| + |
| + CSSValueID distribution = CSSValueInvalid; |
| + CSSValueID position = CSSValueInvalid; |
| + CSSValueID overflow = CSSValueInvalid; |
| + do { |
| + if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly, CSSValueStretch>(range.peek().id())) { |
|
Timothy Loh
2016/02/01 00:30:58
Maybe nicer if we just write CSSValueID id = range
|
| + if (distribution != CSSValueInvalid) |
| + return nullptr; |
| + distribution = range.consumeIncludingWhitespace().id(); |
| + } else if (identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(range.peek().id())) { |
| + if (position != CSSValueInvalid) |
| + return nullptr; |
| + position = range.consumeIncludingWhitespace().id(); |
| + } else if (identMatches<CSSValueUnsafe, CSSValueSafe>(range.peek().id())) { |
| + if (overflow != CSSValueInvalid) |
| + return nullptr; |
| + overflow = range.consumeIncludingWhitespace().id(); |
| + } else { |
| + return nullptr; |
| + } |
| + } while (!range.atEnd()); |
| + |
| + // The grammar states that we should have at least <content-distribution> or |
| + // <content-position> ( <content-distribution> || <content-position> ). |
|
Timothy Loh
2016/02/01 00:30:58
This comment confused me, since I thought the seco
|
| + if (position == CSSValueInvalid && distribution == CSSValueInvalid) |
| + return nullptr; |
| + |
| + // The grammar states that <overflow-position> must be associated to <content-position>. |
| + if (overflow != CSSValueInvalid && position == CSSValueInvalid) |
| + return nullptr; |
| + |
| + return CSSContentDistributionValue::create(distribution, position, overflow); |
| +} |
| + |
| PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) |
| { |
| CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| @@ -3448,6 +3487,10 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty |
| return consumeShapeOutside(m_range, m_context); |
| case CSSPropertyWebkitClipPath: |
| return consumeClipPath(m_range, m_context); |
| + case CSSPropertyJustifyContent: |
| + case CSSPropertyAlignContent: |
| + ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| + return consumeContentDistributionOverflowPosition(m_range); |
| default: |
| CSSParserValueList valueList(m_range); |
| if (valueList.size()) { |