tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / svg / SVGAltGlyphElement.cpp
1 /*
2  * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4  * Copyright (C) 2008 Apple Inc. All rights reserved.
5  * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #include "config.h"
24
25 #if ENABLE(SVG_FONTS)
26 #include "SVGAltGlyphElement.h"
27
28 #include "ExceptionCode.h"
29 #include "RenderInline.h"
30 #include "RenderSVGTSpan.h"
31 #include "SVGAltGlyphDefElement.h"
32 #include "SVGGlyphElement.h"
33 #include "SVGNames.h"
34 #include "XLinkNames.h"
35
36 namespace WebCore {
37
38 // Animated property definitions
39 DEFINE_ANIMATED_STRING(SVGAltGlyphElement, XLinkNames::hrefAttr, Href, href)
40
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAltGlyphElement)
42     REGISTER_LOCAL_ANIMATED_PROPERTY(href)
43     REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextPositioningElement)
44 END_REGISTER_ANIMATED_PROPERTIES
45
46 inline SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* document)
47     : SVGTextPositioningElement(tagName, document)
48 {
49     ASSERT(hasTagName(SVGNames::altGlyphTag));
50     registerAnimatedPropertiesForSVGAltGlyphElement();
51 }
52
53 PassRefPtr<SVGAltGlyphElement> SVGAltGlyphElement::create(const QualifiedName& tagName, Document* document)
54 {
55     return adoptRef(new SVGAltGlyphElement(tagName, document));
56 }
57
58 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
59 {
60     ec = NO_MODIFICATION_ALLOWED_ERR;
61 }
62
63 const AtomicString& SVGAltGlyphElement::glyphRef() const
64 {
65     return fastGetAttribute(SVGNames::glyphRefAttr);
66 }
67
68 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
69 {
70     ec = NO_MODIFICATION_ALLOWED_ERR;
71 }
72
73 const AtomicString& SVGAltGlyphElement::format() const
74 {
75     return fastGetAttribute(SVGNames::formatAttr);
76 }
77
78 bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
79 {
80     if (child->isTextNode())
81         return true;
82     return false;
83 }
84
85 RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
86 {
87     return new (arena) RenderSVGTSpan(this);
88 }
89
90 bool SVGAltGlyphElement::hasValidGlyphElements(Vector<String>& glyphNames) const
91 {
92     String target;
93     Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target);
94     if (!element)
95         return false;
96
97     if (element->hasTagName(SVGNames::glyphTag)) {
98         glyphNames.append(target);
99         return true;
100     }
101
102     if (element->hasTagName(SVGNames::altGlyphDefTag)
103         && static_cast<SVGAltGlyphDefElement*>(element)->hasValidGlyphElements(glyphNames))
104         return true;
105
106     return false;
107 }
108
109 }
110
111 #endif // ENABLE(SVG)