aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGAttributeParser.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-12 12:15:33 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-12 12:15:33 -0700
commit5b31f321fcc3bb7f2ed7cf31ff4b03901228594b (patch)
treef3c65b2e0db3a9d36c448296e745d72832fe6034 /experimental/svg/model/SkSVGAttributeParser.cpp
parent3602d4f16a01da860d16eb36fb52eb62487495cc (diff)
[SVGDom] <polygon> & <polyline> support
R=robertphillips@google.com,stephana@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2235273003 Review-Url: https://codereview.chromium.org/2235273003
Diffstat (limited to 'experimental/svg/model/SkSVGAttributeParser.cpp')
-rw-r--r--experimental/svg/model/SkSVGAttributeParser.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGAttributeParser.cpp b/experimental/svg/model/SkSVGAttributeParser.cpp
index 308eb62ba6..f8bfa2033f 100644
--- a/experimental/svg/model/SkSVGAttributeParser.cpp
+++ b/experimental/svg/model/SkSVGAttributeParser.cpp
@@ -427,3 +427,41 @@ bool SkSVGAttributeParser::parseLineJoin(SkSVGLineJoin* join) {
return parsedValue && this->parseEOSToken();
}
+
+// https://www.w3.org/TR/SVG/shapes.html#PolygonElementPointsAttribute
+bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) {
+ SkTDArray<SkPoint> pts;
+
+ bool parsedValue = false;
+ for (;;) {
+ this->parseWSToken();
+
+ SkScalar x, y;
+ if (!this->parseScalarToken(&x)) {
+ break;
+ }
+
+ // comma-wsp:
+ // (wsp+ comma? wsp*) | (comma wsp*)
+ bool wsp = this->parseWSToken();
+ bool comma = this->parseExpectedStringToken(",");
+ if (!(wsp || comma)) {
+ break;
+ }
+ this->parseWSToken();
+
+ if (!this->parseScalarToken(&y)) {
+ break;
+ }
+
+ pts.push(SkPoint::Make(x, y));
+ parsedValue = true;
+ }
+
+ if (parsedValue && this->parseEOSToken()) {
+ *points = pts;
+ return true;
+ }
+
+ return false;
+}