[svg] Convert text-anchor to a presentation attribute

https://www.w3.org/TR/SVG11/text.html#TextAnchorProperty

Bug: skia:10840
Change-Id: Iff647b62243c42150e873f06215401b5e33705fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330125
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/src/SkSVGDOM.cpp b/modules/svg/src/SkSVGDOM.cpp
index b989b70..f9327a3 100644
--- a/modules/svg/src/SkSVGDOM.cpp
+++ b/modules/svg/src/SkSVGDOM.cpp
@@ -308,6 +308,19 @@
     return true;
 }
 
+bool SetTextAnchorAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
+                            const char* stringValue) {
+    SkSVGTextAnchor anchor;
+    SkSVGAttributeParser parser(stringValue);
+
+    if (!parser.parseTextAnchor(&anchor)) {
+        return false;
+    }
+
+    node->setAttribute(attr, SkSVGTextAnchorValue(anchor));
+    return true;
+}
+
 bool SetPreserveAspectRatioAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
                                      const char* stringValue) {
     SkSVGPreserveAspectRatio par;
@@ -439,7 +452,7 @@
     { "stroke-width"       , { SkSVGAttribute::kStrokeWidth      , SetLengthAttribute       }},
     { "style"              , { SkSVGAttribute::kUnknown          , SetStyleAttributes       }},
     { "text"               , { SkSVGAttribute::kText             , SetStringAttribute       }},
-    { "text-anchor"        , { SkSVGAttribute::kTextAnchor       , SetStringAttribute       }},
+    { "text-anchor"        , { SkSVGAttribute::kTextAnchor       , SetTextAnchorAttribute   }},
     { "transform"          , { SkSVGAttribute::kTransform        , SetTransformAttribute    }},
     { "viewBox"            , { SkSVGAttribute::kViewBox          , SetViewBoxAttribute      }},
     { "visibility"         , { SkSVGAttribute::kVisibility       , SetVisibilityAttribute   }},