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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun&
run) | 45 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun&
run) |
46 { | 46 { |
47 ASSERT(textRenderer); | 47 ASSERT(textRenderer); |
48 | 48 |
49 float scalingFactor = textRenderer->scalingFactor(); | 49 float scalingFactor = textRenderer->scalingFactor(); |
50 ASSERT(scalingFactor); | 50 ASSERT(scalingFactor); |
51 | 51 |
52 const Font& scaledFont = textRenderer->scaledFont(); | 52 const Font& scaledFont = textRenderer->scaledFont(); |
53 int length = 0; | 53 m_length = 0; |
54 | 54 |
55 // Calculate width/height using the scaled font, divide this result by the s
calingFactor afterwards. | 55 // Calculate width/height using the scaled font, divide this result by the s
calingFactor afterwards. |
56 m_width = scaledFont.width(run, length, m_glyph) / scalingFactor; | 56 m_width = scaledFont.width(run, m_length, m_glyph) / scalingFactor; |
57 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; | 57 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; |
58 | |
59 ASSERT(length >= 0); | |
60 m_length = static_cast<unsigned>(length); | |
61 } | 58 } |
62 | 59 |
63 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length) | 60 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length) |
64 { | 61 { |
65 ASSERT(text->style()); | 62 ASSERT(text->style()); |
66 return constructTextRun(text, position, length, text->style()->direction()); | 63 return constructTextRun(text, position, length, text->style()->direction()); |
67 } | 64 } |
68 | 65 |
69 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) | 66 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) |
70 { | 67 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ASSERT(scalingFactor); | 116 ASSERT(scalingFactor); |
120 | 117 |
121 m_width = width / scalingFactor; | 118 m_width = width / scalingFactor; |
122 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; | 119 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; |
123 m_glyph = needsContext ? glyphNameGlyphId : 0; | 120 m_glyph = needsContext ? glyphNameGlyphId : 0; |
124 | 121 |
125 m_length = length; | 122 m_length = length; |
126 } | 123 } |
127 | 124 |
128 } | 125 } |
OLD | NEW |