diff options
Diffstat (limited to 'experimental/svg/model/SkSVGAttributeParser.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGAttributeParser.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/experimental/svg/model/SkSVGAttributeParser.cpp b/experimental/svg/model/SkSVGAttributeParser.cpp index 75e5d12f38..62ca4c8ab2 100644 --- a/experimental/svg/model/SkSVGAttributeParser.cpp +++ b/experimental/svg/model/SkSVGAttributeParser.cpp @@ -149,12 +149,12 @@ bool SkSVGAttributeParser::parseHexColorToken(SkColor* c) { } // https://www.w3.org/TR/SVG/types.html#DataTypeColor -bool SkSVGAttributeParser::parseColor(SkSVGColor* color) { +bool SkSVGAttributeParser::parseColor(SkSVGColorType* color) { SkColor c; // TODO: rgb(...) if (this->parseHexColorToken(&c) || this->parseNamedColorToken(&c)) { - *color = SkSVGColor(c); + *color = SkSVGColorType(c); return true; } @@ -162,13 +162,13 @@ bool SkSVGAttributeParser::parseColor(SkSVGColor* color) { } // https://www.w3.org/TR/SVG/types.html#DataTypeNumber -bool SkSVGAttributeParser::parseNumber(SkSVGNumber* number) { +bool SkSVGAttributeParser::parseNumber(SkSVGNumberType* number) { // consume WS this->parseWSToken(); SkScalar s; if (this->parseScalarToken(&s)) { - *number = SkSVGNumber(s); + *number = SkSVGNumberType(s); // consume trailing separators this->parseSepToken(); return true; @@ -192,3 +192,22 @@ bool SkSVGAttributeParser::parseLength(SkSVGLength* length) { return false; } + +// https://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute +bool SkSVGAttributeParser::parseViewBox(SkSVGViewBoxType* vb) { + SkScalar x, y, w, h; + this->parseWSToken(); + + bool parsedValue = false; + if (this->parseScalarToken(&x) && this->parseSepToken() && + this->parseScalarToken(&y) && this->parseSepToken() && + this->parseScalarToken(&w) && this->parseSepToken() && + this->parseScalarToken(&h)) { + + *vb = SkSVGViewBoxType(SkRect::MakeXYWH(x, y, w, h)); + parsedValue = true; + // consume trailing whitespace + this->parseWSToken(); + } + return parsedValue && this->parseEOSToken(); +} |