diff options
author | Florin Malita <fmalita@chromium.org> | 2017-10-13 14:07:44 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-13 19:14:39 +0000 |
commit | f543a60ef06a6b0ccb5a0a85ca5415021c81c9ee (patch) | |
tree | f2a3d3dd48e360e045e01385d86fa7833de20d3b /experimental/svg/model/SkSVGAttributeParser.cpp | |
parent | 770db22a553e87d6f3e40db72c5871b1d8a9ec91 (diff) |
[SVGDom] Add 'stroke-dasharray' support
https://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty
Change-Id: I9a63ebbd958d661c865ed405570b86cca68f63bf
Reviewed-on: https://skia-review.googlesource.com/59700
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'experimental/svg/model/SkSVGAttributeParser.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGAttributeParser.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGAttributeParser.cpp b/experimental/svg/model/SkSVGAttributeParser.cpp index aee15b394e..40a3f1a4a9 100644 --- a/experimental/svg/model/SkSVGAttributeParser.cpp +++ b/experimental/svg/model/SkSVGAttributeParser.cpp @@ -617,3 +617,33 @@ bool SkSVGAttributeParser::parseVisibility(SkSVGVisibility* visibility) { return parsedValue && this->parseEOSToken(); } + +// https://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty +bool SkSVGAttributeParser::parseDashArray(SkSVGDashArray* dashArray) { + bool parsedValue = false; + if (this->parseExpectedStringToken("none")) { + *dashArray = SkSVGDashArray(SkSVGDashArray::Type::kNone); + parsedValue = true; + } else if (this->parseExpectedStringToken("inherit")) { + *dashArray = SkSVGDashArray(SkSVGDashArray::Type::kInherit); + parsedValue = true; + } else { + SkTDArray<SkSVGLength> dashes; + for (;;) { + SkSVGLength dash; + // parseLength() also consumes trailing separators. + if (!this->parseLength(&dash)) { + break; + } + + dashes.push(dash); + parsedValue = true; + } + + if (parsedValue) { + *dashArray = SkSVGDashArray(std::move(dashes)); + } + } + + return parsedValue && this->parseEOSToken(); +} |