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/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/parser/CSSParserMode.h" | 10 #include "core/css/parser/CSSParserMode.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&); | 52 CSSCustomIdentValue* consumeCustomIdent(CSSParserTokenRange&); |
53 CSSStringValue* consumeString(CSSParserTokenRange&); | 53 CSSStringValue* consumeString(CSSParserTokenRange&); |
54 StringView consumeUrl(CSSParserTokenRange&); | 54 StringView consumeUrl(CSSParserTokenRange&); |
55 | 55 |
56 CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyCol
ors = false); | 56 CSSValue* consumeColor(CSSParserTokenRange&, CSSParserMode, bool acceptQuirkyCol
ors = false); |
57 | 57 |
58 CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk
); | 58 CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk
); |
59 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValu
e*& resultX, CSSValue*& resultY); | 59 bool consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, CSSValu
e*& resultX, CSSValue*& resultY); |
60 bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, Unitless
Quirk, CSSValue*& resultX, CSSValue*& resultY); | 60 bool consumeOneOrTwoValuedPosition(CSSParserTokenRange&, CSSParserMode, Unitless
Quirk, CSSValue*& resultX, CSSValue*& resultY); |
61 | 61 |
62 // TODO(timloh): Move across consumeImage | 62 enum class ConsumeGeneratedImage { |
| 63 Allow, |
| 64 Forbid |
| 65 }; |
| 66 |
| 67 CSSValue* consumeImage(CSSParserTokenRange&, CSSParserContext, ConsumeGeneratedI
mage = ConsumeGeneratedImage::Allow); |
| 68 CSSValue* consumeImageOrNone(CSSParserTokenRange&, CSSParserContext); |
63 | 69 |
64 // Template implementations are at the bottom of the file for readability. | 70 // Template implementations are at the bottom of the file for readability. |
65 | 71 |
66 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } | 72 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) { re
turn false; } |
67 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) | 73 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueI
D id) |
68 { | 74 { |
69 return id == head || identMatches<tail...>(id); | 75 return id == head || identMatches<tail...>(id); |
70 } | 76 } |
71 | 77 |
72 template<CSSValueID... names> CSSPrimitiveValue* consumeIdent(CSSParserTokenRang
e& range) | 78 template<CSSValueID... names> CSSPrimitiveValue* consumeIdent(CSSParserTokenRang
e& range) |
73 { | 79 { |
74 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) | 80 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) |
75 return nullptr; | 81 return nullptr; |
76 return CSSPrimitiveValue::createIdentifier(range.consumeIncludingWhitespace(
).id()); | 82 return CSSPrimitiveValue::createIdentifier(range.consumeIncludingWhitespace(
).id()); |
77 } | 83 } |
78 | 84 |
79 static inline bool isCSSWideKeyword(const CSSValueID& id) | 85 static inline bool isCSSWideKeyword(const CSSValueID& id) |
80 { | 86 { |
81 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; | 87 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; |
82 } | 88 } |
83 | 89 |
84 } // namespace CSSPropertyParserHelpers | 90 } // namespace CSSPropertyParserHelpers |
85 | 91 |
86 } // namespace blink | 92 } // namespace blink |
87 | 93 |
88 #endif // CSSPropertyParserHelpers_h | 94 #endif // CSSPropertyParserHelpers_h |
OLD | NEW |