[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/include/SkSVGText.h b/modules/svg/include/SkSVGText.h
index 268647b..1f45fd3 100644
--- a/modules/svg/include/SkSVGText.h
+++ b/modules/svg/include/SkSVGText.h
@@ -26,6 +26,9 @@
virtual void onRenderText(const SkSVGRenderContext&, SkSVGTextContext*,
SkSVGXmlSpace) const = 0;
+ // Text nodes other than the root <text> element are not rendered directly.
+ void onRender(const SkSVGRenderContext&) const override {}
+
private:
SkPath onAsPath(const SkSVGRenderContext&) const final;
@@ -53,8 +56,6 @@
bool parseAndSetAttribute(const char*, const char*) override;
private:
- void onRender(const SkSVGRenderContext&) const final;
-
std::vector<sk_sp<SkSVGTextFragment>> fChildren;
using INHERITED = SkSVGTextFragment;
@@ -67,7 +68,7 @@
private:
SkSVGText() : INHERITED(SkSVGTag::kText) {}
- void onRenderText(const SkSVGRenderContext&, SkSVGTextContext*, SkSVGXmlSpace) const override;
+ void onRender(const SkSVGRenderContext&) const override;
using INHERITED = SkSVGTextContainer;
};
@@ -93,7 +94,6 @@
private:
SkSVGTextLiteral() : INHERITED(SkSVGTag::kTextLiteral) {}
- void onRender(const SkSVGRenderContext&) const override {}
void onRenderText(const SkSVGRenderContext&, SkSVGTextContext*, SkSVGXmlSpace) const override;
void appendChild(sk_sp<SkSVGNode>) override {}