| 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 12 matching lines...) Expand all Loading... |
| 23 #include "core/svg/SVGAltGlyphItemElement.h" | 23 #include "core/svg/SVGAltGlyphItemElement.h" |
| 24 | 24 |
| 25 #include "core/dom/ElementTraversal.h" | 25 #include "core/dom/ElementTraversal.h" |
| 26 #include "core/svg/SVGGlyphRefElement.h" | 26 #include "core/svg/SVGGlyphRefElement.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 inline SVGAltGlyphItemElement::SVGAltGlyphItemElement(Document& document) | 30 inline SVGAltGlyphItemElement::SVGAltGlyphItemElement(Document& document) |
| 31 : SVGElement(SVGNames::altGlyphItemTag, document) | 31 : SVGElement(SVGNames::altGlyphItemTag, document) |
| 32 { | 32 { |
| 33 ScriptWrappable::init(this); | |
| 34 } | 33 } |
| 35 | 34 |
| 36 DEFINE_NODE_FACTORY(SVGAltGlyphItemElement) | 35 DEFINE_NODE_FACTORY(SVGAltGlyphItemElement) |
| 37 | 36 |
| 38 bool SVGAltGlyphItemElement::hasValidGlyphElements(Vector<AtomicString>& glyphNa
mes) const | 37 bool SVGAltGlyphItemElement::hasValidGlyphElements(Vector<AtomicString>& glyphNa
mes) const |
| 39 { | 38 { |
| 40 // Spec: http://www.w3.org/TR/SVG/text.html#AltGlyphItemElement | 39 // Spec: http://www.w3.org/TR/SVG/text.html#AltGlyphItemElement |
| 41 // The ‘altGlyphItem’ element defines a candidate set of possible glyph subs
titutions. | 40 // The ‘altGlyphItem’ element defines a candidate set of possible glyph subs
titutions. |
| 42 // The first ‘altGlyphItem’ element whose referenced glyphs are all availabl
e is chosen. | 41 // The first ‘altGlyphItem’ element whose referenced glyphs are all availabl
e is chosen. |
| 43 // Its glyphs are rendered instead of the character(s) that are inside of th
e referencing | 42 // Its glyphs are rendered instead of the character(s) that are inside of th
e referencing |
| 44 // ‘altGlyph’ element. | 43 // ‘altGlyph’ element. |
| 45 // | 44 // |
| 46 // Here we fill glyphNames and return true only if all referenced glyphs are
valid and | 45 // Here we fill glyphNames and return true only if all referenced glyphs are
valid and |
| 47 // there is at least one glyph. | 46 // there is at least one glyph. |
| 48 for (SVGGlyphRefElement* glyph = Traversal<SVGGlyphRefElement>::firstChild(*
this); glyph; glyph = Traversal<SVGGlyphRefElement>::nextSibling(*glyph)) { | 47 for (SVGGlyphRefElement* glyph = Traversal<SVGGlyphRefElement>::firstChild(*
this); glyph; glyph = Traversal<SVGGlyphRefElement>::nextSibling(*glyph)) { |
| 49 AtomicString referredGlyphName; | 48 AtomicString referredGlyphName; |
| 50 if (glyph->hasValidGlyphElement(referredGlyphName)) { | 49 if (glyph->hasValidGlyphElement(referredGlyphName)) { |
| 51 glyphNames.append(referredGlyphName); | 50 glyphNames.append(referredGlyphName); |
| 52 } else { | 51 } else { |
| 53 glyphNames.clear(); | 52 glyphNames.clear(); |
| 54 return false; | 53 return false; |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 return !glyphNames.isEmpty(); | 56 return !glyphNames.isEmpty(); |
| 58 } | 57 } |
| 59 | 58 |
| 60 } | 59 } |
| 61 | 60 |
| 62 #endif | 61 #endif |
| OLD | NEW |