SVGTRefElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "Text.h"
#include "SVGTRefElement.h"
#include "SVGNames.h"
#include "XLinkNames.h"
#include "SVGAnimatedString.h"
#include "SVGDocument.h"
#include "RenderInline.h"
using namespace WebCore;
SVGTRefElement::SVGTRefElement(const QualifiedName& tagName, Document *doc)
: SVGTextPositioningElement(tagName, doc), SVGURIReference()
{
}
SVGTRefElement::~SVGTRefElement()
{
}
void SVGTRefElement::updateReferencedText()
{
String targetId = SVGURIReference::getTarget(String(href()->baseVal()).deprecatedString());
Element *targetElement = ownerDocument()->getElementById(targetId.impl());
SVGElement *target = svg_dynamic_cast(targetElement);
if (target) {
ExceptionCode ignore = 0;
setTextContent(target->textContent().impl(), ignore);
}
}
void SVGTRefElement::attributeChanged(Attribute* attr, bool preserveDecls)
{
if (attr->name().matches(XLinkNames::hrefAttr))
updateReferencedText();
SVGTextPositioningElement::attributeChanged(attr, preserveDecls);
}
void SVGTRefElement::parseMappedAttribute(MappedAttribute *attr)
{
if (SVGURIReference::parseMappedAttribute(attr)) {
updateReferencedText();
return;
}
SVGTextPositioningElement::parseMappedAttribute(attr);
}
bool SVGTRefElement::childShouldCreateRenderer(Node *child) const
{
if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
child->hasTagName(SVGNames::trefTag))
return true;
return false;
}
RenderObject *SVGTRefElement::createRenderer(RenderArena *arena, RenderStyle *)
{
return new (arena) RenderInline(this);
}
#endif // SVG_SUPPORT