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 ebad2a6608fa008650c88659a11d7dbbb2fcf582..a0350bb790ca4f8c263a143e46254eb290347d3b 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -3066,6 +3066,47 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeGridLine(CSSParserTokenRange& ran |
| return values.release(); |
| } |
| +static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) |
| +{ |
| + const CSSParserToken& token = range.peek(); |
| + if (identMatches<CSSValueMinContent, CSSValueMaxContent, CSSValueAuto>(token.id())) |
|
Timothy Loh
2016/03/22 06:33:59
Maybe nicer if we check the restriction first?
if
rwlbuis
2016/03/22 20:48:12
Done.
|
| + return restriction == AllowAll ? consumeIdent(range) : nullptr; |
| + |
| + if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::Fraction) { |
| + if (restriction == FixedSizeOnly) |
| + return nullptr; |
| + double flexValue = range.consumeIncludingWhitespace().numericValue(); |
|
Timothy Loh
2016/03/22 06:33:59
Probably should finish validating before consuming
rwlbuis
2016/03/22 20:48:12
Done.
|
| + // Fractional unit is a non-negative dimension. |
| + if (flexValue < 0) |
| + return nullptr; |
| + return cssValuePool().createValue(flexValue, CSSPrimitiveValue::UnitType::Fraction); |
| + } |
| + return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow); |
| +} |
| + |
| +static PassRefPtrWillBeRawPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) |
| +{ |
| + const CSSParserToken& token = range.peek(); |
| + if (identMatches<CSSValueAuto>(token.id())) |
|
Timothy Loh
2016/03/22 06:33:59
IMO clearer to not use a ternary and just write
i
rwlbuis
2016/03/22 20:48:12
Done.
|
| + return restriction == AllowAll ? consumeIdent(range) : nullptr; |
| + |
| + if (token.functionId() == CSSValueMinmax) { |
| + // The spec defines the following grammar: minmax( <track-breadth> , <track-breadth> ). |
|
Timothy Loh
2016/03/22 06:33:59
Comment isn't very useful imo
rwlbuis
2016/03/22 20:48:12
Done.
|
| + CSSParserTokenRange args = consumeFunction(range); |
|
Timothy Loh
2016/03/22 06:33:59
Should we make a copy of the range? If the argumen
rwlbuis
2016/03/22 20:48:12
Done.
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBreadth(args, cssParserMode, restriction); |
| + if (!minTrackBreadth || !consumeCommaIncludingWhitespace(args)) |
| + return nullptr; |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBreadth(args, cssParserMode); |
| + if (!maxTrackBreadth || !args.atEnd()) |
| + return nullptr; |
| + RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueMinmax); |
| + result->append(minTrackBreadth.release()); |
| + result->append(maxTrackBreadth.release()); |
| + return result.release(); |
| + } |
| + return consumeGridBreadth(range, cssParserMode, restriction); |
| +} |
| + |
| PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) |
| { |
| CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| @@ -3434,6 +3475,10 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty |
| case CSSPropertyGridRowStart: |
| ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| return consumeGridLine(m_range); |
| + case CSSPropertyGridAutoColumns: |
| + case CSSPropertyGridAutoRows: |
| + ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| + return consumeGridTrackSize(m_range, m_context.mode()); |
| default: |
| CSSParserValueList valueList(m_range); |
| if (valueList.size()) { |