2 Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #include "wtf/Platform.h"
27 #include "SVGTextElement.h"
29 #include "AffineTransform.h"
30 #include "FloatRect.h"
31 #include "RenderSVGText.h"
32 #include "SVGLengthList.h"
33 #include "SVGRenderStyle.h"
34 #include "SVGTSpanElement.h"
35 #include "SVGTransformList.h"
39 SVGTextElement::SVGTextElement(const QualifiedName
& tagName
, Document
* doc
)
40 : SVGTextPositioningElement(tagName
, doc
)
42 , m_transform(SVGTransformList::create(SVGNames::transformAttr
))
46 SVGTextElement::~SVGTextElement()
50 ANIMATED_PROPERTY_DEFINITIONS(SVGTextElement
, SVGTransformList
*, TransformList
, transformList
, Transform
, transform
, SVGNames::transformAttr
, m_transform
.get())
52 void SVGTextElement::parseMappedAttribute(MappedAttribute
* attr
)
54 if (attr
->name() == SVGNames::transformAttr
) {
55 SVGTransformList
* localTransforms
= transformBaseValue();
58 localTransforms
->clear(ec
);
60 if (!SVGTransformable::parseTransformAttribute(localTransforms
, attr
->value()))
61 localTransforms
->clear(ec
);
63 setTransformBaseValue(localTransforms
);
65 renderer()->setNeedsLayout(true); // should be in setTransformBaseValue
68 SVGTextPositioningElement::parseMappedAttribute(attr
);
71 SVGElement
* SVGTextElement::nearestViewportElement() const
73 return SVGTransformable::nearestViewportElement(this);
76 SVGElement
* SVGTextElement::farthestViewportElement() const
78 return SVGTransformable::farthestViewportElement(this);
81 FloatRect
SVGTextElement::getBBox() const
83 return SVGTransformable::getBBox(this);
86 AffineTransform
SVGTextElement::getScreenCTM() const
88 return SVGTransformable::getScreenCTM(this);
91 AffineTransform
SVGTextElement::getCTM() const
93 return SVGTransformable::getCTM(this);
96 AffineTransform
SVGTextElement::animatedLocalTransform() const
98 return m_supplementalTransform
? transform()->concatenate().matrix() * *m_supplementalTransform
: transform()->concatenate().matrix();
101 AffineTransform
* SVGTextElement::supplementalTransform()
103 if (!m_supplementalTransform
)
104 m_supplementalTransform
.set(new AffineTransform());
105 return m_supplementalTransform
.get();
108 RenderObject
* SVGTextElement::createRenderer(RenderArena
* arena
, RenderStyle
* style
)
110 kDebug() << "create renderer for <text>" << endl
;
111 return new (arena
) RenderSVGText(this);
114 bool SVGTextElement::childShouldCreateRenderer(Node
* child
) const
116 if (child
->isTextNode()
117 #if ENABLE(SVG_FONTS)
118 || child
->hasTagName(SVGNames::altGlyphTag
)
120 || child
->hasTagName(SVGNames::tspanTag
) || child
->hasTagName(SVGNames::trefTag
) || child
->hasTagName(SVGNames::aTag
) || child
->hasTagName(SVGNames::textPathTag
))
125 void SVGTextElement::svgAttributeChanged(const QualifiedName
& attrName
)
127 SVGTextPositioningElement::svgAttributeChanged(attrName
);
132 if (SVGTextPositioningElement::isKnownAttribute(attrName
))
133 renderer()->setNeedsLayout(true);
138 #endif // ENABLE(SVG)