1/* 2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * 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. 8 * 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. 13 * 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. 18 */ 19 20#ifndef SVGTextPathElement_h 21#define SVGTextPathElement_h 22 23#if ENABLE(SVG) 24#include "SVGTextContentElement.h" 25 26#include "SVGURIReference.h" 27 28namespace WebCore { 29 30enum SVGTextPathMethodType { 31 SVGTextPathMethodUnknown = 0, 32 SVGTextPathMethodAlign, 33 SVGTextPathMethodStretch 34}; 35 36enum SVGTextPathSpacingType { 37 SVGTextPathSpacingUnknown = 0, 38 SVGTextPathSpacingAuto, 39 SVGTextPathSpacingExact 40}; 41 42template<> 43struct SVGPropertyTraits<SVGTextPathMethodType> { 44 static unsigned highestEnumValue() { return SVGTextPathMethodStretch; } 45 46 static String toString(SVGTextPathMethodType type) 47 { 48 switch (type) { 49 case SVGTextPathMethodUnknown: 50 return emptyString(); 51 case SVGTextPathMethodAlign: 52 return "align"; 53 case SVGTextPathMethodStretch: 54 return "stretch"; 55 } 56 57 ASSERT_NOT_REACHED(); 58 return emptyString(); 59 } 60 61 static SVGTextPathMethodType fromString(const String& value) 62 { 63 if (value == "align") 64 return SVGTextPathMethodAlign; 65 if (value == "stretch") 66 return SVGTextPathMethodStretch; 67 return SVGTextPathMethodUnknown; 68 } 69}; 70 71template<> 72struct SVGPropertyTraits<SVGTextPathSpacingType> { 73 static unsigned highestEnumValue() { return SVGTextPathSpacingExact; } 74 75 static String toString(SVGTextPathSpacingType type) 76 { 77 switch (type) { 78 case SVGTextPathSpacingUnknown: 79 return emptyString(); 80 case SVGTextPathSpacingAuto: 81 return "auto"; 82 case SVGTextPathSpacingExact: 83 return "exact"; 84 } 85 86 ASSERT_NOT_REACHED(); 87 return emptyString(); 88 } 89 90 static SVGTextPathSpacingType fromString(const String& value) 91 { 92 if (value == "auto") 93 return SVGTextPathSpacingAuto; 94 if (value == "exact") 95 return SVGTextPathSpacingExact; 96 return SVGTextPathSpacingUnknown; 97 } 98}; 99 100class SVGTextPathElement FINAL : public SVGTextContentElement, 101 public SVGURIReference { 102public: 103 // Forward declare enumerations in the W3C naming scheme, for IDL generation. 104 enum { 105 TEXTPATH_METHODTYPE_UNKNOWN = SVGTextPathMethodUnknown, 106 TEXTPATH_METHODTYPE_ALIGN = SVGTextPathMethodAlign, 107 TEXTPATH_METHODTYPE_STRETCH = SVGTextPathMethodStretch, 108 TEXTPATH_SPACINGTYPE_UNKNOWN = SVGTextPathSpacingUnknown, 109 TEXTPATH_SPACINGTYPE_AUTO = SVGTextPathSpacingAuto, 110 TEXTPATH_SPACINGTYPE_EXACT = SVGTextPathSpacingExact 111 }; 112 113 static PassRefPtr<SVGTextPathElement> create(const QualifiedName&, Document*); 114 115protected: 116 virtual void didNotifySubtreeInsertions(ContainerNode*) override; 117 118private: 119 SVGTextPathElement(const QualifiedName&, Document*); 120 121 virtual ~SVGTextPathElement(); 122 123 void clearResourceReferences(); 124 125 virtual void buildPendingResource(); 126 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 127 virtual void removedFrom(ContainerNode*) OVERRIDE; 128 129 bool isSupportedAttribute(const QualifiedName&); 130 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 131 virtual void svgAttributeChanged(const QualifiedName&); 132 133 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 134 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const; 135 virtual bool rendererIsNeeded(const NodeRenderingContext&); 136 137 virtual bool selfHasRelativeLengths() const; 138 139 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGTextPathElement) 140 DECLARE_ANIMATED_LENGTH(StartOffset, startOffset) 141 DECLARE_ANIMATED_ENUMERATION(Method, method, SVGTextPathMethodType) 142 DECLARE_ANIMATED_ENUMERATION(Spacing, spacing, SVGTextPathSpacingType) 143 DECLARE_ANIMATED_STRING(Href, href) 144 END_DECLARE_ANIMATED_PROPERTIES 145}; 146 147} // namespace WebCore 148 149#endif // ENABLE(SVG) 150#endif 151