2 * Copyright (C) 2011 Leo Yang <leoyang@webkit.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #if ENABLE(SVG) && ENABLE(SVG_FONTS)
23 #include "SVGGlyphRefElement.h"
25 #include "SVGGlyphElement.h"
27 #include "SVGParserUtilities.h"
28 #include "XLinkNames.h"
29 #include <wtf/text/AtomicString.h>
33 // Animated property definitions
34 DEFINE_ANIMATED_STRING(SVGGlyphRefElement, XLinkNames::hrefAttr, Href, href)
36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGlyphRefElement)
37 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement)
39 END_REGISTER_ANIMATED_PROPERTIES
41 inline SVGGlyphRefElement::SVGGlyphRefElement(const QualifiedName& tagName, Document* document)
42 : SVGStyledElement(tagName, document)
48 ASSERT(hasTagName(SVGNames::glyphRefTag));
49 registerAnimatedPropertiesForSVGGlyphRefElement();
52 PassRefPtr<SVGGlyphRefElement> SVGGlyphRefElement::create(const QualifiedName& tagName, Document* document)
54 return adoptRef(new SVGGlyphRefElement(tagName, document));
57 bool SVGGlyphRefElement::hasValidGlyphElement(String& glyphName) const
59 // FIXME: We only support xlink:href so far.
60 // https://bugs.webkit.org/show_bug.cgi?id=64787
61 Element* element = targetElementFromIRIString(fastGetAttribute(XLinkNames::hrefAttr), document(), &glyphName);
62 if (!element || !element->hasTagName(SVGNames::glyphTag))
67 void SVGGlyphRefElement::parseMappedAttribute(Attribute* attr)
69 const UChar* startPtr = attr->value().characters();
70 const UChar* endPtr = startPtr + attr->value().length();
72 // FIXME: We need some error handling here.
73 if (attr->name() == SVGNames::xAttr)
74 parseNumber(startPtr, endPtr, m_x);
75 else if (attr->name() == SVGNames::yAttr)
76 parseNumber(startPtr, endPtr, m_y);
77 else if (attr->name() == SVGNames::dxAttr)
78 parseNumber(startPtr, endPtr, m_dx);
79 else if (attr->name() == SVGNames::dyAttr)
80 parseNumber(startPtr, endPtr, m_dy);
82 if (SVGURIReference::parseMappedAttribute(attr))
84 SVGStyledElement::parseMappedAttribute(attr);
88 const AtomicString& SVGGlyphRefElement::glyphRef() const
90 return fastGetAttribute(SVGNames::glyphRefAttr);
93 void SVGGlyphRefElement::setGlyphRef(const AtomicString&, ExceptionCode&)
95 // FIXME: Set and honor attribute change.
96 // https://bugs.webkit.org/show_bug.cgi?id=64787
99 void SVGGlyphRefElement::setX(float x, ExceptionCode&)
101 // FIXME: Honor attribute change.
102 // https://bugs.webkit.org/show_bug.cgi?id=64787
106 void SVGGlyphRefElement::setY(float y , ExceptionCode&)
108 // FIXME: Honor attribute change.
109 // https://bugs.webkit.org/show_bug.cgi?id=64787
113 void SVGGlyphRefElement::setDx(float dx, ExceptionCode&)
115 // FIXME: Honor attribute change.
116 // https://bugs.webkit.org/show_bug.cgi?id=64787
120 void SVGGlyphRefElement::setDy(float dy, ExceptionCode&)
122 // FIXME: Honor attribute change.
123 // https://bugs.webkit.org/show_bug.cgi?id=64787