OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CSSPropertyParserHelpers_h | 5 #ifndef CSSPropertyParserHelpers_h |
6 #define CSSPropertyParserHelpers_h | 6 #define CSSPropertyParserHelpers_h |
7 | 7 |
8 #include "core/css/CSSCustomIdentValue.h" | 8 #include "core/css/CSSCustomIdentValue.h" |
| 9 #include "core/css/CSSIdentifierValue.h" |
9 #include "core/css/CSSPrimitiveValue.h" | 10 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/parser/CSSParserMode.h" | 11 #include "core/css/parser/CSSParserMode.h" |
11 #include "core/css/parser/CSSParserTokenRange.h" | 12 #include "core/css/parser/CSSParserTokenRange.h" |
12 #include "platform/Length.h" // For ValueRange | 13 #include "platform/Length.h" // For ValueRange |
13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class CSSStringValue; | 18 class CSSStringValue; |
18 class CSSURIValue; | 19 class CSSURIValue; |
(...skipping 19 matching lines...) Expand all Loading... |
38 CSSPrimitiveValue* consumeInteger(CSSParserTokenRange&, double minimumValue = -s
td::numeric_limits<double>::max()); | 39 CSSPrimitiveValue* consumeInteger(CSSParserTokenRange&, double minimumValue = -s
td::numeric_limits<double>::max()); |
39 CSSPrimitiveValue* consumePositiveInteger(CSSParserTokenRange&); | 40 CSSPrimitiveValue* consumePositiveInteger(CSSParserTokenRange&); |
40 bool consumeNumberRaw(CSSParserTokenRange&, double& result); | 41 bool consumeNumberRaw(CSSParserTokenRange&, double& result); |
41 CSSPrimitiveValue* consumeNumber(CSSParserTokenRange&, ValueRange); | 42 CSSPrimitiveValue* consumeNumber(CSSParserTokenRange&, ValueRange); |
42 CSSPrimitiveValue* consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange
, UnitlessQuirk = UnitlessQuirk::Forbid); | 43 CSSPrimitiveValue* consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange
, UnitlessQuirk = UnitlessQuirk::Forbid); |
43 CSSPrimitiveValue* consumePercent(CSSParserTokenRange&, ValueRange); | 44 CSSPrimitiveValue* consumePercent(CSSParserTokenRange&, ValueRange); |
44 CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange&, CSSParserMode, V
alueRange, UnitlessQuirk = UnitlessQuirk::Forbid); | 45 CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange&, CSSParserMode, V
alueRange, UnitlessQuirk = UnitlessQuirk::Forbid); |
45 CSSPrimitiveValue* consumeAngle(CSSParserTokenRange&); | 46 CSSPrimitiveValue* consumeAngle(CSSParserTokenRange&); |
46 CSSPrimitiveValue* consumeTime(CSSParserTokenRange&, ValueRange); | 47 CSSPrimitiveValue* consumeTime(CSSParserTokenRange&, ValueRange); |
47 | 48 |
48 CSSPrimitiveValue* consumeIdent(CSSParserTokenRange&); | 49 CSSIdentifierValue* consumeIdent(CSSParserTokenRange&); |
49 CSSPrimitiveValue* consumeIdentRange(CSSParserTokenRange&, CSSValueID lower, CSS
ValueID upper); | 50 CSSIdentifierValue* consumeIdentRange(CSSParserTokenRange&, CSSValueID lower, CS
SValueID upper); |
50 template<CSSValueID, CSSValueID...> inline bool identMatches(CSSValueID id); | 51 template<CSSValueID, CSSValueID...> inline bool identMatches(CSSValueID id); |
51 template<CSSValueID... allowedIdents> CSSPrimitiveValue* consumeIdent(CSSParserT
okenRange&); | 52 template<CSSValueID... allowedIdents> CSSIdentifierValue* consumeIdent(CSSParser
TokenRange&); |
52 | 53 |
53 CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&); | 54 CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&); |
54 CSSStringValue* consumeString(CSSParserTokenRange&); | 55 CSSStringValue* consumeString(CSSParserTokenRange&); |
55 StringView consumeUrlAsStringView(CSSParserTokenRange&); | 56 StringView consumeUrlAsStringView(CSSParserTokenRange&); |
56 CSSURIValue* consumeUrl(CSSParserTokenRange&); | 57 CSSURIValue* consumeUrl(CSSParserTokenRange&); |
57 | 58 |
58 CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyCol
ors = false); | 59 CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyCol
ors = false); |
59 | 60 |
60 CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk
); | 61 CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk
); |
61 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValu
e*& resultX, CSSValue*& resultY); | 62 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValu
e*& resultX, CSSValue*& resultY); |
(...skipping 10 matching lines...) Expand all Loading... |
72 bool isCSSWideKeyword(StringView); | 73 bool isCSSWideKeyword(StringView); |
73 | 74 |
74 // Template implementations are at the bottom of the file for readability. | 75 // Template implementations are at the bottom of the file for readability. |
75 | 76 |
76 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } | 77 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } |
77 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) | 78 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) |
78 { | 79 { |
79 return id == head || identMatches<tail...>(id); | 80 return id == head || identMatches<tail...>(id); |
80 } | 81 } |
81 | 82 |
82 template<CSSValueID... names> CSSPrimitiveValue* consumeIdent(CSSParserTokenRang
e& range) | 83 template<CSSValueID... names> CSSIdentifierValue* consumeIdent(CSSParserTokenRan
ge& range) |
83 { | 84 { |
84 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) | 85 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) |
85 return nullptr; | 86 return nullptr; |
86 return CSSPrimitiveValue::createIdentifier(range.consumeIncludingWhitespace(
).id()); | 87 return CSSIdentifierValue::create(range.consumeIncludingWhitespace().id()); |
87 } | 88 } |
88 | 89 |
89 } // namespace CSSPropertyParserHelpers | 90 } // namespace CSSPropertyParserHelpers |
90 | 91 |
91 } // namespace blink | 92 } // namespace blink |
92 | 93 |
93 #endif // CSSPropertyParserHelpers_h | 94 #endif // CSSPropertyParserHelpers_h |
OLD | NEW |