Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSPropertyParser.h" | 5 #include "core/css/parser/CSSPropertyParser.h" |
| 6 | 6 |
| 7 #include "core/StylePropertyShorthand.h" | 7 #include "core/StylePropertyShorthand.h" |
| 8 #include "core/css/CSSBasicShapeValues.h" | 8 #include "core/css/CSSBasicShapeValues.h" |
| 9 #include "core/css/CSSBorderImage.h" | 9 #include "core/css/CSSBorderImage.h" |
| 10 #include "core/css/CSSContentDistributionValue.h" | 10 #include "core/css/CSSContentDistributionValue.h" |
| (...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3059 if (spanValue) | 3059 if (spanValue) |
| 3060 values->append(spanValue.release()); | 3060 values->append(spanValue.release()); |
| 3061 if (numericValue) | 3061 if (numericValue) |
| 3062 values->append(numericValue.release()); | 3062 values->append(numericValue.release()); |
| 3063 if (gridLineName) | 3063 if (gridLineName) |
| 3064 values->append(gridLineName.release()); | 3064 values->append(gridLineName.release()); |
| 3065 ASSERT(values->length()); | 3065 ASSERT(values->length()); |
| 3066 return values.release(); | 3066 return values.release(); |
| 3067 } | 3067 } |
| 3068 | 3068 |
| 3069 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTok enRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) | |
| 3070 { | |
| 3071 const CSSParserToken& token = range.peek(); | |
| 3072 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.
| |
| 3073 return restriction == AllowAll ? consumeIdent(range) : nullptr; | |
| 3074 | |
| 3075 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue: :UnitType::Fraction) { | |
| 3076 if (restriction == FixedSizeOnly) | |
| 3077 return nullptr; | |
| 3078 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.
| |
| 3079 // Fractional unit is a non-negative dimension. | |
| 3080 if (flexValue < 0) | |
| 3081 return nullptr; | |
| 3082 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::UnitType ::Fraction); | |
| 3083 } | |
| 3084 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, U nitlessQuirk::Allow); | |
| 3085 } | |
| 3086 | |
| 3087 static PassRefPtrWillBeRawPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange & range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAl l) | |
| 3088 { | |
| 3089 const CSSParserToken& token = range.peek(); | |
| 3090 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.
| |
| 3091 return restriction == AllowAll ? consumeIdent(range) : nullptr; | |
| 3092 | |
| 3093 if (token.functionId() == CSSValueMinmax) { | |
| 3094 // The spec defines the following grammar: minmax( <track-breadth> , <tr ack-breadth> ). | |
|
Timothy Loh
2016/03/22 06:33:59
Comment isn't very useful imo
rwlbuis
2016/03/22 20:48:12
Done.
| |
| 3095 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.
| |
| 3096 RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBread th(args, cssParserMode, restriction); | |
| 3097 if (!minTrackBreadth || !consumeCommaIncludingWhitespace(args)) | |
| 3098 return nullptr; | |
| 3099 RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBread th(args, cssParserMode); | |
| 3100 if (!maxTrackBreadth || !args.atEnd()) | |
| 3101 return nullptr; | |
| 3102 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueMinmax); | |
| 3103 result->append(minTrackBreadth.release()); | |
| 3104 result->append(maxTrackBreadth.release()); | |
| 3105 return result.release(); | |
| 3106 } | |
| 3107 return consumeGridBreadth(range, cssParserMode, restriction); | |
| 3108 } | |
| 3109 | |
| 3069 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) | 3110 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) |
| 3070 { | 3111 { |
| 3071 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3112 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 3072 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3113 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
| 3073 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) | 3114 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) |
| 3074 return nullptr; | 3115 return nullptr; |
| 3075 return consumeIdent(m_range); | 3116 return consumeIdent(m_range); |
| 3076 } | 3117 } |
| 3077 switch (property) { | 3118 switch (property) { |
| 3078 case CSSPropertyWillChange: | 3119 case CSSPropertyWillChange: |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3427 return consumeSelfPositionOverflowPosition(m_range); | 3468 return consumeSelfPositionOverflowPosition(m_range); |
| 3428 case CSSPropertyJustifyItems: | 3469 case CSSPropertyJustifyItems: |
| 3429 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3470 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3430 return consumeJustifyItems(m_range); | 3471 return consumeJustifyItems(m_range); |
| 3431 case CSSPropertyGridColumnEnd: | 3472 case CSSPropertyGridColumnEnd: |
| 3432 case CSSPropertyGridColumnStart: | 3473 case CSSPropertyGridColumnStart: |
| 3433 case CSSPropertyGridRowEnd: | 3474 case CSSPropertyGridRowEnd: |
| 3434 case CSSPropertyGridRowStart: | 3475 case CSSPropertyGridRowStart: |
| 3435 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3476 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3436 return consumeGridLine(m_range); | 3477 return consumeGridLine(m_range); |
| 3478 case CSSPropertyGridAutoColumns: | |
| 3479 case CSSPropertyGridAutoRows: | |
| 3480 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
| 3481 return consumeGridTrackSize(m_range, m_context.mode()); | |
| 3437 default: | 3482 default: |
| 3438 CSSParserValueList valueList(m_range); | 3483 CSSParserValueList valueList(m_range); |
| 3439 if (valueList.size()) { | 3484 if (valueList.size()) { |
| 3440 m_valueList = &valueList; | 3485 m_valueList = &valueList; |
| 3441 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { | 3486 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { |
| 3442 while (!m_range.atEnd()) | 3487 while (!m_range.atEnd()) |
| 3443 m_range.consume(); | 3488 m_range.consume(); |
| 3444 return result.release(); | 3489 return result.release(); |
| 3445 } | 3490 } |
| 3446 } | 3491 } |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4440 m_currentShorthand = oldShorthand; | 4485 m_currentShorthand = oldShorthand; |
| 4441 CSSParserValueList valueList(m_range); | 4486 CSSParserValueList valueList(m_range); |
| 4442 if (!valueList.size()) | 4487 if (!valueList.size()) |
| 4443 return false; | 4488 return false; |
| 4444 m_valueList = &valueList; | 4489 m_valueList = &valueList; |
| 4445 return legacyParseShorthand(unresolvedProperty, important); | 4490 return legacyParseShorthand(unresolvedProperty, important); |
| 4446 } | 4491 } |
| 4447 } | 4492 } |
| 4448 | 4493 |
| 4449 } // namespace blink | 4494 } // namespace blink |
| OLD | NEW |