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/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/CSSContentDistributionValue.h" | |
10 #include "core/css/CSSCounterValue.h" | 11 #include "core/css/CSSCounterValue.h" |
11 #include "core/css/CSSCrossfadeValue.h" | 12 #include "core/css/CSSCrossfadeValue.h" |
12 #include "core/css/CSSCursorImageValue.h" | 13 #include "core/css/CSSCursorImageValue.h" |
13 #include "core/css/CSSCustomIdentValue.h" | 14 #include "core/css/CSSCustomIdentValue.h" |
14 #include "core/css/CSSFontFaceSrcValue.h" | 15 #include "core/css/CSSFontFaceSrcValue.h" |
15 #include "core/css/CSSFontFeatureValue.h" | 16 #include "core/css/CSSFontFeatureValue.h" |
16 #include "core/css/CSSFunctionValue.h" | 17 #include "core/css/CSSFunctionValue.h" |
17 #include "core/css/CSSImageSetValue.h" | 18 #include "core/css/CSSImageSetValue.h" |
18 #include "core/css/CSSPathValue.h" | 19 #include "core/css/CSSPathValue.h" |
19 #include "core/css/CSSPrimitiveValueMappings.h" | 20 #include "core/css/CSSPrimitiveValueMappings.h" |
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3141 if (list->length() < 2) { | 3142 if (list->length() < 2) { |
3142 if (RefPtrWillBeRawPtr<CSSValue> boxValue = consumeIdent<CSSValueCon tentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) | 3143 if (RefPtrWillBeRawPtr<CSSValue> boxValue = consumeIdent<CSSValueCon tentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) |
3143 list->append(boxValue.release()); | 3144 list->append(boxValue.release()); |
3144 } | 3145 } |
3145 } | 3146 } |
3146 if (!list->length()) | 3147 if (!list->length()) |
3147 return nullptr; | 3148 return nullptr; |
3148 return list.release(); | 3149 return list.release(); |
3149 } | 3150 } |
3150 | 3151 |
3152 static PassRefPtrWillBeRawPtr<CSSValue> consumeContentDistributionOverflowPositi on(CSSParserTokenRange& range) | |
3153 { | |
3154 if (identMatches<CSSValueAuto, CSSValueBaseline, CSSValueLastBaseline>(range .peek().id())) | |
3155 return CSSContentDistributionValue::create(CSSValueInvalid, range.consum eIncludingWhitespace().id(), CSSValueInvalid); | |
3156 | |
3157 CSSValueID distribution = CSSValueInvalid; | |
3158 CSSValueID position = CSSValueInvalid; | |
3159 CSSValueID overflow = CSSValueInvalid; | |
3160 do { | |
3161 if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpac eEvenly, CSSValueStretch>(range.peek().id())) { | |
Timothy Loh
2016/02/01 00:30:58
Maybe nicer if we just write CSSValueID id = range
| |
3162 if (distribution != CSSValueInvalid) | |
3163 return nullptr; | |
3164 distribution = range.consumeIncludingWhitespace().id(); | |
3165 } else if (identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSV alueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(range.peek().id())) { | |
3166 if (position != CSSValueInvalid) | |
3167 return nullptr; | |
3168 position = range.consumeIncludingWhitespace().id(); | |
3169 } else if (identMatches<CSSValueUnsafe, CSSValueSafe>(range.peek().id()) ) { | |
3170 if (overflow != CSSValueInvalid) | |
3171 return nullptr; | |
3172 overflow = range.consumeIncludingWhitespace().id(); | |
3173 } else { | |
3174 return nullptr; | |
3175 } | |
3176 } while (!range.atEnd()); | |
3177 | |
3178 // The grammar states that we should have at least <content-distribution> or | |
3179 // <content-position> ( <content-distribution> || <content-position> ). | |
Timothy Loh
2016/02/01 00:30:58
This comment confused me, since I thought the seco
| |
3180 if (position == CSSValueInvalid && distribution == CSSValueInvalid) | |
3181 return nullptr; | |
3182 | |
3183 // The grammar states that <overflow-position> must be associated to <conten t-position>. | |
3184 if (overflow != CSSValueInvalid && position == CSSValueInvalid) | |
3185 return nullptr; | |
3186 | |
3187 return CSSContentDistributionValue::create(distribution, position, overflow) ; | |
3188 } | |
3189 | |
3151 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) | 3190 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) |
3152 { | 3191 { |
3153 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3192 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3154 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3193 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
3155 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) | 3194 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) |
3156 return nullptr; | 3195 return nullptr; |
3157 return consumeIdent(m_range); | 3196 return consumeIdent(m_range); |
3158 } | 3197 } |
3159 switch (property) { | 3198 switch (property) { |
3160 case CSSPropertyWillChange: | 3199 case CSSPropertyWillChange: |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3441 case CSSPropertyTextUnderlinePosition: | 3480 case CSSPropertyTextUnderlinePosition: |
3442 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now | 3481 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now |
3443 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 3482 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); |
3444 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range); | 3483 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range); |
3445 case CSSPropertyVerticalAlign: | 3484 case CSSPropertyVerticalAlign: |
3446 return consumeVerticalAlign(m_range, m_context.mode()); | 3485 return consumeVerticalAlign(m_range, m_context.mode()); |
3447 case CSSPropertyShapeOutside: | 3486 case CSSPropertyShapeOutside: |
3448 return consumeShapeOutside(m_range, m_context); | 3487 return consumeShapeOutside(m_range, m_context); |
3449 case CSSPropertyWebkitClipPath: | 3488 case CSSPropertyWebkitClipPath: |
3450 return consumeClipPath(m_range, m_context); | 3489 return consumeClipPath(m_range, m_context); |
3490 case CSSPropertyJustifyContent: | |
3491 case CSSPropertyAlignContent: | |
3492 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
3493 return consumeContentDistributionOverflowPosition(m_range); | |
3451 default: | 3494 default: |
3452 CSSParserValueList valueList(m_range); | 3495 CSSParserValueList valueList(m_range); |
3453 if (valueList.size()) { | 3496 if (valueList.size()) { |
3454 m_valueList = &valueList; | 3497 m_valueList = &valueList; |
3455 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { | 3498 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { |
3456 while (!m_range.atEnd()) | 3499 while (!m_range.atEnd()) |
3457 m_range.consume(); | 3500 m_range.consume(); |
3458 return result.release(); | 3501 return result.release(); |
3459 } | 3502 } |
3460 } | 3503 } |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4101 m_currentShorthand = oldShorthand; | 4144 m_currentShorthand = oldShorthand; |
4102 CSSParserValueList valueList(m_range); | 4145 CSSParserValueList valueList(m_range); |
4103 if (!valueList.size()) | 4146 if (!valueList.size()) |
4104 return false; | 4147 return false; |
4105 m_valueList = &valueList; | 4148 m_valueList = &valueList; |
4106 return legacyParseShorthand(unresolvedProperty, important); | 4149 return legacyParseShorthand(unresolvedProperty, important); |
4107 } | 4150 } |
4108 } | 4151 } |
4109 | 4152 |
4110 } // namespace blink | 4153 } // namespace blink |
OLD | NEW |