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"
29 #include "platform/heap/Handle.h"
35 enum SVGLengthAdjustType
{
36 SVGLengthAdjustUnknown
,
37 SVGLengthAdjustSpacing
,
38 SVGLengthAdjustSpacingAndGlyphs
40 template<> const SVGEnumerationStringEntries
& getStaticStringEntries
<SVGLengthAdjustType
>();
42 class SVGTextContentElement
: public SVGGraphicsElement
{
43 DEFINE_WRAPPERTYPEINFO();
45 // Forward declare enumerations in the W3C naming scheme, for IDL generation.
47 LENGTHADJUST_UNKNOWN
= SVGLengthAdjustUnknown
,
48 LENGTHADJUST_SPACING
= SVGLengthAdjustSpacing
,
49 LENGTHADJUST_SPACINGANDGLYPHS
= SVGLengthAdjustSpacingAndGlyphs
52 unsigned getNumberOfChars();
53 float getComputedTextLength();
54 float getSubStringLength(unsigned charnum
, unsigned nchars
, ExceptionState
&);
55 PassRefPtrWillBeRawPtr
<SVGPointTearOff
> getStartPositionOfChar(unsigned charnum
, ExceptionState
&);
56 PassRefPtrWillBeRawPtr
<SVGPointTearOff
> getEndPositionOfChar(unsigned charnum
, ExceptionState
&);
57 PassRefPtrWillBeRawPtr
<SVGRectTearOff
> getExtentOfChar(unsigned charnum
, ExceptionState
&);
58 float getRotationOfChar(unsigned charnum
, ExceptionState
&);
59 int getCharNumAtPosition(PassRefPtrWillBeRawPtr
<SVGPointTearOff
>, ExceptionState
&);
60 void selectSubString(unsigned charnum
, unsigned nchars
, ExceptionState
&);
62 static SVGTextContentElement
* elementFromLayoutObject(LayoutObject
*);
64 SVGAnimatedLength
* textLength() { return m_textLength
.get(); }
65 bool textLengthIsSpecifiedByUser() { return m_textLengthIsSpecifiedByUser
; }
66 SVGAnimatedEnumeration
<SVGLengthAdjustType
>* lengthAdjust() { return m_lengthAdjust
.get(); }
68 DECLARE_VIRTUAL_TRACE();
71 SVGTextContentElement(const QualifiedName
&, Document
&);
73 bool isPresentationAttribute(const QualifiedName
&) const final
;
74 void collectStyleForPresentationAttribute(const QualifiedName
&, const AtomicString
&, MutableStylePropertySet
*) final
;
75 void svgAttributeChanged(const QualifiedName
&) override
;
77 bool selfHasRelativeLengths() const override
;
80 bool isTextContent() const final
{ return true; }
82 RefPtrWillBeMember
<SVGAnimatedLength
> m_textLength
;
83 bool m_textLengthIsSpecifiedByUser
;
84 RefPtrWillBeMember
<SVGAnimatedEnumeration
<SVGLengthAdjustType
>> m_lengthAdjust
;
87 inline bool isSVGTextContentElement(const SVGElement
& element
)
89 return element
.isTextContent();
92 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGTextContentElement
);
96 #endif // SVGTextContentElement_h