[svg] Use new code path for rest of presentation attrs
This is another necessary step in order to remove kInherit from all of
the base SVG type enums.
Change-Id: I2185e744f7b27369f7bad36591f896d3a9982b42
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335817
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/modules/svg/src/SkSVGDOM.cpp b/modules/svg/src/SkSVGDOM.cpp
index 6e7b427..ec6a720 100644
--- a/modules/svg/src/SkSVGDOM.cpp
+++ b/modules/svg/src/SkSVGDOM.cpp
@@ -41,18 +41,6 @@
namespace {
-bool SetColorAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
- const char* stringValue) {
- SkSVGColorType color;
- SkSVGAttributeParser parser(stringValue);
- if (!parser.parseColor(&color)) {
- return false;
- }
-
- node->setAttribute(attr, SkSVGColorValue(color));
- return true;
-}
-
bool SetIRIAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
const char* stringValue) {
auto parseResult = SkSVGAttributeParser::parse<SkSVGIRI>(stringValue);
@@ -107,13 +95,12 @@
bool SetNumberAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
const char* stringValue) {
- SkSVGNumberType number;
- SkSVGAttributeParser parser(stringValue);
- if (!parser.parseNumber(&number)) {
+ auto parseResult = SkSVGAttributeParser::parse<SkSVGNumberType>(stringValue);
+ if (!parseResult.isValid()) {
return false;
}
- node->setAttribute(attr, SkSVGNumberValue(number));
+ node->setAttribute(attr, SkSVGNumberValue(*parseResult));
return true;
}
@@ -255,11 +242,9 @@
};
SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = {
- { "color" , { SkSVGAttribute::kColor , SetColorAttribute }},
{ "cx" , { SkSVGAttribute::kCx , SetLengthAttribute }},
{ "cy" , { SkSVGAttribute::kCy , SetLengthAttribute }},
{ "d" , { SkSVGAttribute::kD , SetPathDataAttribute }},
- { "fill-opacity" , { SkSVGAttribute::kFillOpacity , SetNumberAttribute }},
{ "filterUnits" , { SkSVGAttribute::kFilterUnits ,
SetObjectBoundingBoxUnitsAttribute }},
// focal point x & y
@@ -267,7 +252,6 @@
{ "fy" , { SkSVGAttribute::kFy , SetLengthAttribute }},
{ "height" , { SkSVGAttribute::kHeight , SetLengthAttribute }},
{ "offset" , { SkSVGAttribute::kOffset , SetLengthAttribute }},
- { "opacity" , { SkSVGAttribute::kOpacity , SetNumberAttribute }},
{ "patternTransform" , { SkSVGAttribute::kPatternTransform , SetTransformAttribute }},
{ "points" , { SkSVGAttribute::kPoints , SetPointsAttribute }},
{ "preserveAspectRatio", { SkSVGAttribute::kPreserveAspectRatio,
@@ -277,10 +261,6 @@
{ "ry" , { SkSVGAttribute::kRy , SetLengthAttribute }},
{ "stop-color" , { SkSVGAttribute::kStopColor , SetStopColorAttribute }},
{ "stop-opacity" , { SkSVGAttribute::kStopOpacity , SetNumberAttribute }},
- { "stroke-dashoffset" , { SkSVGAttribute::kStrokeDashOffset , SetLengthAttribute }},
- { "stroke-miterlimit" , { SkSVGAttribute::kStrokeMiterLimit , SetNumberAttribute }},
- { "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute }},
- { "stroke-width" , { SkSVGAttribute::kStrokeWidth , SetLengthAttribute }},
{ "style" , { SkSVGAttribute::kUnknown , SetStyleAttributes }},
{ "text" , { SkSVGAttribute::kText , SetStringAttribute }},
{ "transform" , { SkSVGAttribute::kTransform , SetTransformAttribute }},