skia2/modules/svg/include/SkSVGText.h
Tyler Denniston b2d1a3bdd7 [svg] Minor cleanups
- Consolidate SVGColor resolution into one method in render context, now
  that it's a shared type.
- Remove all instances of `~TypeName() override = default;`. The only
  thing this provides is slight/unreliable protection against someone
  inadvertently removing 'virtual' from the base class destructor. In
  our case that is SkRefCnt, which I'm assuming has very low risk of
  that happening.
- Clean up some .h copy/paste issues of the form
  `#endif  // Typename_DEFINED`

Change-Id: I67fb40b2828b010fb7fdd83046bc1eae1a476267
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343421
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
2020-12-11 16:25:20 +00:00

77 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:
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