2 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include "SVGTextPathElement.h"
25 #include "FloatRect.h"
26 #include "MappedAttribute.h"
27 #include "RenderSVGTextPath.h"
28 #include "SVGLengthList.h"
29 #include "SVGPathElement.h"
30 #include "SVGRenderStyle.h"
31 #include "SVGTransformList.h"
32 #include "TransformationMatrix.h"
36 SVGTextPathElement::SVGTextPathElement(const QualifiedName
& tagName
, Document
* doc
)
37 : SVGTextContentElement(tagName
, doc
)
39 , m_startOffset(this, SVGNames::startOffsetAttr
, LengthModeOther
)
40 , m_method(this, SVGNames::methodAttr
, SVG_TEXTPATH_METHODTYPE_ALIGN
)
41 , m_spacing(this, SVGNames::spacingAttr
, SVG_TEXTPATH_SPACINGTYPE_EXACT
)
42 , m_href(this, XLinkNames::hrefAttr
)
46 SVGTextPathElement::~SVGTextPathElement()
50 void SVGTextPathElement::parseMappedAttribute(MappedAttribute
* attr
)
52 const String
& value
= attr
->value();
54 if (attr
->name() == SVGNames::startOffsetAttr
)
55 setStartOffsetBaseValue(SVGLength(LengthModeOther
, value
));
56 else if (attr
->name() == SVGNames::methodAttr
) {
58 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN
);
59 else if (value
== "stretch")
60 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH
);
61 } else if (attr
->name() == SVGNames::spacingAttr
) {
63 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO
);
64 else if (value
== "exact")
65 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT
);
67 if (SVGURIReference::parseMappedAttribute(attr
))
69 SVGTextContentElement::parseMappedAttribute(attr
);
73 RenderObject
* SVGTextPathElement::createRenderer(RenderArena
* arena
, RenderStyle
*)
75 return new (arena
) RenderSVGTextPath(this);
78 bool SVGTextPathElement::childShouldCreateRenderer(Node
* child
) const
80 if (child
->isTextNode()
82 || child
->hasTagName(SVGNames::altGlyphTag
)
84 || child
->hasTagName(SVGNames::trefTag
) || child
->hasTagName(SVGNames::tspanTag
) || child
->hasTagName(SVGNames::textPathTag
))
90 void SVGTextPathElement::insertedIntoDocument()
92 SVGElement::insertedIntoDocument();
94 String id
= SVGURIReference::getTarget(href());
95 Element
* targetElement
= ownerDocument()->getElementById(id
);
97 document()->accessSVGExtensions()->addPendingResource(id
, this);
104 #endif // ENABLE(SVG)