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 25 matching lines...) Expand all Loading... |
36 #include "core/css/CSSVariableReferenceValue.h" | 36 #include "core/css/CSSVariableReferenceValue.h" |
37 #include "core/css/FontFace.h" | 37 #include "core/css/FontFace.h" |
38 #include "core/css/HashTools.h" | 38 #include "core/css/HashTools.h" |
39 #include "core/css/parser/CSSParserFastPaths.h" | 39 #include "core/css/parser/CSSParserFastPaths.h" |
40 #include "core/css/parser/CSSParserIdioms.h" | 40 #include "core/css/parser/CSSParserIdioms.h" |
41 #include "core/css/parser/CSSPropertyParserHelpers.h" | 41 #include "core/css/parser/CSSPropertyParserHelpers.h" |
42 #include "core/css/parser/CSSVariableParser.h" | 42 #include "core/css/parser/CSSVariableParser.h" |
43 #include "core/css/parser/FontVariantLigaturesParser.h" | 43 #include "core/css/parser/FontVariantLigaturesParser.h" |
44 #include "core/css/properties/CSSPropertyAlignmentUtils.h" | 44 #include "core/css/properties/CSSPropertyAlignmentUtils.h" |
45 #include "core/css/properties/CSSPropertyDescriptor.h" | 45 #include "core/css/properties/CSSPropertyDescriptor.h" |
| 46 #include "core/css/properties/CSSPropertyPositionUtils.h" |
46 #include "core/frame/UseCounter.h" | 47 #include "core/frame/UseCounter.h" |
47 #include "core/layout/LayoutTheme.h" | 48 #include "core/layout/LayoutTheme.h" |
48 #include "core/svg/SVGPathUtilities.h" | 49 #include "core/svg/SVGPathUtilities.h" |
49 #include "wtf/text/StringBuilder.h" | 50 #include "wtf/text/StringBuilder.h" |
50 #include <memory> | 51 #include <memory> |
51 | 52 |
52 namespace blink { | 53 namespace blink { |
53 | 54 |
54 using namespace CSSPropertyParserHelpers; | 55 using namespace CSSPropertyParserHelpers; |
55 | 56 |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 CSSValue* parsedTransformValue = | 1385 CSSValue* parsedTransformValue = |
1385 consumeTransformValue(range, context, useLegacyParsing); | 1386 consumeTransformValue(range, context, useLegacyParsing); |
1386 if (!parsedTransformValue) | 1387 if (!parsedTransformValue) |
1387 return nullptr; | 1388 return nullptr; |
1388 list->append(*parsedTransformValue); | 1389 list->append(*parsedTransformValue); |
1389 } while (!range.atEnd()); | 1390 } while (!range.atEnd()); |
1390 | 1391 |
1391 return list; | 1392 return list; |
1392 } | 1393 } |
1393 | 1394 |
1394 template <CSSValueID start, CSSValueID end> | |
1395 static CSSValue* consumePositionLonghand(CSSParserTokenRange& range, | |
1396 CSSParserMode cssParserMode) { | |
1397 if (range.peek().type() == IdentToken) { | |
1398 CSSValueID id = range.peek().id(); | |
1399 int percent; | |
1400 if (id == start) | |
1401 percent = 0; | |
1402 else if (id == CSSValueCenter) | |
1403 percent = 50; | |
1404 else if (id == end) | |
1405 percent = 100; | |
1406 else | |
1407 return nullptr; | |
1408 range.consumeIncludingWhitespace(); | |
1409 return CSSPrimitiveValue::create(percent, | |
1410 CSSPrimitiveValue::UnitType::Percentage); | |
1411 } | |
1412 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); | |
1413 } | |
1414 | |
1415 static CSSValue* consumePositionX(CSSParserTokenRange& range, | |
1416 CSSParserMode cssParserMode) { | |
1417 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, | |
1418 cssParserMode); | |
1419 } | |
1420 | |
1421 static CSSValue* consumePositionY(CSSParserTokenRange& range, | |
1422 CSSParserMode cssParserMode) { | |
1423 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, | |
1424 cssParserMode); | |
1425 } | |
1426 | |
1427 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range, | 1395 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range, |
1428 const CSSParserContext* context) { | 1396 const CSSParserContext* context) { |
1429 if (range.peek().id() == CSSValueNone) | 1397 if (range.peek().id() == CSSValueNone) |
1430 return consumeIdent(range); | 1398 return consumeIdent(range); |
1431 return consumeUrl(range, context); | 1399 return consumeUrl(range, context); |
1432 } | 1400 } |
1433 | 1401 |
1434 static CSSValue* consumeBaselineShift(CSSParserTokenRange& range) { | 1402 static CSSValue* consumeBaselineShift(CSSParserTokenRange& range) { |
1435 CSSValueID id = range.peek().id(); | 1403 CSSValueID id = range.peek().id(); |
1436 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 1404 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 case CSSPropertyWebkitBackgroundClip: | 2012 case CSSPropertyWebkitBackgroundClip: |
2045 case CSSPropertyWebkitBackgroundOrigin: | 2013 case CSSPropertyWebkitBackgroundOrigin: |
2046 case CSSPropertyWebkitMaskClip: | 2014 case CSSPropertyWebkitMaskClip: |
2047 case CSSPropertyWebkitMaskOrigin: | 2015 case CSSPropertyWebkitMaskOrigin: |
2048 return consumePrefixedBackgroundBox(unresolvedProperty, range, context); | 2016 return consumePrefixedBackgroundBox(unresolvedProperty, range, context); |
2049 case CSSPropertyBackgroundImage: | 2017 case CSSPropertyBackgroundImage: |
2050 case CSSPropertyWebkitMaskImage: | 2018 case CSSPropertyWebkitMaskImage: |
2051 return consumeImageOrNone(range, context); | 2019 return consumeImageOrNone(range, context); |
2052 case CSSPropertyBackgroundPositionX: | 2020 case CSSPropertyBackgroundPositionX: |
2053 case CSSPropertyWebkitMaskPositionX: | 2021 case CSSPropertyWebkitMaskPositionX: |
2054 return consumePositionX(range, context->mode()); | 2022 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft, |
| 2023 CSSValueRight>( |
| 2024 range, context->mode()); |
2055 case CSSPropertyBackgroundPositionY: | 2025 case CSSPropertyBackgroundPositionY: |
2056 case CSSPropertyWebkitMaskPositionY: | 2026 case CSSPropertyWebkitMaskPositionY: |
2057 return consumePositionY(range, context->mode()); | 2027 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop, |
| 2028 CSSValueBottom>( |
| 2029 range, context->mode()); |
2058 case CSSPropertyBackgroundSize: | 2030 case CSSPropertyBackgroundSize: |
2059 case CSSPropertyAliasWebkitBackgroundSize: | 2031 case CSSPropertyAliasWebkitBackgroundSize: |
2060 case CSSPropertyWebkitMaskSize: | 2032 case CSSPropertyWebkitMaskSize: |
2061 return consumeBackgroundSize(unresolvedProperty, range, context->mode()); | 2033 return consumeBackgroundSize(unresolvedProperty, range, context->mode()); |
2062 case CSSPropertyBackgroundColor: | 2034 case CSSPropertyBackgroundColor: |
2063 return consumeColor(range, context->mode()); | 2035 return consumeColor(range, context->mode()); |
2064 default: | 2036 default: |
2065 break; | 2037 break; |
2066 }; | 2038 }; |
2067 return nullptr; | 2039 return nullptr; |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2785 return consumeOffsetRotate(m_range); | 2757 return consumeOffsetRotate(m_range); |
2786 case CSSPropertyOutlineWidth: | 2758 case CSSPropertyOutlineWidth: |
2787 return consumeLineWidth(m_range, m_context->mode(), | 2759 return consumeLineWidth(m_range, m_context->mode(), |
2788 UnitlessQuirk::Forbid); | 2760 UnitlessQuirk::Forbid); |
2789 case CSSPropertyTransform: | 2761 case CSSPropertyTransform: |
2790 return consumeTransform( | 2762 return consumeTransform( |
2791 m_range, m_context, | 2763 m_range, m_context, |
2792 unresolvedProperty == CSSPropertyAliasWebkitTransform); | 2764 unresolvedProperty == CSSPropertyAliasWebkitTransform); |
2793 case CSSPropertyWebkitTransformOriginX: | 2765 case CSSPropertyWebkitTransformOriginX: |
2794 case CSSPropertyWebkitPerspectiveOriginX: | 2766 case CSSPropertyWebkitPerspectiveOriginX: |
2795 return consumePositionX(m_range, m_context->mode()); | 2767 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft, |
| 2768 CSSValueRight>( |
| 2769 m_range, m_context->mode()); |
2796 case CSSPropertyWebkitTransformOriginY: | 2770 case CSSPropertyWebkitTransformOriginY: |
2797 case CSSPropertyWebkitPerspectiveOriginY: | 2771 case CSSPropertyWebkitPerspectiveOriginY: |
2798 return consumePositionY(m_range, m_context->mode()); | 2772 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop, |
| 2773 CSSValueBottom>( |
| 2774 m_range, m_context->mode()); |
2799 case CSSPropertyMarkerStart: | 2775 case CSSPropertyMarkerStart: |
2800 case CSSPropertyMarkerMid: | 2776 case CSSPropertyMarkerMid: |
2801 case CSSPropertyMarkerEnd: | 2777 case CSSPropertyMarkerEnd: |
2802 case CSSPropertyMask: | 2778 case CSSPropertyMask: |
2803 return consumeNoneOrURI(m_range, m_context); | 2779 return consumeNoneOrURI(m_range, m_context); |
2804 case CSSPropertyFlexGrow: | 2780 case CSSPropertyFlexGrow: |
2805 case CSSPropertyFlexShrink: | 2781 case CSSPropertyFlexShrink: |
2806 return consumeNumber(m_range, ValueRangeNonNegative); | 2782 return consumeNumber(m_range, ValueRangeNonNegative); |
2807 case CSSPropertyColumnRuleWidth: | 2783 case CSSPropertyColumnRuleWidth: |
2808 return consumeColumnRuleWidth(m_range, m_context->mode()); | 2784 return consumeColumnRuleWidth(m_range, m_context->mode()); |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4399 case CSSPropertyGridTemplate: | 4375 case CSSPropertyGridTemplate: |
4400 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); | 4376 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); |
4401 case CSSPropertyGrid: | 4377 case CSSPropertyGrid: |
4402 return consumeGridShorthand(important); | 4378 return consumeGridShorthand(important); |
4403 default: | 4379 default: |
4404 return false; | 4380 return false; |
4405 } | 4381 } |
4406 } | 4382 } |
4407 | 4383 |
4408 } // namespace blink | 4384 } // namespace blink |
OLD | NEW |