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

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: 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') | experimental/svg/model/SkSVGDOM.cpp » ('J')
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(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
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 }
OLDNEW
« no previous file with comments | « no previous file | experimental/svg/model/SkSVGDOM.cpp » ('j') | experimental/svg/model/SkSVGDOM.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698