skia2/modules/svg/include/SkSVGText.h
Florin Malita 9c1f1be078 [svg] xml:space support
Add xml:space attribute and implement related white space filters.

(https://www.w3.org/TR/SVG11/text.html#WhiteSpace)

Bug: skia:10840
Change-Id: I52fda50fae1cd7cf8b0dd7c1a2ee2e667ffa947b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342299
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-12-09 20:07:25 +00:00

79 lines
2.0 KiB
C++

/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSVGText_DEFINED
#define SkSVGText_DEFINED
#include "modules/svg/include/SkSVGContainer.h"
#include "modules/svg/include/SkSVGTypes.h"
// Base class for nestable text containers (<text>, <tspan>, etc).
class SkSVGTextContainer : public SkSVGContainer {
public:
// TODO: these should be arrays
SVG_ATTR(X, SkSVGLength, SkSVGLength(0))
SVG_ATTR(Y, SkSVGLength, SkSVGLength(0))
SVG_ATTR(XmlSpace, SkSVGXmlSpace, SkSVGXmlSpace::kDefault)
protected:
explicit SkSVGTextContainer(SkSVGTag t) : INHERITED(t) {}
private:
void appendChild(sk_sp<SkSVGNode>) final;
bool onPrepareToRender(SkSVGRenderContext*) const final;
bool parseAndSetAttribute(const char*, const char*) override;
using INHERITED = SkSVGContainer;
};
class SkSVGText final : public SkSVGTextContainer {
public:
static sk_sp<SkSVGText> Make() { return sk_sp<SkSVGText>(new SkSVGText()); }
private:
SkSVGText() : INHERITED(SkSVGTag::kText) {}
void onRender(const SkSVGRenderContext&) const override;
using INHERITED = SkSVGTextContainer;
};
class SkSVGTSpan final : public SkSVGTextContainer {
public:
static sk_sp<SkSVGTSpan> Make() { return sk_sp<SkSVGTSpan>(new SkSVGTSpan()); }
private:
SkSVGTSpan() : INHERITED(SkSVGTag::kTSpan) {}
using INHERITED = SkSVGTextContainer;
};
class SkSVGTextLiteral final : public SkSVGNode {
public:
~SkSVGTextLiteral() override;
static sk_sp<SkSVGTextLiteral> Make() {
return sk_sp<SkSVGTextLiteral>(new SkSVGTextLiteral());
}
SVG_ATTR(Text, SkSVGStringType, SkSVGStringType())
private:
SkSVGTextLiteral() : INHERITED(SkSVGTag::kTextLiteral) {}
void onRender(const SkSVGRenderContext&) const override;
SkPath onAsPath(const SkSVGRenderContext&) const override;
void appendChild(sk_sp<SkSVGNode>) override {}
using INHERITED = SkSVGNode;
};
#endif // SkSVGText_DEFINED