KHTML
SVGTextPathElement.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 00003 00004 This file is part of the KDE project 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include "config.h" 00023 #include "wtf/Platform.h" 00024 00025 #if ENABLE(SVG) 00026 #include "SVGTextPathElement.h" 00027 00028 #include "AffineTransform.h" 00029 #include "FloatRect.h" 00030 #include "RenderSVGTextPath.h" 00031 #include "SVGLengthList.h" 00032 #include "SVGPathElement.h" 00033 #include "SVGRenderStyle.h" 00034 #include "SVGTextPathElement.h" 00035 #include "SVGTransformList.h" 00036 00037 namespace WebCore { 00038 00039 SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* doc) 00040 : SVGTextContentElement(tagName, doc) 00041 , SVGURIReference() 00042 , m_startOffset(this, LengthModeOther) 00043 , m_method(SVG_TEXTPATH_METHODTYPE_ALIGN) 00044 , m_spacing(SVG_TEXTPATH_SPACINGTYPE_EXACT) 00045 { 00046 } 00047 00048 SVGTextPathElement::~SVGTextPathElement() 00049 { 00050 } 00051 00052 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, SVGLength, Length, length, StartOffset, startOffset, SVGNames::startOffsetAttr, m_startOffset) 00053 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Method, method, SVGNames::methodAttr, m_method) 00054 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Spacing, spacing, SVGNames::spacingAttr, m_spacing) 00055 00056 void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr) 00057 { 00058 const String& value = attr->value(); 00059 00060 if (attr->name() == SVGNames::startOffsetAttr) 00061 setStartOffsetBaseValue(SVGLength(this, LengthModeOther, value)); 00062 else if (attr->name() == SVGNames::methodAttr) { 00063 if (value == "align") 00064 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN); 00065 else if(value == "stretch") 00066 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH); 00067 } else if (attr->name() == SVGNames::spacingAttr) { 00068 if (value == "auto") 00069 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO); 00070 else if (value == "exact") 00071 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT); 00072 } else { 00073 if (SVGURIReference::parseMappedAttribute(attr)) 00074 return; 00075 SVGTextContentElement::parseMappedAttribute(attr); 00076 } 00077 } 00078 00079 RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style) 00080 { 00081 Q_UNUSED(style); 00082 return new (arena) RenderSVGTextPath(this); 00083 } 00084 00085 bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const 00086 { 00087 if (child->isTextNode() 00088 #if ENABLE(SVG_FONTS) 00089 || child->hasTagName(SVGNames::altGlyphTag) 00090 #endif 00091 || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag)) 00092 return true; 00093 00094 return false; 00095 } 00096 00097 void SVGTextPathElement::insertedIntoDocument() 00098 { 00099 SVGElement::insertedIntoDocument(); 00100 00101 String id = SVGURIReference::getTarget(href()); 00102 Element* targetElement = ownerDocument()->getElementById(id); 00103 if (!targetElement) { 00104 document()->accessSVGExtensions()->addPendingResource(id, this); 00105 return; 00106 } 00107 } 00108 00109 } 00110 00111 #endif // ENABLE(SVG) 00112 00113 // vim:ts=4:noet
KDE 4.6 API Reference