Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis (at) kde.org>
      4  * Copyright (C) 2008 Apple Inc. All rights reserved.
      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 
     36 // Animated property declarations
     37 DEFINE_ANIMATED_STRING(SVGAltGlyphElement, XLinkNames::hrefAttr, Href, href)
     38 
     39 inline SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* document)
     40     : SVGTextPositioningElement(tagName, document)
     41 {
     42 }
     43 
     44 PassRefPtr<SVGAltGlyphElement> SVGAltGlyphElement::create(const QualifiedName& tagName, Document* document)
     45 {
     46     return adoptRef(new SVGAltGlyphElement(tagName, document));
     47 }
     48 
     49 void SVGAltGlyphElement::synchronizeProperty(const QualifiedName& attrName)
     50 {
     51     SVGTextPositioningElement::synchronizeProperty(attrName);
     52 
     53     if (attrName == anyQName() || SVGURIReference::isKnownAttribute(attrName))
     54         synchronizeHref();
     55 }
     56 
     57 AttributeToPropertyTypeMap& SVGAltGlyphElement::attributeToPropertyTypeMap()
     58 {
     59     DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ());
     60     return s_attributeToPropertyTypeMap;
     61 }
     62 
     63 void SVGAltGlyphElement::fillAttributeToPropertyTypeMap()
     64 {
     65     AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap();
     66 
     67     SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);
     68     attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString);
     69 }
     70 
     71 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
     72 {
     73     ec = NO_MODIFICATION_ALLOWED_ERR;
     74 }
     75 
     76 const AtomicString& SVGAltGlyphElement::glyphRef() const
     77 {
     78     return getAttribute(SVGNames::glyphRefAttr);
     79 }
     80 
     81 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
     82 {
     83     ec = NO_MODIFICATION_ALLOWED_ERR;
     84 }
     85 
     86 const AtomicString& SVGAltGlyphElement::format() const
     87 {
     88     return getAttribute(SVGNames::formatAttr);
     89 }
     90 
     91 bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
     92 {
     93     if (child->isTextNode())
     94         return true;
     95     return false;
     96 }
     97 
     98 RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
     99 {
    100     return new (arena) RenderSVGTSpan(this);
    101 }
    102 
    103 SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
    104 {
    105     Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
    106     if (!elt || !elt->hasTagName(SVGNames::glyphTag))
    107         return 0;
    108     return static_cast<SVGGlyphElement*>(elt);
    109 }
    110 
    111 }
    112 
    113 #endif // ENABLE(SVG)
    114 
    115 // vim:ts=4:noet
    116