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

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: typo 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/SkSVGContainer.h » ('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 75e5d12f38558868bc2b15dfa426b15c84d1740f..62ca4c8ab2536f33c3b724e68e4cff1809eac95a 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();
+}
« no previous file with comments | « experimental/svg/model/SkSVGAttributeParser.h ('k') | experimental/svg/model/SkSVGContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698