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/CSSValuePool.h" | 8 #include "core/css/CSSValuePool.h" |
9 #include "core/css/parser/CSSParserMode.h" | 9 #include "core/css/parser/CSSParserMode.h" |
10 #include "core/css/parser/CSSParserTokenRange.h" | 10 #include "core/css/parser/CSSParserTokenRange.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 bool consumeCommaIncludingWhitespace(CSSParserTokenRange&); | 26 bool consumeCommaIncludingWhitespace(CSSParserTokenRange&); |
27 bool consumeSlashIncludingWhitespace(CSSParserTokenRange&); | 27 bool consumeSlashIncludingWhitespace(CSSParserTokenRange&); |
28 // consumeFunction expects the range starts with a FunctionToken. | 28 // consumeFunction expects the range starts with a FunctionToken. |
29 CSSParserTokenRange consumeFunction(CSSParserTokenRange&); | 29 CSSParserTokenRange consumeFunction(CSSParserTokenRange&); |
30 | 30 |
31 enum class UnitlessQuirk { | 31 enum class UnitlessQuirk { |
32 Allow, | 32 Allow, |
33 Forbid | 33 Forbid |
34 }; | 34 }; |
35 | 35 |
36 RawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange&, double minimumVal
ue = -std::numeric_limits<double>::max()); | 36 CSSPrimitiveValue* consumeInteger(CSSParserTokenRange&, double minimumValue = -s
td::numeric_limits<double>::max()); |
37 RawPtr<CSSPrimitiveValue> consumePositiveInteger(CSSParserTokenRange&); | 37 CSSPrimitiveValue* consumePositiveInteger(CSSParserTokenRange&); |
38 bool consumeNumberRaw(CSSParserTokenRange&, double& result); | 38 bool consumeNumberRaw(CSSParserTokenRange&, double& result); |
39 RawPtr<CSSPrimitiveValue> consumeNumber(CSSParserTokenRange&, ValueRange); | 39 CSSPrimitiveValue* consumeNumber(CSSParserTokenRange&, ValueRange); |
40 RawPtr<CSSPrimitiveValue> consumeLength(CSSParserTokenRange&, CSSParserMode, Val
ueRange, UnitlessQuirk = UnitlessQuirk::Forbid); | 40 CSSPrimitiveValue* consumeLength(CSSParserTokenRange&, CSSParserMode, ValueRange
, UnitlessQuirk = UnitlessQuirk::Forbid); |
41 RawPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRange&, ValueRange); | 41 CSSPrimitiveValue* consumePercent(CSSParserTokenRange&, ValueRange); |
42 RawPtr<CSSPrimitiveValue> consumeLengthOrPercent(CSSParserTokenRange&, CSSParser
Mode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid); | 42 CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange&, CSSParserMode, V
alueRange, UnitlessQuirk = UnitlessQuirk::Forbid); |
43 RawPtr<CSSPrimitiveValue> consumeAngle(CSSParserTokenRange&); | 43 CSSPrimitiveValue* consumeAngle(CSSParserTokenRange&); |
44 RawPtr<CSSPrimitiveValue> consumeTime(CSSParserTokenRange&, ValueRange); | 44 CSSPrimitiveValue* consumeTime(CSSParserTokenRange&, ValueRange); |
45 | 45 |
46 RawPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&); | 46 CSSPrimitiveValue* consumeIdent(CSSParserTokenRange&); |
47 RawPtr<CSSPrimitiveValue> consumeIdentRange(CSSParserTokenRange&, CSSValueID low
er, CSSValueID upper); | 47 CSSPrimitiveValue* consumeIdentRange(CSSParserTokenRange&, CSSValueID lower, CSS
ValueID upper); |
48 template<CSSValueID, CSSValueID...> inline bool identMatches(CSSValueID id); | 48 template<CSSValueID, CSSValueID...> inline bool identMatches(CSSValueID id); |
49 template<CSSValueID... allowedIdents> RawPtr<CSSPrimitiveValue> consumeIdent(CSS
ParserTokenRange&); | 49 template<CSSValueID... allowedIdents> CSSPrimitiveValue* consumeIdent(CSSParserT
okenRange&); |
50 | 50 |
51 RawPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserTokenRange&); | 51 CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&); |
52 RawPtr<CSSStringValue> consumeString(CSSParserTokenRange&); | 52 CSSStringValue* consumeString(CSSParserTokenRange&); |
53 String consumeUrl(CSSParserTokenRange&); | 53 String consumeUrl(CSSParserTokenRange&); |
54 | 54 |
55 RawPtr<CSSValue> consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQu
irkyColors = false); | 55 CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyCol
ors = false); |
56 | 56 |
57 RawPtr<CSSValuePair> consumePosition(CSSParserTokenRange&, CSSParserMode, Unitle
ssQuirk); | 57 CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk
); |
58 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, RawPtr<
CSSValue>& resultX, RawPtr<CSSValue>& resultY); | 58 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValu
e*& resultX, CSSValue*& resultY); |
59 bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, Unitless
Quirk, RawPtr<CSSValue>& resultX, RawPtr<CSSValue>& resultY); | 59 bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, Unitless
Quirk, CSSValue*& resultX, CSSValue*& resultY); |
60 | 60 |
61 // TODO(timloh): Move across consumeImage | 61 // TODO(timloh): Move across consumeImage |
62 | 62 |
63 // Template implementations are at the bottom of the file for readability. | 63 // Template implementations are at the bottom of the file for readability. |
64 | 64 |
65 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } | 65 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } |
66 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) | 66 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) |
67 { | 67 { |
68 return id == head || identMatches<tail...>(id); | 68 return id == head || identMatches<tail...>(id); |
69 } | 69 } |
70 | 70 |
71 template<CSSValueID... names> RawPtr<CSSPrimitiveValue> consumeIdent(CSSParserTo
kenRange& range) | 71 template<CSSValueID... names> CSSPrimitiveValue* consumeIdent(CSSParserTokenRang
e& range) |
72 { | 72 { |
73 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) | 73 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) |
74 return nullptr; | 74 return nullptr; |
75 return cssValuePool().createIdentifierValue(range.consumeIncludingWhitespace
().id()); | 75 return cssValuePool().createIdentifierValue(range.consumeIncludingWhitespace
().id()); |
76 } | 76 } |
77 | 77 |
78 static inline bool isCSSWideKeyword(const CSSValueID& id) | 78 static inline bool isCSSWideKeyword(const CSSValueID& id) |
79 { | 79 { |
80 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; | 80 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; |
81 } | 81 } |
82 | 82 |
83 } // namespace CSSPropertyParserHelpers | 83 } // namespace CSSPropertyParserHelpers |
84 | 84 |
85 } // namespace blink | 85 } // namespace blink |
86 | 86 |
87 #endif // CSSPropertyParserHelpers_h | 87 #endif // CSSPropertyParserHelpers_h |
OLD | NEW |