SVGTextElement.cpp [plain text]
#include "config.h"
#include "SVGTextElement.h"
#include "RenderSVGResource.h"
#include "RenderSVGText.h"
#include "SVGNames.h"
#include "SVGRenderStyle.h"
#include "SVGTSpanElement.h"
namespace WebCore {
inline SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document& document)
: SVGTextPositioningElement(tagName, document)
{
ASSERT(hasTagName(SVGNames::textTag));
}
Ref<SVGTextElement> SVGTextElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new SVGTextElement(tagName, document));
}
AffineTransform SVGTextElement::animatedLocalTransform() const
{
AffineTransform matrix;
auto* style = renderer() ? &renderer()->style() : nullptr;
if (style && style->hasTransform()) {
TransformationMatrix t;
style->applyTransform(t, FloatRect(0, 0, 0, 0), RenderStyle::ExcludeTransformOrigin);
matrix = t.toAffineTransform();
} else
transform().concatenate(matrix);
const AffineTransform* transform = const_cast<SVGTextElement*>(this)->supplementalTransform();
if (transform)
return *transform * matrix;
return matrix;
}
RenderPtr<RenderElement> SVGTextElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
return createRenderer<RenderSVGText>(*this, WTFMove(style));
}
bool SVGTextElement::childShouldCreateRenderer(const Node& child) const
{
if (child.isTextNode()
|| child.hasTagName(SVGNames::aTag)
#if ENABLE(SVG_FONTS)
|| child.hasTagName(SVGNames::altGlyphTag)
#endif
|| child.hasTagName(SVGNames::textPathTag)
|| child.hasTagName(SVGNames::trefTag)
|| child.hasTagName(SVGNames::tspanTag))
return true;
return false;
}
}