| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 const Font& scaledFont = textRenderer->scaledFont(); | 49 const Font& scaledFont = textRenderer->scaledFont(); |
| 50 | 50 |
| 51 // Calculate width/height using the scaled font, divide this result by the s
calingFactor afterwards. | 51 // Calculate width/height using the scaled font, divide this result by the s
calingFactor afterwards. |
| 52 m_width = scaledFont.width(run) / scalingFactor; | 52 m_width = scaledFont.width(run) / scalingFactor; |
| 53 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; | 53 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; |
| 54 | 54 |
| 55 ASSERT(run.length() >= 0); | 55 ASSERT(run.length() >= 0); |
| 56 m_length = static_cast<unsigned>(run.length()); | 56 m_length = static_cast<unsigned>(run.length()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 TextRun SVGTextMetrics::constructTextRun(LayoutSVGInlineText* text, unsigned pos
ition, unsigned length) | |
| 60 { | |
| 61 ASSERT(text->style()); | |
| 62 return constructTextRun(text, position, length, text->style()->direction()); | |
| 63 } | |
| 64 | |
| 65 TextRun SVGTextMetrics::constructTextRun(LayoutSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) | 59 TextRun SVGTextMetrics::constructTextRun(LayoutSVGInlineText* text, unsigned pos
ition, unsigned length, TextDirection textDirection) |
| 66 { | 60 { |
| 67 const LayoutStyle& style = text->styleRef(); | 61 const LayoutStyle& style = text->styleRef(); |
| 68 | 62 |
| 69 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. | 63 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. |
| 70 , 0 // length, will be set below if non-zero. | 64 , 0 // length, will be set below if non-zero. |
| 71 , 0 // xPos, only relevant with allowTabs=true | 65 , 0 // xPos, only relevant with allowTabs=true |
| 72 , 0 // padding, only relevant for justified text, not relevant for SVG | 66 , 0 // padding, only relevant for justified text, not relevant for SVG |
| 73 , TextRun::AllowTrailingExpansion | 67 , TextRun::AllowTrailingExpansion |
| 74 , textDirection | 68 , textDirection |
| (...skipping 14 matching lines...) Expand all Loading... |
| 89 ASSERT(run.charactersLength() >= run.length()); | 83 ASSERT(run.charactersLength() >= run.length()); |
| 90 return run; | 84 return run; |
| 91 } | 85 } |
| 92 | 86 |
| 93 SVGTextMetrics SVGTextMetrics::measureCharacterRange(LayoutSVGInlineText* text,
unsigned position, unsigned length, TextDirection textDirection) | 87 SVGTextMetrics SVGTextMetrics::measureCharacterRange(LayoutSVGInlineText* text,
unsigned position, unsigned length, TextDirection textDirection) |
| 94 { | 88 { |
| 95 ASSERT(text); | 89 ASSERT(text); |
| 96 return SVGTextMetrics(text, constructTextRun(text, position, length, textDir
ection)); | 90 return SVGTextMetrics(text, constructTextRun(text, position, length, textDir
ection)); |
| 97 } | 91 } |
| 98 | 92 |
| 99 SVGTextMetrics SVGTextMetrics::measureCharacterRange(LayoutSVGInlineText* text,
unsigned position, unsigned length) | |
| 100 { | |
| 101 ASSERT(text); | |
| 102 return SVGTextMetrics(text, constructTextRun(text, position, length)); | |
| 103 } | |
| 104 | |
| 105 SVGTextMetrics::SVGTextMetrics(LayoutSVGInlineText* text, unsigned position, uns
igned length, float width) | 93 SVGTextMetrics::SVGTextMetrics(LayoutSVGInlineText* text, unsigned position, uns
igned length, float width) |
| 106 { | 94 { |
| 107 ASSERT(text); | 95 ASSERT(text); |
| 108 | 96 |
| 109 float scalingFactor = text->scalingFactor(); | 97 float scalingFactor = text->scalingFactor(); |
| 110 ASSERT(scalingFactor); | 98 ASSERT(scalingFactor); |
| 111 | 99 |
| 112 m_width = width / scalingFactor; | 100 m_width = width / scalingFactor; |
| 113 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; | 101 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; |
| 114 | 102 |
| 115 m_length = length; | 103 m_length = length; |
| 116 } | 104 } |
| 117 | 105 |
| 118 } | 106 } |
| OLD | NEW |