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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
7 | 7 |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/CSSCustomIdentValue.h" | 10 #include "core/css/CSSCustomIdentValue.h" |
11 #include "core/css/CSSFontFaceSrcValue.h" | 11 #include "core/css/CSSFontFaceSrcValue.h" |
12 #include "core/css/CSSFontFeatureValue.h" | 12 #include "core/css/CSSFontFeatureValue.h" |
13 #include "core/css/CSSPrimitiveValueMappings.h" | 13 #include "core/css/CSSPrimitiveValueMappings.h" |
| 14 #include "core/css/CSSQuadValue.h" |
14 #include "core/css/CSSStringValue.h" | 15 #include "core/css/CSSStringValue.h" |
15 #include "core/css/CSSURIValue.h" | 16 #include "core/css/CSSURIValue.h" |
16 #include "core/css/CSSUnicodeRangeValue.h" | 17 #include "core/css/CSSUnicodeRangeValue.h" |
17 #include "core/css/CSSValuePair.h" | 18 #include "core/css/CSSValuePair.h" |
18 #include "core/css/CSSValuePool.h" | 19 #include "core/css/CSSValuePool.h" |
19 #include "core/css/FontFace.h" | 20 #include "core/css/FontFace.h" |
20 #include "core/css/parser/CSSParserFastPaths.h" | 21 #include "core/css/parser/CSSParserFastPaths.h" |
21 #include "core/css/parser/CSSParserValues.h" | 22 #include "core/css/parser/CSSParserValues.h" |
22 #include "core/frame/UseCounter.h" | 23 #include "core/frame/UseCounter.h" |
23 #include "core/layout/LayoutTheme.h" | 24 #include "core/layout/LayoutTheme.h" |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 795 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
795 } | 796 } |
796 | 797 |
797 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange
& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk
::Forbid) | 798 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange
& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk
::Forbid) |
798 { | 799 { |
799 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) | 800 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) |
800 return consumeIdent(range); | 801 return consumeIdent(range); |
801 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 802 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
802 } | 803 } |
803 | 804 |
| 805 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserT
okenRange& range, CSSParserMode cssParserMode) |
| 806 { |
| 807 if (range.peek().id() == CSSValueAuto) |
| 808 return consumeIdent(range); |
| 809 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All
ow); |
| 810 } |
| 811 |
| 812 static PassRefPtrWillBeRawPtr<CSSValue> consumeClip(CSSParserTokenRange& range,
CSSParserMode cssParserMode) |
| 813 { |
| 814 if (range.peek().id() == CSSValueAuto) |
| 815 return consumeIdent(range); |
| 816 |
| 817 if (range.peek().functionId() != CSSValueRect) |
| 818 return nullptr; |
| 819 |
| 820 CSSParserTokenRange args = consumeFunction(range); |
| 821 // rect(t, r, b, l) || rect(t r b l) |
| 822 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = consumeClipComponent(args, cssPa
rserMode); |
| 823 if (!top) |
| 824 return nullptr; |
| 825 bool needsComma = consumeCommaIncludingWhitespace(args); |
| 826 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = consumeClipComponent(args, css
ParserMode); |
| 827 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args))) |
| 828 return nullptr; |
| 829 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = consumeClipComponent(args, cs
sParserMode); |
| 830 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args))) |
| 831 return nullptr; |
| 832 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = consumeClipComponent(args, cssP
arserMode); |
| 833 if (!left || !args.atEnd()) |
| 834 return nullptr; |
| 835 return CSSQuadValue::create(top.release(), right.release(), bottom.release()
, left.release(), CSSQuadValue::SerializeAsRect); |
| 836 } |
| 837 |
804 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID propId) | 838 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID propId) |
805 { | 839 { |
806 m_range.consumeWhitespace(); | 840 m_range.consumeWhitespace(); |
807 switch (propId) { | 841 switch (propId) { |
808 case CSSPropertyWillChange: | 842 case CSSPropertyWillChange: |
809 return consumeWillChange(m_range); | 843 return consumeWillChange(m_range); |
810 case CSSPropertyPage: | 844 case CSSPropertyPage: |
811 return consumePage(m_range); | 845 return consumePage(m_range); |
812 case CSSPropertyQuotes: | 846 case CSSPropertyQuotes: |
813 return consumeQuotes(m_range); | 847 return consumeQuotes(m_range); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 case CSSPropertyMinWidth: | 887 case CSSPropertyMinWidth: |
854 case CSSPropertyMinHeight: | 888 case CSSPropertyMinHeight: |
855 case CSSPropertyWidth: | 889 case CSSPropertyWidth: |
856 case CSSPropertyHeight: | 890 case CSSPropertyHeight: |
857 return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow); | 891 return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow); |
858 case CSSPropertyWebkitMinLogicalWidth: | 892 case CSSPropertyWebkitMinLogicalWidth: |
859 case CSSPropertyWebkitMinLogicalHeight: | 893 case CSSPropertyWebkitMinLogicalHeight: |
860 case CSSPropertyWebkitLogicalWidth: | 894 case CSSPropertyWebkitLogicalWidth: |
861 case CSSPropertyWebkitLogicalHeight: | 895 case CSSPropertyWebkitLogicalHeight: |
862 return consumeWidthOrHeight(m_range, m_context); | 896 return consumeWidthOrHeight(m_range, m_context); |
| 897 case CSSPropertyClip: |
| 898 return consumeClip(m_range, m_context.mode()); |
863 default: | 899 default: |
864 return nullptr; | 900 return nullptr; |
865 } | 901 } |
866 } | 902 } |
867 | 903 |
868 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 904 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
869 { | 905 { |
870 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 906 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
871 | 907 |
872 do { | 908 do { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 } | 1283 } |
1248 case CSSPropertyBorderSpacing: | 1284 case CSSPropertyBorderSpacing: |
1249 return consumeBorderSpacing(important); | 1285 return consumeBorderSpacing(important); |
1250 default: | 1286 default: |
1251 m_currentShorthand = oldShorthand; | 1287 m_currentShorthand = oldShorthand; |
1252 return false; | 1288 return false; |
1253 } | 1289 } |
1254 } | 1290 } |
1255 | 1291 |
1256 } // namespace blink | 1292 } // namespace blink |
OLD | NEW |