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 |
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 #include "core/rendering/svg/SVGTextLayoutAttributesBuilder.h" | 22 #include "core/rendering/svg/SVGTextLayoutAttributesBuilder.h" |
23 | 23 |
24 #include "core/rendering/svg/RenderSVGInlineText.h" | 24 #include "core/rendering/svg/RenderSVGInlineText.h" |
25 #include "core/rendering/svg/RenderSVGText.h" | 25 #include "core/rendering/svg/RenderSVGText.h" |
| 26 #include "core/rendering/svg/SVGTextMetricsBuilder.h" |
26 #include "core/svg/SVGTextPositioningElement.h" | 27 #include "core/svg/SVGTextPositioningElement.h" |
27 | 28 |
28 namespace WebCore { | 29 namespace WebCore { |
29 | 30 |
30 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder() | 31 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder() |
31 : m_textLength(0) | 32 : m_textLength(0) |
32 { | 33 { |
33 } | 34 } |
34 | 35 |
35 void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render
SVGInlineText* text) | 36 void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render
SVGInlineText* text) |
(...skipping 10 matching lines...) Expand all Loading... |
46 m_textLength = 0; | 47 m_textLength = 0; |
47 UChar lastCharacter = ' '; | 48 UChar lastCharacter = ' '; |
48 collectTextPositioningElements(textRoot, lastCharacter); | 49 collectTextPositioningElements(textRoot, lastCharacter); |
49 | 50 |
50 if (!m_textLength) | 51 if (!m_textLength) |
51 return; | 52 return; |
52 | 53 |
53 buildCharacterDataMap(textRoot); | 54 buildCharacterDataMap(textRoot); |
54 } | 55 } |
55 | 56 |
56 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, text, m_character
DataMap); | 57 SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, text, m_cha
racterDataMap); |
57 } | 58 } |
58 | 59 |
59 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV
GText* textRoot) | 60 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV
GText* textRoot) |
60 { | 61 { |
61 ASSERT(textRoot); | 62 ASSERT(textRoot); |
62 | 63 |
63 m_characterDataMap.clear(); | 64 m_characterDataMap.clear(); |
64 | 65 |
65 if (m_textPositions.isEmpty()) { | 66 if (m_textPositions.isEmpty()) { |
66 m_textLength = 0; | 67 m_textLength = 0; |
67 UChar lastCharacter = ' '; | 68 UChar lastCharacter = ' '; |
68 collectTextPositioningElements(textRoot, lastCharacter); | 69 collectTextPositioningElements(textRoot, lastCharacter); |
69 } | 70 } |
70 | 71 |
71 if (!m_textLength) | 72 if (!m_textLength) |
72 return false; | 73 return false; |
73 | 74 |
74 buildCharacterDataMap(textRoot); | 75 buildCharacterDataMap(textRoot); |
75 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDat
aMap); | 76 SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, 0, m_charac
terDataMap); |
76 return true; | 77 return true; |
77 } | 78 } |
78 | 79 |
79 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInli
neText* text) | 80 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInli
neText* text) |
80 { | 81 { |
81 ASSERT(text); | 82 ASSERT(text); |
82 m_metricsBuilder.measureTextRenderer(text); | 83 SVGTextMetricsBuilder::measureTextRenderer(text); |
83 } | 84 } |
84 | 85 |
85 static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne
d& atCharacter, UChar& lastCharacter) | 86 static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne
d& atCharacter, UChar& lastCharacter) |
86 { | 87 { |
87 if (text->style()->whiteSpace() == PRE) { | 88 if (text->style()->whiteSpace() == PRE) { |
88 atCharacter += text->textLength(); | 89 atCharacter += text->textLength(); |
89 return; | 90 return; |
90 } | 91 } |
91 | 92 |
92 unsigned textLength = text->textLength(); | 93 unsigned textLength = text->textLength(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 data.rotate = lastRotation; | 226 data.rotate = lastRotation; |
226 m_characterDataMap.set(position.start + i + 1, data); | 227 m_characterDataMap.set(position.start + i + 1, data); |
227 continue; | 228 continue; |
228 } | 229 } |
229 | 230 |
230 it->value.rotate = lastRotation; | 231 it->value.rotate = lastRotation; |
231 } | 232 } |
232 } | 233 } |
233 | 234 |
234 } | 235 } |
OLD | NEW |