[SVG] Replace custom attribute value wrappers with std::variant
Less boilerplate, more STL.
Change-Id: I601f75877d60085cbf3d39f401543fbe9c086f90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282836
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/experimental/svg/model/SkSVGText.cpp b/experimental/svg/model/SkSVGText.cpp
index 2ac8fe5..70f6937 100644
--- a/experimental/svg/model/SkSVGText.cpp
+++ b/experimental/svg/model/SkSVGText.cpp
@@ -8,7 +8,6 @@
#include "experimental/svg/model/SkSVGText.h"
#include "experimental/svg/model/SkSVGRenderContext.h"
-#include "experimental/svg/model/SkSVGValue.h"
#include "include/core/SkCanvas.h"
SkSVGText::SkSVGText() : INHERITED(SkSVGTag::kText) {}
@@ -48,35 +47,35 @@
return path;
}
-void SkSVGText::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
+void SkSVGText::onSetAttribute(SkSVGAttribute attr, const SkSVGAttributeValue& v) {
switch (attr) {
case SkSVGAttribute::kX:
- if (const auto* x = v.as<SkSVGLengthValue>()) {
+ if (const auto* x = std::get_if<SkSVGLength>(&v)) {
this->setX(*x);
}
break;
case SkSVGAttribute::kY:
- if (const auto* y = v.as<SkSVGLengthValue>()) {
+ if (const auto* y = std::get_if<SkSVGLength>(&v)) {
this->setY(*y);
}
break;
case SkSVGAttribute::kText:
- if (const auto* text = v.as<SkSVGStringValue>()) {
+ if (const auto* text = std::get_if<SkSVGStringType>(&v)) {
this->setText(*text);
}
break;
case SkSVGAttribute::kTextAnchor:
- if (const auto* text_anchor = v.as<SkSVGStringValue>()) {
+ if (const auto* text_anchor = std::get_if<SkSVGStringType>(&v)) {
this->setTextAnchor(*text_anchor);
}
break;
case SkSVGAttribute::kFontFamily:
- if (const auto* font_family = v.as<SkSVGStringValue>()) {
+ if (const auto* font_family = std::get_if<SkSVGStringType>(&v)) {
this->setFontFamily(*font_family);
}
break;
case SkSVGAttribute::kFontSize:
- if (const auto* font_size = v.as<SkSVGLengthValue>()) {
+ if (const auto* font_size = std::get_if<SkSVGLength>(&v)) {
this->setFontSize(*font_size);
}
break;