OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkSVGSVG.h" | 8 #include "SkSVGSVG.h" |
| 9 #include "SkSVGValue.h" |
9 | 10 |
10 SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { } | 11 SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { } |
| 12 |
| 13 void SkSVGSVG::setX(const SkSVGLength& x) { |
| 14 fX = x; |
| 15 } |
| 16 |
| 17 void SkSVGSVG::setY(const SkSVGLength& y) { |
| 18 fY = y; |
| 19 } |
| 20 |
| 21 void SkSVGSVG::setWidth(const SkSVGLength& w) { |
| 22 fWidth = w; |
| 23 } |
| 24 |
| 25 void SkSVGSVG::setHeight(const SkSVGLength& h) { |
| 26 fHeight = h; |
| 27 } |
| 28 |
| 29 void SkSVGSVG::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { |
| 30 switch (attr) { |
| 31 case SkSVGAttribute::kX: |
| 32 if (const auto* x = v.as<SkSVGLengthValue>()) { |
| 33 this->setX(*x); |
| 34 } |
| 35 break; |
| 36 case SkSVGAttribute::kY: |
| 37 if (const auto* y = v.as<SkSVGLengthValue>()) { |
| 38 this->setY(*y); |
| 39 } |
| 40 break; |
| 41 case SkSVGAttribute::kWidth: |
| 42 if (const auto* w = v.as<SkSVGLengthValue>()) { |
| 43 this->setWidth(*w); |
| 44 } |
| 45 break; |
| 46 case SkSVGAttribute::kHeight: |
| 47 if (const auto* h = v.as<SkSVGLengthValue>()) { |
| 48 this->setHeight(*h); |
| 49 } |
| 50 break; |
| 51 default: |
| 52 this->INHERITED::onSetAttribute(attr, v); |
| 53 } |
| 54 } |
OLD | NEW |