Home | History | Annotate | Download | only in svg
      1 /*
      2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005, 2006 Rob Buis <buis (at) 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 
     36 SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* doc)
     37     : SVGTextPositioningElement(tagName, doc)
     38 {
     39 }
     40 
     41 SVGAltGlyphElement::~SVGAltGlyphElement()
     42 {
     43 }
     44 
     45 void SVGAltGlyphElement::synchronizeProperty(const QualifiedName& attrName)
     46 {
     47     SVGTextPositioningElement::synchronizeProperty(attrName);
     48 
     49     if (attrName == anyQName() || SVGURIReference::isKnownAttribute(attrName))
     50         synchronizeHref();
     51 }
     52 
     53 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
     54 {
     55     ec = NO_MODIFICATION_ALLOWED_ERR;
     56 }
     57 
     58 const AtomicString& SVGAltGlyphElement::glyphRef() const
     59 {
     60     return getAttribute(SVGNames::glyphRefAttr);
     61 }
     62 
     63 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
     64 {
     65     ec = NO_MODIFICATION_ALLOWED_ERR;
     66 }
     67 
     68 const AtomicString& SVGAltGlyphElement::format() const
     69 {
     70     return getAttribute(SVGNames::formatAttr);
     71 }
     72 
     73 bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
     74 {
     75     if (child->isTextNode())
     76         return true;
     77     return false;
     78 }
     79 
     80 RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
     81 {
     82     return new (arena) RenderSVGTSpan(this);
     83 }
     84 
     85 SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
     86 {
     87     Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
     88     if (!elt || !elt->hasTagName(SVGNames::glyphTag))
     89         return 0;
     90     return static_cast<SVGGlyphElement*>(elt);
     91 }
     92 
     93 }
     94 
     95 #endif // ENABLE(SVG)
     96 
     97 // vim:ts=4:noet
     98