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 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu
eCenter, CSSValueLeft, CSSValueRight>(rangeCopy); | 3276 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu
eCenter, CSSValueLeft, CSSValueRight>(rangeCopy); |
3277 if (!legacy) | 3277 if (!legacy) |
3278 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); | 3278 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); |
3279 if (legacy && positionKeyword) { | 3279 if (legacy && positionKeyword) { |
3280 range = rangeCopy; | 3280 range = rangeCopy; |
3281 return CSSValuePair::create(legacy.release(), positionKeyword.release(),
CSSValuePair::DropIdenticalValues); | 3281 return CSSValuePair::create(legacy.release(), positionKeyword.release(),
CSSValuePair::DropIdenticalValues); |
3282 } | 3282 } |
3283 return consumeSelfPositionOverflowPosition(range); | 3283 return consumeSelfPositionOverflowPosition(range); |
3284 } | 3284 } |
3285 | 3285 |
| 3286 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> consumeCustomIdentForGridLine
(CSSParserTokenRange& range) |
| 3287 { |
| 3288 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) |
| 3289 return nullptr; |
| 3290 return consumeCustomIdent(range); |
| 3291 } |
| 3292 |
| 3293 static PassRefPtrWillBeRawPtr<CSSValue> consumeGridLine(CSSParserTokenRange& ran
ge) |
| 3294 { |
| 3295 if (range.peek().id() == CSSValueAuto) |
| 3296 return consumeIdent(range); |
| 3297 |
| 3298 RefPtrWillBeRawPtr<CSSPrimitiveValue> spanValue = nullptr; |
| 3299 RefPtrWillBeRawPtr<CSSCustomIdentValue> gridLineName = nullptr; |
| 3300 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = consumeInteger(range); |
| 3301 if (numericValue) { |
| 3302 gridLineName = consumeCustomIdentForGridLine(range); |
| 3303 spanValue = consumeIdent<CSSValueSpan>(range); |
| 3304 } else if ((spanValue = consumeIdent<CSSValueSpan>(range))) { |
| 3305 numericValue = consumeInteger(range); |
| 3306 gridLineName = consumeCustomIdentForGridLine(range); |
| 3307 if (!numericValue) |
| 3308 numericValue = consumeInteger(range); |
| 3309 } else if ((gridLineName = consumeCustomIdentForGridLine(range))) { |
| 3310 numericValue = consumeInteger(range); |
| 3311 spanValue = consumeIdent<CSSValueSpan>(range); |
| 3312 if (!spanValue && !numericValue) |
| 3313 return gridLineName.release(); |
| 3314 } else { |
| 3315 return nullptr; |
| 3316 } |
| 3317 |
| 3318 if (spanValue && numericValue && numericValue->getIntValue() < 0) |
| 3319 return nullptr; // Negative numbers are not allowed for span. |
| 3320 if (numericValue && numericValue->getIntValue() == 0) |
| 3321 return nullptr; // An <integer> value of zero makes the declaration inva
lid. |
| 3322 |
| 3323 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
| 3324 if (spanValue) |
| 3325 values->append(spanValue.release()); |
| 3326 if (numericValue) |
| 3327 values->append(numericValue.release()); |
| 3328 if (gridLineName) |
| 3329 values->append(gridLineName.release()); |
| 3330 ASSERT(values->length()); |
| 3331 return values.release(); |
| 3332 } |
| 3333 |
3286 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 3334 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
3287 { | 3335 { |
3288 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3336 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3289 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3337 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
3290 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) | 3338 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) |
3291 return nullptr; | 3339 return nullptr; |
3292 return consumeIdent(m_range); | 3340 return consumeIdent(m_range); |
3293 } | 3341 } |
3294 switch (property) { | 3342 switch (property) { |
3295 case CSSPropertyWillChange: | 3343 case CSSPropertyWillChange: |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3638 case CSSPropertyWebkitMaskRepeatY: | 3686 case CSSPropertyWebkitMaskRepeatY: |
3639 return nullptr; | 3687 return nullptr; |
3640 case CSSPropertyJustifySelf: | 3688 case CSSPropertyJustifySelf: |
3641 case CSSPropertyAlignSelf: | 3689 case CSSPropertyAlignSelf: |
3642 case CSSPropertyAlignItems: | 3690 case CSSPropertyAlignItems: |
3643 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3691 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3644 return consumeSelfPositionOverflowPosition(m_range); | 3692 return consumeSelfPositionOverflowPosition(m_range); |
3645 case CSSPropertyJustifyItems: | 3693 case CSSPropertyJustifyItems: |
3646 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3694 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3647 return consumeJustifyItems(m_range); | 3695 return consumeJustifyItems(m_range); |
| 3696 case CSSPropertyGridColumnEnd: |
| 3697 case CSSPropertyGridColumnStart: |
| 3698 case CSSPropertyGridRowEnd: |
| 3699 case CSSPropertyGridRowStart: |
| 3700 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3701 return consumeGridLine(m_range); |
3648 default: | 3702 default: |
3649 CSSParserValueList valueList(m_range); | 3703 CSSParserValueList valueList(m_range); |
3650 if (valueList.size()) { | 3704 if (valueList.size()) { |
3651 m_valueList = &valueList; | 3705 m_valueList = &valueList; |
3652 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve
dProperty)) { | 3706 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve
dProperty)) { |
3653 while (!m_range.atEnd()) | 3707 while (!m_range.atEnd()) |
3654 m_range.consume(); | 3708 m_range.consume(); |
3655 return result.release(); | 3709 return result.release(); |
3656 } | 3710 } |
3657 } | 3711 } |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4581 m_currentShorthand = oldShorthand; | 4635 m_currentShorthand = oldShorthand; |
4582 CSSParserValueList valueList(m_range); | 4636 CSSParserValueList valueList(m_range); |
4583 if (!valueList.size()) | 4637 if (!valueList.size()) |
4584 return false; | 4638 return false; |
4585 m_valueList = &valueList; | 4639 m_valueList = &valueList; |
4586 return legacyParseShorthand(unresolvedProperty, important); | 4640 return legacyParseShorthand(unresolvedProperty, important); |
4587 } | 4641 } |
4588 } | 4642 } |
4589 | 4643 |
4590 } // namespace blink | 4644 } // namespace blink |
OLD | NEW |