2020-10-15 22:10:29 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
#include "modules/svg/include/SkSVGContainer.h"
|
2020-10-15 22:10:29 +00:00
|
|
|
#include "modules/svg/include/SkSVGTypes.h"
|
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
// 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))
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-09 18:02:50 +00:00
|
|
|
SVG_ATTR(XmlSpace, SkSVGXmlSpace, SkSVGXmlSpace::kDefault)
|
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
protected:
|
|
|
|
explicit SkSVGTextContainer(SkSVGTag t) : INHERITED(t) {}
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
private:
|
|
|
|
void appendChild(sk_sp<SkSVGNode>) final;
|
2020-12-09 18:02:50 +00:00
|
|
|
bool onPrepareToRender(SkSVGRenderContext*) const final;
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
bool parseAndSetAttribute(const char*, const char*) override;
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
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:
|
|
|
|
static sk_sp<SkSVGTextLiteral> Make() {
|
|
|
|
return sk_sp<SkSVGTextLiteral>(new SkSVGTextLiteral());
|
|
|
|
}
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
SVG_ATTR(Text, SkSVGStringType, SkSVGStringType())
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
private:
|
|
|
|
SkSVGTextLiteral() : INHERITED(SkSVGTag::kTextLiteral) {}
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
void onRender(const SkSVGRenderContext&) const override;
|
|
|
|
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
2020-10-20 14:43:03 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
void appendChild(sk_sp<SkSVGNode>) override {}
|
2020-10-20 14:43:03 +00:00
|
|
|
|
2020-12-06 16:50:52 +00:00
|
|
|
using INHERITED = SkSVGNode;
|
2020-10-15 22:10:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkSVGText_DEFINED
|