1 /* 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef SVGTextContentElement_h 22 #define SVGTextContentElement_h 23 24 #if ENABLE(SVG) 25 #include "SVGAnimatedBoolean.h" 26 #include "SVGAnimatedEnumeration.h" 27 #include "SVGAnimatedLength.h" 28 #include "SVGExternalResourcesRequired.h" 29 #include "SVGLangSpace.h" 30 #include "SVGStyledElement.h" 31 #include "SVGTests.h" 32 33 namespace WebCore { 34 35 class SVGTextContentElement : public SVGStyledElement, 36 public SVGTests, 37 public SVGLangSpace, 38 public SVGExternalResourcesRequired { 39 public: 40 enum SVGLengthAdjustType { 41 LENGTHADJUST_UNKNOWN = 0, 42 LENGTHADJUST_SPACING = 1, 43 LENGTHADJUST_SPACINGANDGLYPHS = 2 44 }; 45 46 unsigned getNumberOfChars() const; 47 float getComputedTextLength() const; 48 float getSubStringLength(unsigned charnum, unsigned nchars, ExceptionCode&) const; 49 FloatPoint getStartPositionOfChar(unsigned charnum, ExceptionCode&) const; 50 FloatPoint getEndPositionOfChar(unsigned charnum, ExceptionCode&) const; 51 FloatRect getExtentOfChar(unsigned charnum, ExceptionCode&) const; 52 float getRotationOfChar(unsigned charnum, ExceptionCode&) const; 53 int getCharNumAtPosition(const FloatPoint&) const; 54 void selectSubString(unsigned charnum, unsigned nchars, ExceptionCode&) const; 55 56 static SVGTextContentElement* elementFromRenderer(RenderObject*); 57 58 // textLength is not declared using the standard DECLARE_ANIMATED_LENGTH macro 59 // as its getter needs special handling (return getComputedTextLength(), instead of m_textLength). specifiedTextLength()60 SVGLength& specifiedTextLength() { return m_specifiedTextLength; } 61 PassRefPtr<SVGAnimatedLength> textLengthAnimated(); 62 63 protected: 64 SVGTextContentElement(const QualifiedName&, Document*); 65 isValid()66 virtual bool isValid() const { return SVGTests::isValid(); } 67 68 virtual void parseMappedAttribute(Attribute*); 69 virtual void svgAttributeChanged(const QualifiedName&); 70 virtual void synchronizeProperty(const QualifiedName&); 71 void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&); 72 73 virtual bool selfHasRelativeLengths() const; 74 75 private: isTextContent()76 virtual bool isTextContent() const { return true; } 77 78 // Animated property declarations 79 void synchronizeTextLength(); 80 SVGLength m_specifiedTextLength; 81 mutable SVGSynchronizableAnimatedProperty<SVGLength> m_textLength; 82 DECLARE_ANIMATED_ENUMERATION(LengthAdjust, lengthAdjust) 83 84 // SVGExternalResourcesRequired 85 DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired) 86 }; 87 88 } // namespace WebCore 89 90 #endif // ENABLE(SVG) 91 #endif 92