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 #include "core/css/CSSSyntaxDescriptor.h" | 5 #include "core/css/CSSSyntaxDescriptor.h" |
6 | 6 |
7 #include "core/animation/CSSColorInterpolationType.h" | 7 #include "core/animation/CSSColorInterpolationType.h" |
8 #include "core/animation/CSSLengthInterpolationType.h" | 8 #include "core/animation/CSSLengthInterpolationType.h" |
9 #include "core/animation/CSSValueInterpolationType.h" | 9 #include "core/animation/CSSValueInterpolationType.h" |
10 #include "core/css/CSSCustomPropertyDeclaration.h" | 10 #include "core/css/CSSCustomPropertyDeclaration.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 if (type == "url") | 50 if (type == "url") |
51 return CSSSyntaxType::kUrl; | 51 return CSSSyntaxType::kUrl; |
52 if (type == "integer") | 52 if (type == "integer") |
53 return CSSSyntaxType::kInteger; | 53 return CSSSyntaxType::kInteger; |
54 if (type == "angle") | 54 if (type == "angle") |
55 return CSSSyntaxType::kAngle; | 55 return CSSSyntaxType::kAngle; |
56 if (type == "time") | 56 if (type == "time") |
57 return CSSSyntaxType::kTime; | 57 return CSSSyntaxType::kTime; |
58 if (type == "resolution") | 58 if (type == "resolution") |
59 return CSSSyntaxType::kResolution; | 59 return CSSSyntaxType::kResolution; |
60 if (type == "transform-function") | 60 if (type == "transform-list") |
61 return CSSSyntaxType::kTransformFunction; | 61 return CSSSyntaxType::kTransformList; |
62 if (type == "custom-ident") | 62 if (type == "custom-ident") |
63 return CSSSyntaxType::kCustomIdent; | 63 return CSSSyntaxType::kCustomIdent; |
64 // Not an Ident, just used to indicate failure | 64 // Not an Ident, just used to indicate failure |
65 return CSSSyntaxType::kIdent; | 65 return CSSSyntaxType::kIdent; |
66 } | 66 } |
67 | 67 |
68 bool ConsumeSyntaxType(const String& input, | 68 bool ConsumeSyntaxType(const String& input, |
69 size_t& offset, | 69 size_t& offset, |
70 CSSSyntaxType& type) { | 70 CSSSyntaxType& type) { |
71 DCHECK_EQ(input[offset], '<'); | 71 DCHECK_EQ(input[offset], '<'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 type = CSSSyntaxType::kIdent; | 115 type = CSSSyntaxType::kIdent; |
116 success = ConsumeSyntaxIdent(input, offset, ident); | 116 success = ConsumeSyntaxIdent(input, offset, ident); |
117 } | 117 } |
118 | 118 |
119 if (!success) { | 119 if (!success) { |
120 syntax_components_.clear(); | 120 syntax_components_.clear(); |
121 return; | 121 return; |
122 } | 122 } |
123 | 123 |
124 bool repeatable = ConsumeCharacterAndWhitespace(input, '+', offset); | 124 bool repeatable = ConsumeCharacterAndWhitespace(input, '+', offset); |
| 125 // <transform-list> is already a space separated list, |
| 126 // <transform-list>+ is invalid. |
| 127 if (type == CSSSyntaxType::kTransformList && repeatable) { |
| 128 syntax_components_.clear(); |
| 129 return; |
| 130 } |
125 ConsumeWhitespace(input, offset); | 131 ConsumeWhitespace(input, offset); |
126 syntax_components_.push_back(CSSSyntaxComponent(type, ident, repeatable)); | 132 syntax_components_.push_back(CSSSyntaxComponent(type, ident, repeatable)); |
127 | 133 |
128 } while (ConsumeCharacterAndWhitespace(input, '|', offset)); | 134 } while (ConsumeCharacterAndWhitespace(input, '|', offset)); |
129 | 135 |
130 if (offset != input.length()) | 136 if (offset != input.length()) |
131 syntax_components_.clear(); | 137 syntax_components_.clear(); |
132 } | 138 } |
133 | 139 |
134 const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax, | 140 const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax, |
(...skipping 26 matching lines...) Expand all Loading... |
161 case CSSSyntaxType::kUrl: | 167 case CSSSyntaxType::kUrl: |
162 return ConsumeUrl(range, context); | 168 return ConsumeUrl(range, context); |
163 case CSSSyntaxType::kInteger: | 169 case CSSSyntaxType::kInteger: |
164 return ConsumeInteger(range); | 170 return ConsumeInteger(range); |
165 case CSSSyntaxType::kAngle: | 171 case CSSSyntaxType::kAngle: |
166 return ConsumeAngle(range, *context, WTF::Optional<WebFeature>()); | 172 return ConsumeAngle(range, *context, WTF::Optional<WebFeature>()); |
167 case CSSSyntaxType::kTime: | 173 case CSSSyntaxType::kTime: |
168 return ConsumeTime(range, ValueRange::kValueRangeAll); | 174 return ConsumeTime(range, ValueRange::kValueRangeAll); |
169 case CSSSyntaxType::kResolution: | 175 case CSSSyntaxType::kResolution: |
170 return ConsumeResolution(range); | 176 return ConsumeResolution(range); |
171 case CSSSyntaxType::kTransformFunction: | 177 case CSSSyntaxType::kTransformList: |
172 return nullptr; // TODO(timloh): Implement this. | 178 return ConsumeTransformList(range, *context); |
173 case CSSSyntaxType::kCustomIdent: | 179 case CSSSyntaxType::kCustomIdent: |
174 return ConsumeCustomIdent(range); | 180 return ConsumeCustomIdent(range); |
175 default: | 181 default: |
176 NOTREACHED(); | 182 NOTREACHED(); |
177 return nullptr; | 183 return nullptr; |
178 } | 184 } |
179 } | 185 } |
180 | 186 |
181 const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax, | 187 const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax, |
182 CSSParserTokenRange range, | 188 CSSParserTokenRange range, |
(...skipping 26 matching lines...) Expand all Loading... |
209 for (const CSSSyntaxComponent& component : syntax_components_) { | 215 for (const CSSSyntaxComponent& component : syntax_components_) { |
210 if (const CSSValue* result = | 216 if (const CSSValue* result = |
211 ConsumeSyntaxComponent(component, range, context)) | 217 ConsumeSyntaxComponent(component, range, context)) |
212 return result; | 218 return result; |
213 } | 219 } |
214 return CSSVariableParser::ParseRegisteredPropertyValue(range, *context, true, | 220 return CSSVariableParser::ParseRegisteredPropertyValue(range, *context, true, |
215 is_animation_tainted); | 221 is_animation_tainted); |
216 } | 222 } |
217 | 223 |
218 } // namespace blink | 224 } // namespace blink |
OLD | NEW |