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 m_length = 0; | 53 int 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, m_length, m_glyph) / scalingFactor; | 56 m_width = scaledFont.width(run, 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); |
58 } | 61 } |
59 | 62 |
60 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length) | 63 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length) |
61 { | 64 { |
62 ASSERT(text->style()); | 65 ASSERT(text->style()); |
63 return constructTextRun(text, position, length, text->style()->direction()); | 66 return constructTextRun(text, position, length, text->style()->direction()); |
64 } | 67 } |
65 | 68 |
66 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) | 69 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) |
67 { | 70 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ASSERT(scalingFactor); | 119 ASSERT(scalingFactor); |
117 | 120 |
118 m_width = width / scalingFactor; | 121 m_width = width / scalingFactor; |
119 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; | 122 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; |
120 m_glyph = needsContext ? glyphNameGlyphId : 0; | 123 m_glyph = needsContext ? glyphNameGlyphId : 0; |
121 | 124 |
122 m_length = length; | 125 m_length = length; |
123 } | 126 } |
124 | 127 |
125 } | 128 } |
OLD | NEW |