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/CSSCalculationValue.h" | 10 #include "core/css/CSSCalculationValue.h" |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 1364 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
1365 } | 1365 } |
1366 | 1366 |
1367 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange
& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk
::Forbid) | 1367 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange
& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk
::Forbid) |
1368 { | 1368 { |
1369 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) | 1369 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) |
1370 return consumeIdent(range); | 1370 return consumeIdent(range); |
1371 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 1371 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
1372 } | 1372 } |
1373 | 1373 |
1374 static PassRefPtrWillBeRawPtr<CSSValue> consumeMarginWidth(CSSParserTokenRange&
range, CSSParserMode cssParserMode, UnitlessQuirk unitless) | 1374 static PassRefPtrWillBeRawPtr<CSSValue> consumeMarginOrOffset(CSSParserTokenRang
e& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) |
1375 { | 1375 { |
1376 if (range.peek().id() == CSSValueAuto) | 1376 if (range.peek().id() == CSSValueAuto) |
1377 return consumeIdent(range); | 1377 return consumeIdent(range); |
1378 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless)
; | 1378 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless)
; |
1379 } | 1379 } |
1380 | 1380 |
1381 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserT
okenRange& range, CSSParserMode cssParserMode) | 1381 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserT
okenRange& range, CSSParserMode cssParserMode) |
1382 { | 1382 { |
1383 if (range.peek().id() == CSSValueAuto) | 1383 if (range.peek().id() == CSSValueAuto) |
1384 return consumeIdent(range); | 1384 return consumeIdent(range); |
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 | 3347 |
3348 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; | 3348 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; |
3349 if (!range.atEnd()) { | 3349 if (!range.atEnd()) { |
3350 mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, cont
ext); | 3350 mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, cont
ext); |
3351 if (!mask) | 3351 if (!mask) |
3352 return nullptr; | 3352 return nullptr; |
3353 } | 3353 } |
3354 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); | 3354 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); |
3355 } | 3355 } |
3356 | 3356 |
| 3357 static PassRefPtrWillBeRawPtr<CSSValue> consumeFontSizeAdjust(CSSParserTokenRang
e& range) |
| 3358 { |
| 3359 if (range.peek().id() == CSSValueNone) |
| 3360 return consumeIdent(range); |
| 3361 return consumeNumber(range, ValueRangeNonNegative); |
| 3362 } |
| 3363 |
| 3364 static PassRefPtrWillBeRawPtr<CSSValue> consumeImageOrientation(CSSParserTokenRa
nge& range, CSSParserMode cssParserMode) |
| 3365 { |
| 3366 if (range.peek().id() == CSSValueFromImage) |
| 3367 return consumeIdent(range); |
| 3368 if (range.peek().type() != NumberToken) { |
| 3369 RefPtrWillBeRawPtr<CSSPrimitiveValue> angle = consumeAngle(range, cssPar
serMode); |
| 3370 if (angle && angle->getDoubleValue() == 0) |
| 3371 return angle; |
| 3372 } |
| 3373 return nullptr; |
| 3374 } |
| 3375 |
3357 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 3376 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
3358 { | 3377 { |
3359 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3378 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3360 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3379 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
3361 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) | 3380 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) |
3362 return nullptr; | 3381 return nullptr; |
3363 return consumeIdent(m_range); | 3382 return consumeIdent(m_range); |
3364 } | 3383 } |
3365 switch (property) { | 3384 switch (property) { |
3366 case CSSPropertyWillChange: | 3385 case CSSPropertyWillChange: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3419 return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow); | 3438 return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow); |
3420 case CSSPropertyWebkitMinLogicalWidth: | 3439 case CSSPropertyWebkitMinLogicalWidth: |
3421 case CSSPropertyWebkitMinLogicalHeight: | 3440 case CSSPropertyWebkitMinLogicalHeight: |
3422 case CSSPropertyWebkitLogicalWidth: | 3441 case CSSPropertyWebkitLogicalWidth: |
3423 case CSSPropertyWebkitLogicalHeight: | 3442 case CSSPropertyWebkitLogicalHeight: |
3424 return consumeWidthOrHeight(m_range, m_context); | 3443 return consumeWidthOrHeight(m_range, m_context); |
3425 case CSSPropertyMarginTop: | 3444 case CSSPropertyMarginTop: |
3426 case CSSPropertyMarginRight: | 3445 case CSSPropertyMarginRight: |
3427 case CSSPropertyMarginBottom: | 3446 case CSSPropertyMarginBottom: |
3428 case CSSPropertyMarginLeft: | 3447 case CSSPropertyMarginLeft: |
3429 return consumeMarginWidth(m_range, m_context.mode(), UnitlessQuirk::Allo
w); | 3448 case CSSPropertyBottom: |
| 3449 case CSSPropertyLeft: |
| 3450 case CSSPropertyRight: |
| 3451 case CSSPropertyTop: |
| 3452 return consumeMarginOrOffset(m_range, m_context.mode(), UnitlessQuirk::A
llow); |
3430 case CSSPropertyWebkitMarginStart: | 3453 case CSSPropertyWebkitMarginStart: |
3431 case CSSPropertyWebkitMarginEnd: | 3454 case CSSPropertyWebkitMarginEnd: |
3432 case CSSPropertyWebkitMarginBefore: | 3455 case CSSPropertyWebkitMarginBefore: |
3433 case CSSPropertyWebkitMarginAfter: | 3456 case CSSPropertyWebkitMarginAfter: |
3434 return consumeMarginWidth(m_range, m_context.mode(), UnitlessQuirk::Forb
id); | 3457 return consumeMarginOrOffset(m_range, m_context.mode(), UnitlessQuirk::F
orbid); |
3435 case CSSPropertyPaddingTop: | 3458 case CSSPropertyPaddingTop: |
3436 case CSSPropertyPaddingRight: | 3459 case CSSPropertyPaddingRight: |
3437 case CSSPropertyPaddingBottom: | 3460 case CSSPropertyPaddingBottom: |
3438 case CSSPropertyPaddingLeft: | 3461 case CSSPropertyPaddingLeft: |
3439 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNe
gative, UnitlessQuirk::Allow); | 3462 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNe
gative, UnitlessQuirk::Allow); |
3440 case CSSPropertyWebkitPaddingStart: | 3463 case CSSPropertyWebkitPaddingStart: |
3441 case CSSPropertyWebkitPaddingEnd: | 3464 case CSSPropertyWebkitPaddingEnd: |
3442 case CSSPropertyWebkitPaddingBefore: | 3465 case CSSPropertyWebkitPaddingBefore: |
3443 case CSSPropertyWebkitPaddingAfter: | 3466 case CSSPropertyWebkitPaddingAfter: |
3444 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNe
gative, UnitlessQuirk::Forbid); | 3467 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNe
gative, UnitlessQuirk::Forbid); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3667 case CSSPropertyBorderImageOutset: | 3690 case CSSPropertyBorderImageOutset: |
3668 case CSSPropertyWebkitMaskBoxImageOutset: | 3691 case CSSPropertyWebkitMaskBoxImageOutset: |
3669 return consumeBorderImageOutset(m_range); | 3692 return consumeBorderImageOutset(m_range); |
3670 case CSSPropertyBorderImageWidth: | 3693 case CSSPropertyBorderImageWidth: |
3671 case CSSPropertyWebkitMaskBoxImageWidth: | 3694 case CSSPropertyWebkitMaskBoxImageWidth: |
3672 return consumeBorderImageWidth(m_range); | 3695 return consumeBorderImageWidth(m_range); |
3673 case CSSPropertyWebkitBorderImage: | 3696 case CSSPropertyWebkitBorderImage: |
3674 return consumeWebkitBorderImage(property, m_range, m_context); | 3697 return consumeWebkitBorderImage(property, m_range, m_context); |
3675 case CSSPropertyWebkitBoxReflect: | 3698 case CSSPropertyWebkitBoxReflect: |
3676 return consumeReflect(m_range, m_context); | 3699 return consumeReflect(m_range, m_context); |
| 3700 case CSSPropertyFontSizeAdjust: |
| 3701 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); |
| 3702 return consumeFontSizeAdjust(m_range); |
| 3703 case CSSPropertyImageOrientation: |
| 3704 ASSERT(RuntimeEnabledFeatures::imageOrientationEnabled()); |
| 3705 return consumeImageOrientation(m_range, m_context.mode()); |
3677 default: | 3706 default: |
3678 CSSParserValueList valueList(m_range); | 3707 CSSParserValueList valueList(m_range); |
3679 if (valueList.size()) { | 3708 if (valueList.size()) { |
3680 m_valueList = &valueList; | 3709 m_valueList = &valueList; |
3681 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve
dProperty)) { | 3710 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve
dProperty)) { |
3682 while (!m_range.atEnd()) | 3711 while (!m_range.atEnd()) |
3683 m_range.consume(); | 3712 m_range.consume(); |
3684 return result.release(); | 3713 return result.release(); |
3685 } | 3714 } |
3686 } | 3715 } |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4361 m_currentShorthand = oldShorthand; | 4390 m_currentShorthand = oldShorthand; |
4362 CSSParserValueList valueList(m_range); | 4391 CSSParserValueList valueList(m_range); |
4363 if (!valueList.size()) | 4392 if (!valueList.size()) |
4364 return false; | 4393 return false; |
4365 m_valueList = &valueList; | 4394 m_valueList = &valueList; |
4366 return legacyParseShorthand(unresolvedProperty, important); | 4395 return legacyParseShorthand(unresolvedProperty, important); |
4367 } | 4396 } |
4368 } | 4397 } |
4369 | 4398 |
4370 } // namespace blink | 4399 } // namespace blink |
OLD | NEW |