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#include "SVGAltGlyphElement.h" 25 26#if ENABLE(SVG_FONTS) 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 36namespace WebCore { 37 38// Animated property definitions 39DEFINE_ANIMATED_STRING(SVGAltGlyphElement, XLinkNames::hrefAttr, Href, href) 40 41BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAltGlyphElement) 42 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextPositioningElement) 44END_REGISTER_ANIMATED_PROPERTIES 45 46inline SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document& document) 47 : SVGTextPositioningElement(tagName, document) 48{ 49 ASSERT(hasTagName(SVGNames::altGlyphTag)); 50 registerAnimatedPropertiesForSVGAltGlyphElement(); 51} 52 53PassRefPtr<SVGAltGlyphElement> SVGAltGlyphElement::create(const QualifiedName& tagName, Document& document) 54{ 55 return adoptRef(new SVGAltGlyphElement(tagName, document)); 56} 57 58void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec) 59{ 60 ec = NO_MODIFICATION_ALLOWED_ERR; 61} 62 63const AtomicString& SVGAltGlyphElement::glyphRef() const 64{ 65 return fastGetAttribute(SVGNames::glyphRefAttr); 66} 67 68void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec) 69{ 70 ec = NO_MODIFICATION_ALLOWED_ERR; 71} 72 73const AtomicString& SVGAltGlyphElement::format() const 74{ 75 return fastGetAttribute(SVGNames::formatAttr); 76} 77 78bool SVGAltGlyphElement::childShouldCreateRenderer(const Node& child) const 79{ 80 if (child.isTextNode()) 81 return true; 82 return false; 83} 84 85RenderPtr<RenderElement> SVGAltGlyphElement::createElementRenderer(PassRef<RenderStyle> style) 86{ 87 return createRenderer<RenderSVGTSpan>(*this, WTF::move(style)); 88} 89 90bool 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 (isSVGGlyphElement(element)) { 98 glyphNames.append(target); 99 return true; 100 } 101 102 if (isSVGAltGlyphDefElement(element) 103 && toSVGAltGlyphDefElement(element)->hasValidGlyphElements(glyphNames)) 104 return true; 105 106 return false; 107} 108 109} 110 111#endif 112