1 /*
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 Copyright (C) 2008 Apple Computer, Inc.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20 */
21
22 #include "config.h"
23
24 #if ENABLE(SVG_FONTS)
25 #include "SVGAltGlyphElement.h"
26
27 #include "ExceptionCode.h"
28 #include "RenderInline.h"
29 #include "RenderSVGTSpan.h"
30 #include "SVGGlyphElement.h"
31 #include "SVGNames.h"
32 #include "XLinkNames.h"
33
34 namespace WebCore {
35
SVGAltGlyphElement(const QualifiedName & tagName,Document * doc)36 SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* doc)
37 : SVGTextPositioningElement(tagName, doc)
38 {
39 }
40
~SVGAltGlyphElement()41 SVGAltGlyphElement::~SVGAltGlyphElement()
42 {
43 }
44
setGlyphRef(const AtomicString &,ExceptionCode & ec)45 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
46 {
47 ec = NO_MODIFICATION_ALLOWED_ERR;
48 }
49
glyphRef() const50 const AtomicString& SVGAltGlyphElement::glyphRef() const
51 {
52 return getAttribute(SVGNames::glyphRefAttr);
53 }
54
setFormat(const AtomicString &,ExceptionCode & ec)55 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
56 {
57 ec = NO_MODIFICATION_ALLOWED_ERR;
58 }
59
format() const60 const AtomicString& SVGAltGlyphElement::format() const
61 {
62 return getAttribute(SVGNames::formatAttr);
63 }
64
childShouldCreateRenderer(Node * child) const65 bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
66 {
67 if (child->isTextNode())
68 return true;
69 return false;
70 }
71
createRenderer(RenderArena * arena,RenderStyle *)72 RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
73 {
74 return new (arena) RenderSVGTSpan(this);
75 }
76
glyphElement() const77 SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
78 {
79 Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
80 if (!elt || !elt->hasTagName(SVGNames::glyphTag))
81 return 0;
82 return static_cast<SVGGlyphElement*>(elt);
83 }
84
85 }
86
87 #endif // ENABLE(SVG)
88
89 // vim:ts=4:noet
90