SVGTextElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "SVGTextElement.h"
#include "KCanvasRenderingStyle.h"
#include "SVGAnimatedLengthList.h"
#include "SVGAnimatedTransformList.h"
#include "SVGMatrix.h"
#include "SVGRenderStyle.h"
#include "SVGTSpanElement.h"
#include "RenderStyle.h"
#include <kcanvas/KCanvasCreator.h>
#include <kcanvas/RenderSVGText.h>
namespace WebCore {
SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document *doc)
: SVGTextPositioningElement(tagName, doc), SVGTransformable()
{
}
SVGTextElement::~SVGTextElement()
{
}
SVGAnimatedTransformList *SVGTextElement::transform() const
{
return lazy_create<SVGAnimatedTransformList>(m_transform, this);
}
SVGMatrix *SVGTextElement::localMatrix() const
{
return lazy_create<SVGMatrix>(m_localMatrix);
}
void SVGTextElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == SVGNames::transformAttr) {
SVGTransformList *localTransforms = transform()->baseVal();
localTransforms->clear();
SVGTransformable::parseTransformAttribute(localTransforms, attr->value());
updateLocalTransform(localTransforms);
} else
SVGTextPositioningElement::parseMappedAttribute(attr);
}
void SVGTextElement::updateLocalTransform(SVGTransformList *localTransforms)
{
RefPtr<SVGTransform> localTransform = localTransforms->concatenate();
if(localTransform) {
m_localMatrix = localTransform->matrix();
if (renderer()) {
renderer()->setLocalTransform(m_localMatrix->matrix());
renderer()->setNeedsLayout(true);
}
}
}
void SVGTextElement::attach()
{
SVGStyledElement::attach();
if (renderer() && m_localMatrix)
renderer()->setLocalTransform(m_localMatrix->matrix());
}
SVGElement *SVGTextElement::nearestViewportElement() const
{
return SVGTransformable::nearestViewportElement(this);
}
SVGElement *SVGTextElement::farthestViewportElement() const
{
return SVGTransformable::farthestViewportElement(this);
}
FloatRect SVGTextElement::getBBox() const
{
return SVGTransformable::getBBox(this);
}
SVGMatrix *SVGTextElement::getScreenCTM() const
{
return SVGLocatable::getScreenCTM(this);
}
SVGMatrix *SVGTextElement::getCTM() const
{
return SVGLocatable::getScreenCTM(this);
}
RenderObject *SVGTextElement::createRenderer(RenderArena *arena, RenderStyle *style)
{
return new (arena) RenderSVGText(this);
}
bool SVGTextElement::childShouldCreateRenderer(Node *child) const
{
if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
child->hasTagName(SVGNames::trefTag))
return true;
return false;
}
}
#endif // SVG_SUPPORT