don't discard iframe children.
[kdelibs.git] / khtml / svg / SVGTextPathElement.cpp
blob5b80aa7d0fc86da3da3cf7c93949cb64ca375ee3
1 /*
2 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 This file is part of the KDE project
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include "config.h"
23 #include "wtf/Platform.h"
25 #if ENABLE(SVG)
26 #include "SVGTextPathElement.h"
28 #include "AffineTransform.h"
29 #include "FloatRect.h"
30 #include "RenderSVGTextPath.h"
31 #include "SVGLengthList.h"
32 #include "SVGPathElement.h"
33 #include "SVGRenderStyle.h"
34 #include "SVGTextPathElement.h"
35 #include "SVGTransformList.h"
37 namespace WebCore {
39 SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* doc)
40 : SVGTextContentElement(tagName, doc)
41 , SVGURIReference()
42 , m_startOffset(this, LengthModeOther)
43 , m_method(SVG_TEXTPATH_METHODTYPE_ALIGN)
44 , m_spacing(SVG_TEXTPATH_SPACINGTYPE_EXACT)
48 SVGTextPathElement::~SVGTextPathElement()
52 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, SVGLength, Length, length, StartOffset, startOffset, SVGNames::startOffsetAttr, m_startOffset)
53 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Method, method, SVGNames::methodAttr, m_method)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Spacing, spacing, SVGNames::spacingAttr, m_spacing)
56 void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr)
58 const String& value = attr->value();
60 if (attr->name() == SVGNames::startOffsetAttr)
61 setStartOffsetBaseValue(SVGLength(this, LengthModeOther, value));
62 else if (attr->name() == SVGNames::methodAttr) {
63 if (value == "align")
64 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN);
65 else if(value == "stretch")
66 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH);
67 } else if (attr->name() == SVGNames::spacingAttr) {
68 if (value == "auto")
69 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO);
70 else if (value == "exact")
71 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT);
72 } else {
73 if (SVGURIReference::parseMappedAttribute(attr))
74 return;
75 SVGTextContentElement::parseMappedAttribute(attr);
79 RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style)
81 return new (arena) RenderSVGTextPath(this);
84 bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const
86 if (child->isTextNode()
87 #if ENABLE(SVG_FONTS)
88 || child->hasTagName(SVGNames::altGlyphTag)
89 #endif
90 || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag))
91 return true;
93 return false;
96 void SVGTextPathElement::insertedIntoDocument()
98 SVGElement::insertedIntoDocument();
100 String id = SVGURIReference::getTarget(href());
101 Element* targetElement = ownerDocument()->getElementById(id);
102 if (!targetElement) {
103 document()->accessSVGExtensions()->addPendingResource(id, this);
104 return;
110 #endif // ENABLE(SVG)
112 // vim:ts=4:noet