2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
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.
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.
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.
21 #ifndef SVGTextContentElement_h
22 #define SVGTextContentElement_h
24 #include "core/svg/SVGAnimatedBoolean.h"
25 #include "core/svg/SVGAnimatedEnumeration.h"
26 #include "core/svg/SVGAnimatedLength.h"
27 #include "core/svg/SVGGraphicsElement.h"
28 #include "core/svg/SVGPointTearOff.h"
34 enum SVGLengthAdjustType {
35 SVGLengthAdjustUnknown,
36 SVGLengthAdjustSpacing,
37 SVGLengthAdjustSpacingAndGlyphs
39 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGLengthAdjustType>();
41 class SVGTextContentElement : public SVGGraphicsElement {
42 DEFINE_WRAPPERTYPEINFO();
44 // Forward declare enumerations in the W3C naming scheme, for IDL generation.
46 LENGTHADJUST_UNKNOWN = SVGLengthAdjustUnknown,
47 LENGTHADJUST_SPACING = SVGLengthAdjustSpacing,
48 LENGTHADJUST_SPACINGANDGLYPHS = SVGLengthAdjustSpacingAndGlyphs
51 unsigned getNumberOfChars();
52 float getComputedTextLength();
53 float getSubStringLength(unsigned charnum, unsigned nchars, ExceptionState&);
54 PassRefPtr<SVGPointTearOff> getStartPositionOfChar(unsigned charnum, ExceptionState&);
55 PassRefPtr<SVGPointTearOff> getEndPositionOfChar(unsigned charnum, ExceptionState&);
56 PassRefPtr<SVGRectTearOff> getExtentOfChar(unsigned charnum, ExceptionState&);
57 float getRotationOfChar(unsigned charnum, ExceptionState&);
58 int getCharNumAtPosition(PassRefPtr<SVGPointTearOff>, ExceptionState&);
59 void selectSubString(unsigned charnum, unsigned nchars, ExceptionState&);
61 static SVGTextContentElement* elementFromRenderer(RenderObject*);
63 SVGAnimatedLength* textLength() { return m_textLength.get(); }
64 bool textLengthIsSpecifiedByUser() { return m_textLengthIsSpecifiedByUser; }
65 SVGAnimatedEnumeration<SVGLengthAdjustType>* lengthAdjust() { return m_lengthAdjust.get(); }
68 SVGTextContentElement(const QualifiedName&, Document&);
70 bool isSupportedAttribute(const QualifiedName&);
71 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
72 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE FINAL;
73 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE FINAL;
74 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
76 virtual bool selfHasRelativeLengths() const OVERRIDE;
79 virtual bool isTextContent() const OVERRIDE FINAL { return true; }
81 RefPtr<SVGAnimatedLength> m_textLength;
82 bool m_textLengthIsSpecifiedByUser;
83 RefPtr<SVGAnimatedEnumeration<SVGLengthAdjustType> > m_lengthAdjust;
86 inline bool isSVGTextContentElement(const SVGElement& element)
88 return element.isTextContent();
91 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGTextContentElement);
95 #endif // SVGTextContentElement_h