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(SkSVGColor* color) { | 152 bool SkSVGAttributeParser::parseColor(SkSVGColor* color) { |
153 SkColor c; | 153 SkColor c; |
154 | 154 |
155 // consume preceding whitespace | |
156 this->parseWSToken(); | |
157 | |
155 // TODO: rgb(...) | 158 // TODO: rgb(...) |
156 if (this->parseHexColorToken(&c) || this->parseNamedColorToken(&c)) { | 159 if (this->parseHexColorToken(&c) || this->parseNamedColorToken(&c)) { |
157 *color = SkSVGColor(c); | 160 *color = SkSVGColor(c); |
158 return true; | 161 |
162 // consume trailing whitespace | |
163 this->parseWSToken(); | |
159 } | 164 } |
160 | 165 |
robertphillips
2016/08/08 12:39:30
Do we need to init 'color' to something in case th
f(malita)
2016/08/08 13:00:02
All SVG types have default constructors, so color
| |
161 return false; | 166 return this->parseEOSToken(); |
162 } | 167 } |
163 | 168 |
164 // https://www.w3.org/TR/SVG/types.html#DataTypeNumber | 169 // https://www.w3.org/TR/SVG/types.html#DataTypeNumber |
165 bool SkSVGAttributeParser::parseNumber(SkSVGNumber* number) { | 170 bool SkSVGAttributeParser::parseNumber(SkSVGNumber* number) { |
166 // consume WS | 171 // consume WS |
167 this->parseWSToken(); | 172 this->parseWSToken(); |
168 | 173 |
169 SkScalar s; | 174 SkScalar s; |
170 if (this->parseScalarToken(&s)) { | 175 if (this->parseScalarToken(&s)) { |
171 *number = SkSVGNumber(s); | 176 *number = SkSVGNumber(s); |
(...skipping 13 matching lines...) Expand all Loading... | |
185 if (this->parseScalarToken(&s) && | 190 if (this->parseScalarToken(&s) && |
186 (this->parseLengthUnitToken(&u) || this->parseSepToken() || this->parseE OSToken())) { | 191 (this->parseLengthUnitToken(&u) || this->parseSepToken() || this->parseE OSToken())) { |
187 *length = SkSVGLength(s, u); | 192 *length = SkSVGLength(s, u); |
188 // consume trailing separators | 193 // consume trailing separators |
189 this->parseSepToken(); | 194 this->parseSepToken(); |
190 return true; | 195 return true; |
191 } | 196 } |
192 | 197 |
193 return false; | 198 return false; |
194 } | 199 } |
OLD | NEW |