OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 attributes.characterDataMap().set(currentPosition + 1, it->value); | 45 attributes.characterDataMap().set(currentPosition + 1, it->value); |
46 | 46 |
47 // Increase the position in the value/attribute list with one for each | 47 // Increase the position in the value/attribute list with one for each |
48 // "character unit" (that will be displayed.) | 48 // "character unit" (that will be displayed.) |
49 valueListPosition++; | 49 valueListPosition++; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder() | 55 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder(LayoutSVGText& te
xtRoot) |
56 : m_characterCount(0) | 56 : m_textRoot(textRoot) |
| 57 , m_characterCount(0) |
57 { | 58 { |
58 } | 59 } |
59 | 60 |
60 void SVGTextLayoutAttributesBuilder::buildLayoutAttributes(LayoutSVGText& textRo
ot) const | 61 void SVGTextLayoutAttributesBuilder::buildLayoutAttributes() |
61 { | 62 { |
| 63 m_characterDataMap.clear(); |
| 64 |
| 65 if (m_textPositions.isEmpty()) { |
| 66 m_characterCount = 0; |
| 67 collectTextPositioningElements(m_textRoot); |
| 68 } |
| 69 |
| 70 if (!m_characterCount) |
| 71 return; |
| 72 |
| 73 buildCharacterDataMap(m_textRoot); |
| 74 |
62 unsigned valueListPosition = 0; | 75 unsigned valueListPosition = 0; |
63 LayoutObject* child = textRoot.firstChild(); | 76 LayoutObject* child = m_textRoot.firstChild(); |
64 while (child) { | 77 while (child) { |
65 if (child->isSVGInlineText()) { | 78 if (child->isSVGInlineText()) { |
66 updateLayoutAttributes(toLayoutSVGInlineText(*child), valueListPosit
ion, m_characterDataMap); | 79 updateLayoutAttributes(toLayoutSVGInlineText(*child), valueListPosit
ion, m_characterDataMap); |
67 } else if (child->isSVGInline()) { | 80 } else if (child->isSVGInline()) { |
68 // Visit children of text content elements. | 81 // Visit children of text content elements. |
69 if (LayoutObject* inlineChild = toLayoutSVGInline(child)->firstChild
()) { | 82 if (LayoutObject* inlineChild = toLayoutSVGInline(child)->firstChild
()) { |
70 child = inlineChild; | 83 child = inlineChild; |
71 continue; | 84 continue; |
72 } | 85 } |
73 } | 86 } |
74 child = child->nextInPreOrderAfterChildren(&textRoot); | 87 child = child->nextInPreOrderAfterChildren(&m_textRoot); |
75 } | 88 } |
76 } | 89 } |
77 | 90 |
78 void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRoot(LayoutSVGT
ext& textRoot) | |
79 { | |
80 m_characterDataMap.clear(); | |
81 | |
82 if (m_textPositions.isEmpty()) { | |
83 m_characterCount = 0; | |
84 collectTextPositioningElements(textRoot); | |
85 } | |
86 | |
87 if (!m_characterCount) | |
88 return; | |
89 | |
90 buildCharacterDataMap(textRoot); | |
91 buildLayoutAttributes(textRoot); | |
92 } | |
93 | |
94 static inline unsigned countCharactersInTextNode(const LayoutSVGInlineText& text
) | 91 static inline unsigned countCharactersInTextNode(const LayoutSVGInlineText& text
) |
95 { | 92 { |
96 unsigned numCharacters = 0; | 93 unsigned numCharacters = 0; |
97 for (const SVGTextMetrics& metrics : text.metricsList()) { | 94 for (const SVGTextMetrics& metrics : text.metricsList()) { |
98 if (metrics.isEmpty()) | 95 if (metrics.isEmpty()) |
99 continue; | 96 continue; |
100 numCharacters++; | 97 numCharacters++; |
101 } | 98 } |
102 return numCharacters; | 99 return numCharacters; |
103 } | 100 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 attrLists.updateCharacterData(i, data); | 243 attrLists.updateCharacterData(i, data); |
247 } | 244 } |
248 } | 245 } |
249 | 246 |
250 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) | 247 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) |
251 { | 248 { |
252 visitor->trace(element); | 249 visitor->trace(element); |
253 } | 250 } |
254 | 251 |
255 } // namespace blink | 252 } // namespace blink |
OLD | NEW |