Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / svg / SVGTextPathElement.cpp
blob8a01ad946e68b9ee3c82713c984bff4c479ca234
1 /*
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.
20 #include "config.h"
22 #if ENABLE(SVG)
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"
34 namespace WebCore {
36 SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* doc)
37 : SVGTextContentElement(tagName, doc)
38 , SVGURIReference()
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) {
57 if (value == "align")
58 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN);
59 else if (value == "stretch")
60 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH);
61 } else if (attr->name() == SVGNames::spacingAttr) {
62 if (value == "auto")
63 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO);
64 else if (value == "exact")
65 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT);
66 } else {
67 if (SVGURIReference::parseMappedAttribute(attr))
68 return;
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()
81 #if ENABLE(SVG_FONTS)
82 || child->hasTagName(SVGNames::altGlyphTag)
83 #endif
84 || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag))
85 return true;
87 return false;
90 void SVGTextPathElement::insertedIntoDocument()
92 SVGElement::insertedIntoDocument();
94 String id = SVGURIReference::getTarget(href());
95 Element* targetElement = ownerDocument()->getElementById(id);
96 if (!targetElement) {
97 document()->accessSVGExtensions()->addPendingResource(id, this);
98 return;
104 #endif // ENABLE(SVG)
106 // vim:ts=4:noet