[svg] Cleanup text content model rules

Per spec (and empirically) <text> elements are not nestable (neither
directly or indirectly):
https://www.w3.org/TR/SVG11/intro.html#TermTextContentChildElement

Update the implementation to

 - only bridge onRender -> onRenderText in the root SkSVGText
   implementation
 - disallow <text> elements as text container descendants

Change-Id: I07b3abaf943b820e01c88f78bddf7ce5970ee508
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358220
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/src/SkSVGText.cpp b/modules/svg/src/SkSVGText.cpp
index 17ed02c..7b25578 100644
--- a/modules/svg/src/SkSVGText.cpp
+++ b/modules/svg/src/SkSVGText.cpp
@@ -490,9 +490,8 @@
 }
 
 void SkSVGTextContainer::appendChild(sk_sp<SkSVGNode> child) {
-    // Only allow text nodes.
+    // Only allow text content child nodes.
     switch (child->tag()) {
-    case SkSVGTag::kText:
     case SkSVGTag::kTextLiteral:
     case SkSVGTag::kTextPath:
     case SkSVGTag::kTSpan:
@@ -506,10 +505,7 @@
 
 void SkSVGTextContainer::onRenderText(const SkSVGRenderContext& ctx, SkSVGTextContext* tctx,
                                       SkSVGXmlSpace) const {
-    if (!tctx) {
-        // No text context => missing top-level <text> node.
-        return;
-    }
+    SkASSERT(tctx);
 
     const SkSVGTextContext::ScopedPosResolver resolver(*this, ctx.lengthContext(), tctx);
 
@@ -542,10 +538,6 @@
            this->setXmlSpace(SkSVGAttributeParser::parse<SkSVGXmlSpace>("xml:space", name, value));
 }
 
-void SkSVGTextContainer::onRender(const SkSVGRenderContext& ctx) const {
-    this->onRenderText(ctx, nullptr, this->getXmlSpace());
-}
-
 void SkSVGTextLiteral::onRenderText(const SkSVGRenderContext& ctx, SkSVGTextContext* tctx,
                                     SkSVGXmlSpace xs) const {
     SkASSERT(tctx);
@@ -553,17 +545,16 @@
     tctx->appendFragment(this->getText(), ctx, xs);
 }
 
-void SkSVGText::onRenderText(const SkSVGRenderContext& ctx, SkSVGTextContext*,
-                             SkSVGXmlSpace xs) const {
-    // Root text nodes establish a new text layout context.
+void SkSVGText::onRender(const SkSVGRenderContext& ctx) const {
+    // Root <text> nodes establish a text layout context.
     SkSVGTextContext tctx(ctx);
 
-    this->INHERITED::onRenderText(ctx, &tctx, xs);
+    this->onRenderText(ctx, &tctx, this->getXmlSpace());
 }
 
 void SkSVGTextPath::onRenderText(const SkSVGRenderContext& ctx, SkSVGTextContext*,
                                  SkSVGXmlSpace xs) const {
-    // Root text nodes establish a new text layout context.
+    // textPath nodes establish a new text layout context.
     SkSVGTextContext tctx(ctx, this);
 
     this->INHERITED::onRenderText(ctx, &tctx, xs);