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 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3262 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu eCenter, CSSValueLeft, CSSValueRight>(rangeCopy); | 3262 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu eCenter, CSSValueLeft, CSSValueRight>(rangeCopy); |
3263 if (!legacy) | 3263 if (!legacy) |
3264 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); | 3264 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); |
3265 if (legacy && positionKeyword) { | 3265 if (legacy && positionKeyword) { |
3266 range = rangeCopy; | 3266 range = rangeCopy; |
3267 return CSSValuePair::create(legacy.release(), positionKeyword.release(), CSSValuePair::DropIdenticalValues); | 3267 return CSSValuePair::create(legacy.release(), positionKeyword.release(), CSSValuePair::DropIdenticalValues); |
3268 } | 3268 } |
3269 return consumeSelfPositionOverflowPosition(range); | 3269 return consumeSelfPositionOverflowPosition(range); |
3270 } | 3270 } |
3271 | 3271 |
3272 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> consumeValidCustomIdentValue( CSSParserTokenRange& range) | |
3273 { | |
3274 if (isCSSWideKeyword(range.peek().id()) || range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) | |
Timothy Loh
2016/03/16 04:24:25
isCSSWideKeyword should be in consumeCustomIdent,
rwlbuis
2016/03/16 17:02:02
Sure, I moved that here:
https://codereview.chromi
| |
3275 return nullptr; | |
3276 return consumeCustomIdent(range); | |
3277 } | |
3278 | |
3279 static PassRefPtrWillBeRawPtr<CSSValue> consumeGridLine(CSSParserTokenRange& ran ge) | |
3280 { | |
3281 if (range.peek().id() == CSSValueAuto) | |
3282 return consumeIdent(range); | |
3283 | |
3284 RefPtrWillBeRawPtr<CSSPrimitiveValue> spanValue = nullptr; | |
3285 RefPtrWillBeRawPtr<CSSCustomIdentValue> gridLineName = nullptr; | |
3286 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = consumeInteger(range); | |
3287 if (numericValue) { | |
3288 gridLineName = consumeValidCustomIdentValue(range); | |
3289 spanValue = consumeIdent<CSSValueSpan>(range); | |
3290 } else if ((spanValue = consumeIdent<CSSValueSpan>(range))) { | |
3291 numericValue = consumeInteger(range); | |
3292 gridLineName = consumeValidCustomIdentValue(range); | |
3293 if (!numericValue) | |
3294 numericValue = consumeInteger(range); | |
3295 } else if ((gridLineName = consumeValidCustomIdentValue(range))) { | |
3296 numericValue = consumeInteger(range); | |
3297 spanValue = consumeIdent<CSSValueSpan>(range); | |
3298 if (!spanValue && !numericValue) | |
3299 return gridLineName.release(); | |
3300 } else { | |
3301 return nullptr; | |
3302 } | |
3303 | |
3304 // Negative numbers are not allowed for span (but are for <integer>). | |
Timothy Loh
2016/03/16 04:24:26
Comment is misleading since <integer> is a type de
rwlbuis
2016/03/16 20:23:42
Done.
| |
3305 if (numericValue && ((spanValue && numericValue->getIntValue() < 0) || (nume ricValue->getIntValue() == 0))) | |
3306 return nullptr; | |
3307 | |
3308 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); | |
3309 if (spanValue) | |
3310 values->append(spanValue.release()); | |
3311 if (numericValue) | |
3312 values->append(numericValue.release()); | |
3313 if (gridLineName) | |
3314 values->append(gridLineName.release()); | |
3315 ASSERT(values->length()); | |
3316 return values.release(); | |
3317 } | |
3318 | |
3272 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) | 3319 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) |
3273 { | 3320 { |
3274 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3321 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3275 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3322 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
3276 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) | 3323 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) |
3277 return nullptr; | 3324 return nullptr; |
3278 return consumeIdent(m_range); | 3325 return consumeIdent(m_range); |
3279 } | 3326 } |
3280 switch (property) { | 3327 switch (property) { |
3281 case CSSPropertyWillChange: | 3328 case CSSPropertyWillChange: |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3624 case CSSPropertyWebkitMaskRepeatY: | 3671 case CSSPropertyWebkitMaskRepeatY: |
3625 return nullptr; | 3672 return nullptr; |
3626 case CSSPropertyJustifySelf: | 3673 case CSSPropertyJustifySelf: |
3627 case CSSPropertyAlignSelf: | 3674 case CSSPropertyAlignSelf: |
3628 case CSSPropertyAlignItems: | 3675 case CSSPropertyAlignItems: |
3629 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3676 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3630 return consumeSelfPositionOverflowPosition(m_range); | 3677 return consumeSelfPositionOverflowPosition(m_range); |
3631 case CSSPropertyJustifyItems: | 3678 case CSSPropertyJustifyItems: |
3632 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3679 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3633 return consumeJustifyItems(m_range); | 3680 return consumeJustifyItems(m_range); |
3681 case CSSPropertyGridColumnEnd: | |
3682 case CSSPropertyGridColumnStart: | |
3683 case CSSPropertyGridRowEnd: | |
3684 case CSSPropertyGridRowStart: | |
3685 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
3686 return consumeGridLine(m_range); | |
3634 default: | 3687 default: |
3635 CSSParserValueList valueList(m_range); | 3688 CSSParserValueList valueList(m_range); |
3636 if (valueList.size()) { | 3689 if (valueList.size()) { |
3637 m_valueList = &valueList; | 3690 m_valueList = &valueList; |
3638 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { | 3691 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { |
3639 while (!m_range.atEnd()) | 3692 while (!m_range.atEnd()) |
3640 m_range.consume(); | 3693 m_range.consume(); |
3641 return result.release(); | 3694 return result.release(); |
3642 } | 3695 } |
3643 } | 3696 } |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4567 m_currentShorthand = oldShorthand; | 4620 m_currentShorthand = oldShorthand; |
4568 CSSParserValueList valueList(m_range); | 4621 CSSParserValueList valueList(m_range); |
4569 if (!valueList.size()) | 4622 if (!valueList.size()) |
4570 return false; | 4623 return false; |
4571 m_valueList = &valueList; | 4624 m_valueList = &valueList; |
4572 return legacyParseShorthand(unresolvedProperty, important); | 4625 return legacyParseShorthand(unresolvedProperty, important); |
4573 } | 4626 } |
4574 } | 4627 } |
4575 | 4628 |
4576 } // namespace blink | 4629 } // namespace blink |
OLD | NEW |