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 14 matching lines...) Expand all Loading... |
25 #include "core/layout/svg/SVGTextMetricsBuilder.h" | 25 #include "core/layout/svg/SVGTextMetricsBuilder.h" |
26 #include "core/svg/SVGTextPositioningElement.h" | 26 #include "core/svg/SVGTextPositioningElement.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder() | 30 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder() |
31 : m_textLength(0) | 31 : m_textLength(0) |
32 { | 32 { |
33 } | 33 } |
34 | 34 |
35 void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForText(LayoutSVGInlin
eText* text) | |
36 { | |
37 ASSERT(text); | |
38 | |
39 LayoutSVGText* textRoot = LayoutSVGText::locateLayoutSVGTextAncestor(text); | |
40 if (!textRoot) | |
41 return; | |
42 | |
43 if (m_textPositions.isEmpty()) { | |
44 m_characterDataMap.clear(); | |
45 | |
46 m_textLength = 0; | |
47 UChar lastCharacter = ' '; | |
48 collectTextPositioningElements(*textRoot, lastCharacter); | |
49 | |
50 if (!m_textLength) | |
51 return; | |
52 | |
53 buildCharacterDataMap(*textRoot); | |
54 } | |
55 | |
56 SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, text, m_cha
racterDataMap); | |
57 } | |
58 | |
59 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(LayoutSV
GText& textRoot) | 35 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(LayoutSV
GText& textRoot) |
60 { | 36 { |
61 m_characterDataMap.clear(); | 37 m_characterDataMap.clear(); |
62 | 38 |
63 if (m_textPositions.isEmpty()) { | 39 if (m_textPositions.isEmpty()) { |
64 m_textLength = 0; | 40 m_textLength = 0; |
65 UChar lastCharacter = ' '; | 41 UChar lastCharacter = ' '; |
66 collectTextPositioningElements(textRoot, lastCharacter); | 42 collectTextPositioningElements(textRoot, lastCharacter); |
67 } | 43 } |
68 | 44 |
69 if (!m_textLength) | 45 if (!m_textLength) |
70 return false; | 46 return false; |
71 | 47 |
72 buildCharacterDataMap(textRoot); | 48 buildCharacterDataMap(textRoot); |
73 SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(&textRoot, nullptr, m
_characterDataMap); | 49 SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, m_character
DataMap); |
74 return true; | 50 return true; |
75 } | 51 } |
76 | 52 |
77 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextLayoutObject(LayoutSVG
InlineText* text) | 53 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextLayoutObject(LayoutSVG
Text& textRoot, LayoutSVGInlineText& text) |
78 { | 54 { |
79 ASSERT(text); | 55 SVGTextMetricsBuilder::measureTextLayoutObject(textRoot, text); |
80 SVGTextMetricsBuilder::measureTextLayoutObject(text); | |
81 } | 56 } |
82 | 57 |
83 static inline void processLayoutSVGInlineText(LayoutSVGInlineText* text, unsigne
d& atCharacter, UChar& lastCharacter) | 58 static inline void processLayoutSVGInlineText(LayoutSVGInlineText* text, unsigne
d& atCharacter, UChar& lastCharacter) |
84 { | 59 { |
85 if (text->style()->whiteSpace() == PRE) { | 60 if (text->style()->whiteSpace() == PRE) { |
86 atCharacter += text->textLength(); | 61 atCharacter += text->textLength(); |
87 return; | 62 return; |
88 } | 63 } |
89 | 64 |
90 unsigned textLength = text->textLength(); | 65 unsigned textLength = text->textLength(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 data.rotate = lastRotation; | 193 data.rotate = lastRotation; |
219 } | 194 } |
220 } | 195 } |
221 | 196 |
222 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) | 197 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) |
223 { | 198 { |
224 visitor->trace(element); | 199 visitor->trace(element); |
225 } | 200 } |
226 | 201 |
227 } // namespace blink | 202 } // namespace blink |
OLD | NEW |