aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGSVG.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-03 10:21:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-03 10:21:11 -0700
commitbffc2566872f99d378a1113d0a49ec9ee0d60b7a (patch)
tree3a7fab8b6206e99201b1ea817c95454f340260c8 /experimental/svg/model/SkSVGSVG.cpp
parent9e3d3d8b363edcdd81a13b2be046152c6bb839cd (diff)
[SVGDom] Initial SVGLength support
Mostly plumb new length types, but also introduce a stateful parser, rect shape and named color support. R=reed@google.com,robertphillips@google.com,stephana@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2202053002 Review-Url: https://codereview.chromium.org/2202053002
Diffstat (limited to 'experimental/svg/model/SkSVGSVG.cpp')
-rw-r--r--experimental/svg/model/SkSVGSVG.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGSVG.cpp b/experimental/svg/model/SkSVGSVG.cpp
index aeccc7082b..42bd280a5e 100644
--- a/experimental/svg/model/SkSVGSVG.cpp
+++ b/experimental/svg/model/SkSVGSVG.cpp
@@ -6,5 +6,49 @@
*/
#include "SkSVGSVG.h"
+#include "SkSVGValue.h"
SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { }
+
+void SkSVGSVG::setX(const SkSVGLength& x) {
+ fX = x;
+}
+
+void SkSVGSVG::setY(const SkSVGLength& y) {
+ fY = y;
+}
+
+void SkSVGSVG::setWidth(const SkSVGLength& w) {
+ fWidth = w;
+}
+
+void SkSVGSVG::setHeight(const SkSVGLength& h) {
+ fHeight = h;
+}
+
+void SkSVGSVG::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
+ switch (attr) {
+ case SkSVGAttribute::kX:
+ if (const auto* x = v.as<SkSVGLengthValue>()) {
+ this->setX(*x);
+ }
+ break;
+ case SkSVGAttribute::kY:
+ if (const auto* y = v.as<SkSVGLengthValue>()) {
+ this->setY(*y);
+ }
+ break;
+ case SkSVGAttribute::kWidth:
+ if (const auto* w = v.as<SkSVGLengthValue>()) {
+ this->setWidth(*w);
+ }
+ break;
+ case SkSVGAttribute::kHeight:
+ if (const auto* h = v.as<SkSVGLengthValue>()) {
+ this->setHeight(*h);
+ }
+ break;
+ default:
+ this->INHERITED::onSetAttribute(attr, v);
+ }
+}