Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: experimental/svg/model/SkSVGAttributeParser.cpp

Issue 2225623002: [SVGDom] Improve whitespace handling in style parsing (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698