OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkParse.h" | 8 #include "SkParse.h" |
9 #include "SkSVGAttributeParser.h" | 9 #include "SkSVGAttributeParser.h" |
10 #include "SkSVGTypes.h" | 10 #include "SkSVGTypes.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 145 } |
146 | 146 |
147 *c = v | 0xff000000; | 147 *c = v | 0xff000000; |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 // https://www.w3.org/TR/SVG/types.html#DataTypeColor | 151 // https://www.w3.org/TR/SVG/types.html#DataTypeColor |
152 bool SkSVGAttributeParser::parseColor(SkSVGColorType* color) { | 152 bool SkSVGAttributeParser::parseColor(SkSVGColorType* color) { |
153 SkColor c; | 153 SkColor c; |
154 | 154 |
| 155 // consume preceding whitespace |
| 156 this->parseWSToken(); |
| 157 |
155 // TODO: rgb(...) | 158 // TODO: rgb(...) |
| 159 bool parsedValue = false; |
156 if (this->parseHexColorToken(&c) || this->parseNamedColorToken(&c)) { | 160 if (this->parseHexColorToken(&c) || this->parseNamedColorToken(&c)) { |
157 *color = SkSVGColorType(c); | 161 *color = SkSVGColorType(c); |
158 return true; | 162 parsedValue = true; |
| 163 |
| 164 // consume trailing whitespace |
| 165 this->parseWSToken(); |
159 } | 166 } |
160 | 167 |
161 return false; | 168 return parsedValue && this->parseEOSToken(); |
162 } | 169 } |
163 | 170 |
164 // https://www.w3.org/TR/SVG/types.html#DataTypeNumber | 171 // https://www.w3.org/TR/SVG/types.html#DataTypeNumber |
165 bool SkSVGAttributeParser::parseNumber(SkSVGNumberType* number) { | 172 bool SkSVGAttributeParser::parseNumber(SkSVGNumberType* number) { |
166 // consume WS | 173 // consume WS |
167 this->parseWSToken(); | 174 this->parseWSToken(); |
168 | 175 |
169 SkScalar s; | 176 SkScalar s; |
170 if (this->parseScalarToken(&s)) { | 177 if (this->parseScalarToken(&s)) { |
171 *number = SkSVGNumberType(s); | 178 *number = SkSVGNumberType(s); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 352 } |
346 | 353 |
347 this->parseWSToken(); | 354 this->parseWSToken(); |
348 if (!parsed || !this->parseEOSToken()) { | 355 if (!parsed || !this->parseEOSToken()) { |
349 return false; | 356 return false; |
350 } | 357 } |
351 | 358 |
352 *t = SkSVGTransformType(matrix); | 359 *t = SkSVGTransformType(matrix); |
353 return true; | 360 return true; |
354 } | 361 } |
OLD | NEW |