| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Leo Yang <leoyang@webkit.org> | |
| 3 * | |
| 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. | |
| 8 * | |
| 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. | |
| 13 * | |
| 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. | |
| 18 */ | |
| 19 | |
| 20 #include "config.h" | |
| 21 | |
| 22 #if ENABLE(SVG_FONTS) | |
| 23 #include "core/svg/SVGGlyphRefElement.h" | |
| 24 | |
| 25 #include "core/XLinkNames.h" | |
| 26 #include "core/svg/SVGParserUtilities.h" | |
| 27 #include "wtf/text/AtomicString.h" | |
| 28 | |
| 29 namespace blink { | |
| 30 | |
| 31 inline SVGGlyphRefElement::SVGGlyphRefElement(Document& document) | |
| 32 : SVGElement(SVGNames::glyphRefTag, document) | |
| 33 , SVGURIReference(this) | |
| 34 , m_x(0) | |
| 35 , m_y(0) | |
| 36 , m_dx(0) | |
| 37 , m_dy(0) | |
| 38 { | |
| 39 } | |
| 40 | |
| 41 DEFINE_NODE_FACTORY(SVGGlyphRefElement) | |
| 42 | |
| 43 bool SVGGlyphRefElement::hasValidGlyphElement(AtomicString& glyphName) const | |
| 44 { | |
| 45 // FIXME: We only support xlink:href so far. | |
| 46 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 47 Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefA
ttr), document(), &glyphName); | |
| 48 return isSVGGlyphElement(element); | |
| 49 } | |
| 50 | |
| 51 template<typename CharType> | |
| 52 void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const
AtomicString& value) | |
| 53 { | |
| 54 const CharType* ptr = value.isEmpty() ? 0 : value.string().getCharacters<Cha
rType>(); | |
| 55 const CharType* end = ptr + value.length(); | |
| 56 | |
| 57 // FIXME: We need some error handling here. | |
| 58 if (name == SVGNames::xAttr) { | |
| 59 parseNumber(ptr, end, m_x); | |
| 60 } else if (name == SVGNames::yAttr) { | |
| 61 parseNumber(ptr, end, m_y); | |
| 62 } else if (name == SVGNames::dxAttr) { | |
| 63 parseNumber(ptr, end, m_dx); | |
| 64 } else if (name == SVGNames::dyAttr) { | |
| 65 parseNumber(ptr, end, m_dy); | |
| 66 } else { | |
| 67 parseAttributeNew(name, value); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicS
tring& value) | |
| 72 { | |
| 73 if (value.isEmpty() || value.is8Bit()) | |
| 74 parseAttributeInternal<LChar>(name, value); | |
| 75 else | |
| 76 parseAttributeInternal<UChar>(name, value); | |
| 77 } | |
| 78 | |
| 79 const AtomicString& SVGGlyphRefElement::glyphRef() const | |
| 80 { | |
| 81 return fastGetAttribute(SVGNames::glyphRefAttr); | |
| 82 } | |
| 83 | |
| 84 void SVGGlyphRefElement::setGlyphRef(const AtomicString&) | |
| 85 { | |
| 86 // FIXME: Set and honor attribute change. | |
| 87 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 88 } | |
| 89 | |
| 90 void SVGGlyphRefElement::setX(float x) | |
| 91 { | |
| 92 // FIXME: Honor attribute change. | |
| 93 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 94 m_x = x; | |
| 95 } | |
| 96 | |
| 97 void SVGGlyphRefElement::setY(float y) | |
| 98 { | |
| 99 // FIXME: Honor attribute change. | |
| 100 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 101 m_y = y; | |
| 102 } | |
| 103 | |
| 104 void SVGGlyphRefElement::setDx(float dx) | |
| 105 { | |
| 106 // FIXME: Honor attribute change. | |
| 107 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 108 m_dx = dx; | |
| 109 } | |
| 110 | |
| 111 void SVGGlyphRefElement::setDy(float dy) | |
| 112 { | |
| 113 // FIXME: Honor attribute change. | |
| 114 // https://bugs.webkit.org/show_bug.cgi?id=64787 | |
| 115 m_dy = dy; | |
| 116 } | |
| 117 | |
| 118 } | |
| 119 | |
| 120 #endif | |
| OLD | NEW |