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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 | 21 |
22 #if ENABLE(SVG_FONTS) | 22 #if ENABLE(SVG_FONTS) |
23 #include "core/svg/SVGAltGlyphDefElement.h" | 23 #include "core/svg/SVGAltGlyphDefElement.h" |
24 | 24 |
25 #include "SVGNames.h" | 25 #include "SVGNames.h" |
| 26 #include "core/dom/ElementTraversal.h" |
26 #include "core/svg/SVGAltGlyphItemElement.h" | 27 #include "core/svg/SVGAltGlyphItemElement.h" |
27 #include "core/svg/SVGGlyphRefElement.h" | 28 #include "core/svg/SVGGlyphRefElement.h" |
28 | 29 |
29 namespace WebCore { | 30 namespace WebCore { |
30 | 31 |
31 inline SVGAltGlyphDefElement::SVGAltGlyphDefElement(Document& document) | 32 inline SVGAltGlyphDefElement::SVGAltGlyphDefElement(Document& document) |
32 : SVGElement(SVGNames::altGlyphDefTag, document) | 33 : SVGElement(SVGNames::altGlyphDefTag, document) |
33 { | 34 { |
34 ScriptWrappable::init(this); | 35 ScriptWrappable::init(this); |
35 } | 36 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // </altGlyphDef> | 82 // </altGlyphDef> |
82 // For a), the content model is 1), so we will use "g1" and "g2" if they are
all valid | 83 // For a), the content model is 1), so we will use "g1" and "g2" if they are
all valid |
83 // and "i1" is skipped. | 84 // and "i1" is skipped. |
84 // For b), the content model is 2), so we will use <glyphRef> elements conta
ined in | 85 // For b), the content model is 2), so we will use <glyphRef> elements conta
ined in |
85 // "i1" if they are valid and "g1" and "g2" are skipped. | 86 // "i1" if they are valid and "g1" and "g2" are skipped. |
86 | 87 |
87 // These 2 variables are used to determine content model. | 88 // These 2 variables are used to determine content model. |
88 bool fountFirstGlyphRef = false; | 89 bool fountFirstGlyphRef = false; |
89 bool foundFirstAltGlyphItem = false; | 90 bool foundFirstAltGlyphItem = false; |
90 | 91 |
91 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 92 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch
ild = Traversal<SVGElement>::nextSibling(*child)) { |
92 if (!foundFirstAltGlyphItem && child->hasTagName(SVGNames::glyphRefTag))
{ | 93 if (!foundFirstAltGlyphItem && isSVGGlyphRefElement(*child)) { |
93 fountFirstGlyphRef = true; | 94 fountFirstGlyphRef = true; |
94 AtomicString referredGlyphName; | 95 AtomicString referredGlyphName; |
95 | 96 |
96 if (toSVGGlyphRefElement(child)->hasValidGlyphElement(referredGlyphN
ame)) | 97 if (toSVGGlyphRefElement(child)->hasValidGlyphElement(referredGlyphN
ame)) |
97 glyphNames.append(referredGlyphName); | 98 glyphNames.append(referredGlyphName); |
98 else { | 99 else { |
99 // As the spec says "If any of the referenced glyphs are unavail
able, | 100 // As the spec says "If any of the referenced glyphs are unavail
able, |
100 // then the character(s) that are inside of the 'altGlyph' eleme
nt are | 101 // then the character(s) that are inside of the 'altGlyph' eleme
nt are |
101 // rendered as if there were not an 'altGlyph' element surroundi
ng | 102 // rendered as if there were not an 'altGlyph' element surroundi
ng |
102 // those characters.". | 103 // those characters.". |
103 glyphNames.clear(); | 104 glyphNames.clear(); |
104 return false; | 105 return false; |
105 } | 106 } |
106 } else if (!fountFirstGlyphRef && child->hasTagName(SVGNames::altGlyphIt
emTag)) { | 107 } else if (!fountFirstGlyphRef && isSVGAltGlyphItemElement(*child)) { |
107 foundFirstAltGlyphItem = true; | 108 foundFirstAltGlyphItem = true; |
108 Vector<AtomicString> referredGlyphNames; | 109 Vector<AtomicString> referredGlyphNames; |
109 | 110 |
110 // As the spec says "The first 'altGlyphItem' in which all reference
d glyphs | 111 // As the spec says "The first 'altGlyphItem' in which all reference
d glyphs |
111 // are available is chosen." | 112 // are available is chosen." |
112 if (toSVGAltGlyphItemElement(child)->hasValidGlyphElements(glyphName
s) && !glyphNames.isEmpty()) | 113 if (toSVGAltGlyphItemElement(child)->hasValidGlyphElements(glyphName
s) && !glyphNames.isEmpty()) |
113 return true; | 114 return true; |
114 } | 115 } |
115 } | 116 } |
116 return !glyphNames.isEmpty(); | 117 return !glyphNames.isEmpty(); |
117 } | 118 } |
118 | 119 |
119 } | 120 } |
120 | 121 |
121 #endif | 122 #endif |
OLD | NEW |