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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/svg/model/SkSVGAttributeParser.h ('k') | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGAttributeParser.cpp
diff --git a/experimental/svg/model/SkSVGAttributeParser.cpp b/experimental/svg/model/SkSVGAttributeParser.cpp
index 7a2561cdf718f5b8c91cc52c219fc8d4b2a233fd..308eb62ba6bbf7f51cde4b968fb98b02031c5bba 100644
--- a/experimental/svg/model/SkSVGAttributeParser.cpp
+++ b/experimental/svg/model/SkSVGAttributeParser.cpp
@@ -359,3 +359,71 @@ bool SkSVGAttributeParser::parseTransform(SkSVGTransformType* t) {
*t = SkSVGTransformType(matrix);
return true;
}
+
+// https://www.w3.org/TR/SVG/painting.html#SpecifyingPaint
+bool SkSVGAttributeParser::parsePaint(SkSVGPaint* paint) {
+ SkSVGColorType c;
+ bool parsedValue = false;
+ if (this->parseColor(&c)) {
+ *paint = SkSVGPaint(c);
+ parsedValue = true;
+ } else if (this->parseExpectedStringToken("none")) {
+ *paint = SkSVGPaint(SkSVGPaint::Type::kNone);
+ parsedValue = true;
+ } else if (this->parseExpectedStringToken("currentColor")) {
+ *paint = SkSVGPaint(SkSVGPaint::Type::kCurrentColor);
+ parsedValue = true;
+ } else if (this->parseExpectedStringToken("inherit")) {
+ *paint = SkSVGPaint(SkSVGPaint::Type::kInherit);
+ parsedValue = true;
+ }
+ return parsedValue && this->parseEOSToken();
+}
+
+// https://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty
+bool SkSVGAttributeParser::parseLineCap(SkSVGLineCap* cap) {
+ static const struct {
+ SkSVGLineCap::Type fType;
+ const char* fName;
+ } gCapInfo[] = {
+ { SkSVGLineCap::Type::kButt , "butt" },
+ { SkSVGLineCap::Type::kRound , "round" },
+ { SkSVGLineCap::Type::kSquare , "square" },
+ { SkSVGLineCap::Type::kInherit, "inherit" },
+ };
+
+ bool parsedValue = false;
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gCapInfo); ++i) {
+ if (this->parseExpectedStringToken(gCapInfo[i].fName)) {
+ *cap = SkSVGLineCap(gCapInfo[i].fType);
+ parsedValue = true;
+ break;
+ }
+ }
+
+ return parsedValue && this->parseEOSToken();
+}
+
+// https://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty
+bool SkSVGAttributeParser::parseLineJoin(SkSVGLineJoin* join) {
+ static const struct {
+ SkSVGLineJoin::Type fType;
+ const char* fName;
+ } gJoinInfo[] = {
+ { SkSVGLineJoin::Type::kMiter , "miter" },
+ { SkSVGLineJoin::Type::kRound , "round" },
+ { SkSVGLineJoin::Type::kBevel , "bevel" },
+ { SkSVGLineJoin::Type::kInherit, "inherit" },
+ };
+
+ bool parsedValue = false;
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gJoinInfo); ++i) {
+ if (this->parseExpectedStringToken(gJoinInfo[i].fName)) {
+ *join = SkSVGLineJoin(gJoinInfo[i].fType);
+ parsedValue = true;
+ break;
+ }
+ }
+
+ return parsedValue && this->parseEOSToken();
+}
« 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