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

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

Issue 2234153002: [SVGDom] Add more presentation attributes. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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 | « experimental/svg/model/SkSVGAttributeParser.h ('k') | 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 this->parseWSToken(); 354 this->parseWSToken();
355 if (!parsed || !this->parseEOSToken()) { 355 if (!parsed || !this->parseEOSToken()) {
356 return false; 356 return false;
357 } 357 }
358 358
359 *t = SkSVGTransformType(matrix); 359 *t = SkSVGTransformType(matrix);
360 return true; 360 return true;
361 } 361 }
362
363 // https://www.w3.org/TR/SVG/painting.html#SpecifyingPaint
364 bool SkSVGAttributeParser::parsePaint(SkSVGPaint* paint) {
365 SkSVGColorType c;
366 bool parsedValue = false;
367 if (this->parseColor(&c)) {
368 *paint = SkSVGPaint(c);
369 parsedValue = true;
370 } else if (this->parseExpectedStringToken("none")) {
371 *paint = SkSVGPaint(SkSVGPaint::Type::kNone);
372 parsedValue = true;
373 } else if (this->parseExpectedStringToken("currentColor")) {
374 *paint = SkSVGPaint(SkSVGPaint::Type::kCurrentColor);
375 parsedValue = true;
376 } else if (this->parseExpectedStringToken("inherit")) {
377 *paint = SkSVGPaint(SkSVGPaint::Type::kInherit);
378 parsedValue = true;
379 }
380 return parsedValue && this->parseEOSToken();
381 }
382
383 // https://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty
384 bool SkSVGAttributeParser::parseLineCap(SkSVGLineCap* cap) {
385 static const struct {
386 SkSVGLineCap::Type fType;
387 const char* fName;
388 } gCapInfo[] = {
389 { SkSVGLineCap::Type::kButt , "butt" },
390 { SkSVGLineCap::Type::kRound , "round" },
391 { SkSVGLineCap::Type::kSquare , "square" },
392 { SkSVGLineCap::Type::kInherit, "inherit" },
393 };
394
395 bool parsedValue = false;
396 for (size_t i = 0; i < SK_ARRAY_COUNT(gCapInfo); ++i) {
397 if (this->parseExpectedStringToken(gCapInfo[i].fName)) {
398 *cap = SkSVGLineCap(gCapInfo[i].fType);
399 parsedValue = true;
400 break;
401 }
402 }
403
404 return parsedValue && this->parseEOSToken();
405 }
406
407 // https://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty
408 bool SkSVGAttributeParser::parseLineJoin(SkSVGLineJoin* join) {
409 static const struct {
410 SkSVGLineJoin::Type fType;
411 const char* fName;
412 } gJoinInfo[] = {
413 { SkSVGLineJoin::Type::kMiter , "miter" },
414 { SkSVGLineJoin::Type::kRound , "round" },
415 { SkSVGLineJoin::Type::kBevel , "bevel" },
416 { SkSVGLineJoin::Type::kInherit, "inherit" },
417 };
418
419 bool parsedValue = false;
420 for (size_t i = 0; i < SK_ARRAY_COUNT(gJoinInfo); ++i) {
421 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) {
422 *join = SkSVGLineJoin(gJoinInfo[i].fType);
423 parsedValue = true;
424 break;
425 }
426 }
427
428 return parsedValue && this->parseEOSToken();
429 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGAttributeParser.h ('k') | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698