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.
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.
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.
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.
26 #include "SVGAltGlyphElement.h"
28 #include "ExceptionCode.h"
29 #include "RenderInline.h"
30 #include "RenderSVGTSpan.h"
31 #include "SVGAltGlyphDefElement.h"
32 #include "SVGGlyphElement.h"
34 #include "XLinkNames.h"
38 // Animated property definitions
39 DEFINE_ANIMATED_STRING(SVGAltGlyphElement, XLinkNames::hrefAttr, Href, href)
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAltGlyphElement)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextPositioningElement)
44 END_REGISTER_ANIMATED_PROPERTIES
46 inline SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* document)
47 : SVGTextPositioningElement(tagName, document)
49 ASSERT(hasTagName(SVGNames::altGlyphTag));
50 registerAnimatedPropertiesForSVGAltGlyphElement();
53 PassRefPtr<SVGAltGlyphElement> SVGAltGlyphElement::create(const QualifiedName& tagName, Document* document)
55 return adoptRef(new SVGAltGlyphElement(tagName, document));
58 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
60 ec = NO_MODIFICATION_ALLOWED_ERR;
63 const AtomicString& SVGAltGlyphElement::glyphRef() const
65 return fastGetAttribute(SVGNames::glyphRefAttr);
68 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
70 ec = NO_MODIFICATION_ALLOWED_ERR;
73 const AtomicString& SVGAltGlyphElement::format() const
75 return fastGetAttribute(SVGNames::formatAttr);
78 bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
80 if (child->isTextNode())
85 RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
87 return new (arena) RenderSVGTSpan(this);
90 bool SVGAltGlyphElement::hasValidGlyphElements(Vector<String>& glyphNames) const
93 Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target);
97 if (element->hasTagName(SVGNames::glyphTag)) {
98 glyphNames.append(target);
102 if (element->hasTagName(SVGNames::altGlyphDefTag)
103 && static_cast<SVGAltGlyphDefElement*>(element)->hasValidGlyphElements(glyphNames))
111 #endif // ENABLE(SVG)