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

Unified Diff: experimental/svg/model/SkSVGAttributeParser.cpp

Issue 2222793002: [SVGDom] Add <svg> viewBox support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: SkSVGRenderContext initialization cleanup 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
Index: experimental/svg/model/SkSVGAttributeParser.cpp
diff --git a/experimental/svg/model/SkSVGAttributeParser.cpp b/experimental/svg/model/SkSVGAttributeParser.cpp
index 75e5d12f38558868bc2b15dfa426b15c84d1740f..6b523b1b31c2cc4bf57b735c52cd9d6e5e7098eb 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,19 @@ 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();
+ 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));
+ // consume trailing whitespace
+ this->parseWSToken();
+ }
robertphillips 2016/08/08 13:55:28 What happens on a partial parse that ends in an EO
f(malita) 2016/08/08 17:13:29 Fixed.
+ return this->parseEOSToken();
+}

Powered by Google App Engine
This is Rietveld 408576698