2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include "SVGTRefElement.h"
26 #include "RenderSVGInline.h"
27 #include "RenderSVGResource.h"
28 #include "SVGDocument.h"
31 #include "XLinkNames.h"
35 inline SVGTRefElement::SVGTRefElement(const QualifiedName& tagName, Document* document)
36 : SVGTextPositioningElement(tagName, document)
40 PassRefPtr<SVGTRefElement> SVGTRefElement::create(const QualifiedName& tagName, Document* document)
42 return adoptRef(new SVGTRefElement(tagName, document));
45 void SVGTRefElement::updateReferencedText()
47 Element* target = document()->getElementById(SVGURIReference::getTarget(href()));
49 if (target && target->isSVGElement())
50 textContent = static_cast<SVGElement*>(target)->textContent();
51 ExceptionCode ignore = 0;
52 setTextContent(textContent, ignore);
55 void SVGTRefElement::parseMappedAttribute(Attribute* attr)
57 if (SVGURIReference::parseMappedAttribute(attr)) {
58 updateReferencedText();
62 SVGTextPositioningElement::parseMappedAttribute(attr);
65 void SVGTRefElement::svgAttributeChanged(const QualifiedName& attrName)
67 SVGTextPositioningElement::svgAttributeChanged(attrName);
72 if (SVGURIReference::isKnownAttribute(attrName))
73 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer());
76 void SVGTRefElement::synchronizeProperty(const QualifiedName& attrName)
78 SVGTextPositioningElement::synchronizeProperty(attrName);
80 if (attrName == anyQName() || SVGURIReference::isKnownAttribute(attrName))
84 bool SVGTRefElement::childShouldCreateRenderer(Node* child) const
86 if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
87 child->hasTagName(SVGNames::trefTag))
92 RenderObject* SVGTRefElement::createRenderer(RenderArena* arena, RenderStyle*)
94 return new (arena) RenderSVGInline(this);