| 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 21 matching lines...) Expand all Loading... |
| 32 : SVGElement(SVGNames::altGlyphDefTag, document) | 32 : SVGElement(SVGNames::altGlyphDefTag, document) |
| 33 { | 33 { |
| 34 ScriptWrappable::init(this); | 34 ScriptWrappable::init(this); |
| 35 } | 35 } |
| 36 | 36 |
| 37 PassRefPtr<SVGAltGlyphDefElement> SVGAltGlyphDefElement::create(Document& docume
nt) | 37 PassRefPtr<SVGAltGlyphDefElement> SVGAltGlyphDefElement::create(Document& docume
nt) |
| 38 { | 38 { |
| 39 return adoptRef(new SVGAltGlyphDefElement(document)); | 39 return adoptRef(new SVGAltGlyphDefElement(document)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool SVGAltGlyphDefElement::hasValidGlyphElements(Vector<String>& glyphNames) co
nst | 42 bool SVGAltGlyphDefElement::hasValidGlyphElements(Vector<AtomicString>& glyphNam
es) const |
| 43 { | 43 { |
| 44 // Spec: http://www.w3.org/TR/SVG/text.html#AltGlyphDefElement | 44 // Spec: http://www.w3.org/TR/SVG/text.html#AltGlyphDefElement |
| 45 // An 'altGlyphDef' can contain either of the following: | 45 // An 'altGlyphDef' can contain either of the following: |
| 46 // | 46 // |
| 47 // 1. In the simplest case, an 'altGlyphDef' contains one or more 'glyphRef'
elements. | 47 // 1. In the simplest case, an 'altGlyphDef' contains one or more 'glyphRef'
elements. |
| 48 // Each 'glyphRef' element references a single glyph within a particular fon
t. | 48 // Each 'glyphRef' element references a single glyph within a particular fon
t. |
| 49 // If all of the referenced glyphs are available, then these glyphs are rend
ered | 49 // If all of the referenced glyphs are available, then these glyphs are rend
ered |
| 50 // instead of the character(s) inside of the referencing 'altGlyph' element. | 50 // instead of the character(s) inside of the referencing 'altGlyph' element. |
| 51 // If any of the referenced glyphs are unavailable, then the character(s) th
at are | 51 // If any of the referenced glyphs are unavailable, then the character(s) th
at are |
| 52 // inside of the 'altGlyph' element are rendered as if there were not an 'al
tGlyph' | 52 // inside of the 'altGlyph' element are rendered as if there were not an 'al
tGlyph' |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // For b), the content model is 2), so we will use <glyphRef> elements conta
ined in | 84 // 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. | 85 // "i1" if they are valid and "g1" and "g2" are skipped. |
| 86 | 86 |
| 87 // These 2 variables are used to determine content model. | 87 // These 2 variables are used to determine content model. |
| 88 bool fountFirstGlyphRef = false; | 88 bool fountFirstGlyphRef = false; |
| 89 bool foundFirstAltGlyphItem = false; | 89 bool foundFirstAltGlyphItem = false; |
| 90 | 90 |
| 91 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 91 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 92 if (!foundFirstAltGlyphItem && child->hasTagName(SVGNames::glyphRefTag))
{ | 92 if (!foundFirstAltGlyphItem && child->hasTagName(SVGNames::glyphRefTag))
{ |
| 93 fountFirstGlyphRef = true; | 93 fountFirstGlyphRef = true; |
| 94 String referredGlyphName; | 94 AtomicString referredGlyphName; |
| 95 | 95 |
| 96 if (toSVGGlyphRefElement(child)->hasValidGlyphElement(referredGlyphN
ame)) | 96 if (toSVGGlyphRefElement(child)->hasValidGlyphElement(referredGlyphN
ame)) |
| 97 glyphNames.append(referredGlyphName); | 97 glyphNames.append(referredGlyphName); |
| 98 else { | 98 else { |
| 99 // As the spec says "If any of the referenced glyphs are unavail
able, | 99 // 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 | 100 // 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 | 101 // rendered as if there were not an 'altGlyph' element surroundi
ng |
| 102 // those characters.". | 102 // those characters.". |
| 103 glyphNames.clear(); | 103 glyphNames.clear(); |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 } else if (!fountFirstGlyphRef && child->hasTagName(SVGNames::altGlyphIt
emTag)) { | 106 } else if (!fountFirstGlyphRef && child->hasTagName(SVGNames::altGlyphIt
emTag)) { |
| 107 foundFirstAltGlyphItem = true; | 107 foundFirstAltGlyphItem = true; |
| 108 Vector<String> referredGlyphNames; | 108 Vector<AtomicString> referredGlyphNames; |
| 109 | 109 |
| 110 // As the spec says "The first 'altGlyphItem' in which all reference
d glyphs | 110 // As the spec says "The first 'altGlyphItem' in which all reference
d glyphs |
| 111 // are available is chosen." | 111 // are available is chosen." |
| 112 if (static_cast<SVGAltGlyphItemElement*>(child)->hasValidGlyphElemen
ts(glyphNames) && !glyphNames.isEmpty()) | 112 if (static_cast<SVGAltGlyphItemElement*>(child)->hasValidGlyphElemen
ts(glyphNames) && !glyphNames.isEmpty()) |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return !glyphNames.isEmpty(); | 116 return !glyphNames.isEmpty(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } | 119 } |
| 120 | 120 |
| 121 #endif | 121 #endif |
| OLD | NEW |