• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

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     return new (arena) RenderSVGTextPath(this);
00082 }
00083 
00084 bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const
00085 {
00086     if (child->isTextNode()
00087 #if ENABLE(SVG_FONTS)
00088         || child->hasTagName(SVGNames::altGlyphTag)
00089 #endif
00090         || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag))
00091         return true;
00092 
00093     return false;
00094 }
00095 
00096 void SVGTextPathElement::insertedIntoDocument()
00097 {
00098     SVGElement::insertedIntoDocument();
00099 
00100     String id = SVGURIReference::getTarget(href());
00101     Element* targetElement = ownerDocument()->getElementById(id);
00102     if (!targetElement) {
00103         document()->accessSVGExtensions()->addPendingResource(id, this);
00104         return;
00105     }
00106 }
00107 
00108 }
00109 
00110 #endif // ENABLE(SVG)
00111 
00112 // vim:ts=4:noet

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal