OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Leo Yang <leoyang@webkit.org> | 2 * Copyright (C) 2011 Leo Yang <leoyang@webkit.org> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #if ENABLE(SVG_FONTS) | 22 #if ENABLE(SVG_FONTS) |
23 #include "core/svg/SVGGlyphRefElement.h" | 23 #include "core/svg/SVGGlyphRefElement.h" |
24 | 24 |
25 #include "XLinkNames.h" | 25 #include "XLinkNames.h" |
26 #include "core/svg/SVGParserUtilities.h" | 26 #include "core/svg/SVGParserUtilities.h" |
27 #include "wtf/text/AtomicString.h" | 27 #include "wtf/text/AtomicString.h" |
28 | 28 |
29 namespace WebCore { | 29 namespace WebCore { |
30 | 30 |
31 // Animated property definitions | 31 // Animated property definitions |
32 DEFINE_ANIMATED_STRING(SVGGlyphRefElement, XLinkNames::hrefAttr, Href, href) | |
33 | 32 |
34 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGlyphRefElement) | 33 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGlyphRefElement) |
35 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | |
36 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 34 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
37 END_REGISTER_ANIMATED_PROPERTIES | 35 END_REGISTER_ANIMATED_PROPERTIES |
38 | 36 |
39 inline SVGGlyphRefElement::SVGGlyphRefElement(Document& document) | 37 inline SVGGlyphRefElement::SVGGlyphRefElement(Document& document) |
40 : SVGElement(SVGNames::glyphRefTag, document) | 38 : SVGElement(SVGNames::glyphRefTag, document) |
39 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate())) | |
41 , m_x(0) | 40 , m_x(0) |
42 , m_y(0) | 41 , m_y(0) |
43 , m_dx(0) | 42 , m_dx(0) |
44 , m_dy(0) | 43 , m_dy(0) |
45 { | 44 { |
46 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
46 addToPropertyMap(m_href); | |
47 registerAnimatedPropertiesForSVGGlyphRefElement(); | 47 registerAnimatedPropertiesForSVGGlyphRefElement(); |
48 } | 48 } |
49 | 49 |
50 PassRefPtr<SVGGlyphRefElement> SVGGlyphRefElement::create(Document& document) | 50 PassRefPtr<SVGGlyphRefElement> SVGGlyphRefElement::create(Document& document) |
51 { | 51 { |
52 return adoptRef(new SVGGlyphRefElement(document)); | 52 return adoptRef(new SVGGlyphRefElement(document)); |
53 } | 53 } |
54 | 54 |
55 bool SVGGlyphRefElement::hasValidGlyphElement(AtomicString& glyphName) const | 55 bool SVGGlyphRefElement::hasValidGlyphElement(AtomicString& glyphName) const |
56 { | 56 { |
57 // FIXME: We only support xlink:href so far. | 57 // FIXME: We only support xlink:href so far. |
58 // https://bugs.webkit.org/show_bug.cgi?id=64787 | 58 // https://bugs.webkit.org/show_bug.cgi?id=64787 |
59 Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefA ttr), document(), &glyphName); | 59 Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefA ttr), document(), &glyphName); |
60 if (!element || !element->hasTagName(SVGNames::glyphTag)) | 60 if (!element || !element->hasTagName(SVGNames::glyphTag)) |
61 return false; | 61 return false; |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 template<typename CharType> | 65 template<typename CharType> |
66 void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const AtomicString& value) | 66 void SVGGlyphRefElement::parseAttributeInternal(const QualifiedName& name, const AtomicString& value) |
67 { | 67 { |
68 const CharType* ptr = value.isEmpty() ? 0 : value.string().getCharacters<Cha rType>(); | 68 const CharType* ptr = value.isEmpty() ? 0 : value.string().getCharacters<Cha rType>(); |
69 const CharType* end = ptr + value.length(); | 69 const CharType* end = ptr + value.length(); |
70 | 70 |
71 // FIXME: We need some error handling here. | 71 // FIXME: We need some error handling here. |
haraken
2014/01/29 05:18:00
What does this FIXME imply? I wonder why this code
kouhei (in TOK)
2014/01/30 08:18:56
I will do that when I land SVGNumber{,List} migrat
| |
72 if (name == SVGNames::xAttr) { | 72 if (name == SVGNames::xAttr) { |
73 parseNumber(ptr, end, m_x); | 73 parseNumber(ptr, end, m_x); |
74 } else if (name == SVGNames::yAttr) { | 74 } else if (name == SVGNames::yAttr) { |
75 parseNumber(ptr, end, m_y); | 75 parseNumber(ptr, end, m_y); |
76 } else if (name == SVGNames::dxAttr) { | 76 } else if (name == SVGNames::dxAttr) { |
77 parseNumber(ptr, end, m_dx); | 77 parseNumber(ptr, end, m_dx); |
78 } else if (name == SVGNames::dyAttr) { | 78 } else if (name == SVGNames::dyAttr) { |
79 parseNumber(ptr, end, m_dy); | 79 parseNumber(ptr, end, m_dy); |
80 } else if (name.matches(XLinkNames::hrefAttr)) { | |
81 SVGParsingError parseError = NoError; | |
82 m_href->setBaseValueAsString(value, parseError); | |
83 reportAttributeParsingError(parseError, name, value); | |
80 } else { | 84 } else { |
81 if (SVGURIReference::parseAttribute(name, value)) | |
82 return; | |
83 SVGElement::parseAttribute(name, value); | 85 SVGElement::parseAttribute(name, value); |
84 } | 86 } |
85 } | 87 } |
86 | 88 |
87 void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value) | 89 void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value) |
88 { | 90 { |
89 if (value.isEmpty() || value.is8Bit()) | 91 if (value.isEmpty() || value.is8Bit()) |
90 parseAttributeInternal<LChar>(name, value); | 92 parseAttributeInternal<LChar>(name, value); |
91 else | 93 else |
92 parseAttributeInternal<UChar>(name, value); | 94 parseAttributeInternal<UChar>(name, value); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 void SVGGlyphRefElement::setDy(float dy) | 129 void SVGGlyphRefElement::setDy(float dy) |
128 { | 130 { |
129 // FIXME: Honor attribute change. | 131 // FIXME: Honor attribute change. |
130 // https://bugs.webkit.org/show_bug.cgi?id=64787 | 132 // https://bugs.webkit.org/show_bug.cgi?id=64787 |
131 m_dy = dy; | 133 m_dy = dy; |
132 } | 134 } |
133 | 135 |
134 } | 136 } |
135 | 137 |
136 #endif | 138 #endif |
OLD | NEW |