OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // Ensure |m_subrunRanges| is updated for the current bidi run, or the | 69 // Ensure |m_subrunRanges| is updated for the current bidi run, or the |
70 // complete m_run if no bidi runs are present. Returns the current position | 70 // complete m_run if no bidi runs are present. Returns the current position |
71 // in the subrun which can be used to index into |m_subrunRanges|. | 71 // in the subrun which can be used to index into |m_subrunRanges|. |
72 unsigned updateSubrunRangesForCurrentPosition(); | 72 unsigned updateSubrunRangesForCurrentPosition(); |
73 | 73 |
74 // Current character position in m_text. | 74 // Current character position in m_text. |
75 unsigned m_currentPosition; | 75 unsigned m_currentPosition; |
76 | 76 |
77 LineLayoutSVGInlineText m_text; | 77 LineLayoutSVGInlineText m_text; |
| 78 float m_fontScalingFactor; |
| 79 float m_cachedFontHeight; |
78 TextRun m_run; | 80 TextRun m_run; |
79 | 81 |
80 BidiCharacterRun* m_bidiRun; | 82 BidiCharacterRun* m_bidiRun; |
81 BidiResolver<TextRunIterator, BidiCharacterRun> m_bidiResolver; | 83 BidiResolver<TextRunIterator, BidiCharacterRun> m_bidiResolver; |
82 | 84 |
83 // Ranges for the current bidi run if present, or the entire run otherwise. | 85 // Ranges for the current bidi run if present, or the entire run otherwise. |
84 Vector<CharacterRange> m_subrunRanges; | 86 Vector<CharacterRange> m_subrunRanges; |
85 }; | 87 }; |
86 | 88 |
87 TextRun SVGTextMetricsCalculator::constructTextRun(LineLayoutSVGInlineText textL
ayoutItem, unsigned position, unsigned length, TextDirection textDirection) | 89 TextRun SVGTextMetricsCalculator::constructTextRun(LineLayoutSVGInlineText textL
ayoutItem, unsigned position, unsigned length, TextDirection textDirection) |
(...skipping 20 matching lines...) Expand all Loading... |
108 | 110 |
109 // Propagate the maximum length of the characters buffer to the TextRun, eve
n when we're only processing a substring. | 111 // Propagate the maximum length of the characters buffer to the TextRun, eve
n when we're only processing a substring. |
110 run.setCharactersLength(textLayoutItem.textLength() - position); | 112 run.setCharactersLength(textLayoutItem.textLength() - position); |
111 ASSERT(run.charactersLength() >= run.length()); | 113 ASSERT(run.charactersLength() >= run.length()); |
112 return run; | 114 return run; |
113 } | 115 } |
114 | 116 |
115 SVGTextMetricsCalculator::SVGTextMetricsCalculator(LayoutSVGInlineText* text) | 117 SVGTextMetricsCalculator::SVGTextMetricsCalculator(LayoutSVGInlineText* text) |
116 : m_currentPosition(0) | 118 : m_currentPosition(0) |
117 , m_text(LineLayoutSVGInlineText(text)) | 119 , m_text(LineLayoutSVGInlineText(text)) |
| 120 , m_fontScalingFactor(m_text.scalingFactor()) |
| 121 , m_cachedFontHeight(m_text.scaledFont().getFontMetrics().floatHeight() / m_
fontScalingFactor) |
118 , m_run(constructTextRun(m_text, 0, m_text.textLength(), m_text.styleRef().d
irection())) | 122 , m_run(constructTextRun(m_text, 0, m_text.textLength(), m_text.styleRef().d
irection())) |
119 , m_bidiRun(nullptr) | 123 , m_bidiRun(nullptr) |
120 { | 124 { |
121 setupBidiRuns(); | 125 setupBidiRuns(); |
122 } | 126 } |
123 | 127 |
124 SVGTextMetricsCalculator::~SVGTextMetricsCalculator() | 128 SVGTextMetricsCalculator::~SVGTextMetricsCalculator() |
125 { | 129 { |
126 if (m_bidiRun) | 130 if (m_bidiRun) |
127 m_bidiResolver.runs().deleteRuns(); | 131 m_bidiResolver.runs().deleteRuns(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return 0; | 204 return 0; |
201 | 205 |
202 return positionInRun; | 206 return positionInRun; |
203 } | 207 } |
204 | 208 |
205 SVGTextMetrics SVGTextMetricsCalculator::currentCharacterMetrics() | 209 SVGTextMetrics SVGTextMetricsCalculator::currentCharacterMetrics() |
206 { | 210 { |
207 unsigned currentSubrunPosition = updateSubrunRangesForCurrentPosition(); | 211 unsigned currentSubrunPosition = updateSubrunRangesForCurrentPosition(); |
208 unsigned length = currentCharacterStartsSurrogatePair() ? 2 : 1; | 212 unsigned length = currentCharacterStartsSurrogatePair() ? 2 : 1; |
209 float width = m_subrunRanges[currentSubrunPosition].width(); | 213 float width = m_subrunRanges[currentSubrunPosition].width(); |
210 return SVGTextMetrics(m_text, length, width); | 214 return SVGTextMetrics(length, width / m_fontScalingFactor, m_cachedFontHeigh
t); |
211 } | 215 } |
212 | 216 |
213 struct TreeWalkTextState { | 217 struct TreeWalkTextState { |
214 TreeWalkTextState() | 218 TreeWalkTextState() |
215 : lastCharacterWasWhiteSpace(true) | 219 : lastCharacterWasWhiteSpace(true) |
216 , valueListPosition(0) { } | 220 , valueListPosition(0) { } |
217 | 221 |
218 bool lastCharacterWasWhiteSpace; | 222 bool lastCharacterWasWhiteSpace; |
219 unsigned valueListPosition; | 223 unsigned valueListPosition; |
220 }; | 224 }; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 walkTree(textRoot, text); | 329 walkTree(textRoot, text); |
326 } | 330 } |
327 | 331 |
328 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR
oot, LayoutSVGInlineText* stopAtText, SVGCharacterDataMap& allCharactersMap) | 332 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR
oot, LayoutSVGInlineText* stopAtText, SVGCharacterDataMap& allCharactersMap) |
329 { | 333 { |
330 ASSERT(textRoot); | 334 ASSERT(textRoot); |
331 walkTree(textRoot, stopAtText, &allCharactersMap); | 335 walkTree(textRoot, stopAtText, &allCharactersMap); |
332 } | 336 } |
333 | 337 |
334 } // namespace blink | 338 } // namespace blink |
OLD | NEW |