Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGTextContentElement.h
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 #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"
29
30 namespace blink {
31
32 class ExceptionState;
33
34 enum SVGLengthAdjustType {
35     SVGLengthAdjustUnknown,
36     SVGLengthAdjustSpacing,
37     SVGLengthAdjustSpacingAndGlyphs
38 };
39 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGLengthAdjustType>();
40
41 class SVGTextContentElement : public SVGGraphicsElement {
42     DEFINE_WRAPPERTYPEINFO();
43 public:
44     // Forward declare enumerations in the W3C naming scheme, for IDL generation.
45     enum {
46         LENGTHADJUST_UNKNOWN = SVGLengthAdjustUnknown,
47         LENGTHADJUST_SPACING = SVGLengthAdjustSpacing,
48         LENGTHADJUST_SPACINGANDGLYPHS = SVGLengthAdjustSpacingAndGlyphs
49     };
50
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&);
60
61     static SVGTextContentElement* elementFromRenderer(RenderObject*);
62
63     SVGAnimatedLength* textLength() { return m_textLength.get(); }
64     bool textLengthIsSpecifiedByUser() { return m_textLengthIsSpecifiedByUser; }
65     SVGAnimatedEnumeration<SVGLengthAdjustType>* lengthAdjust() { return m_lengthAdjust.get(); }
66
67 protected:
68     SVGTextContentElement(const QualifiedName&, Document&);
69
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;
75
76     virtual bool selfHasRelativeLengths() const OVERRIDE;
77
78 private:
79     virtual bool isTextContent() const OVERRIDE FINAL { return true; }
80
81     RefPtr<SVGAnimatedLength> m_textLength;
82     bool m_textLengthIsSpecifiedByUser;
83     RefPtr<SVGAnimatedEnumeration<SVGLengthAdjustType> > m_lengthAdjust;
84 };
85
86 inline bool isSVGTextContentElement(const SVGElement& element)
87 {
88     return element.isTextContent();
89 }
90
91 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGTextContentElement);
92
93 } // namespace blink
94
95 #endif // SVGTextContentElement_h