| 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 ASSERT(textLayoutItem); | 44 ASSERT(textLayoutItem); |
| 45 | 45 |
| 46 float scalingFactor = textLayoutItem.scalingFactor(); | 46 float scalingFactor = textLayoutItem.scalingFactor(); |
| 47 ASSERT(scalingFactor); | 47 ASSERT(scalingFactor); |
| 48 | 48 |
| 49 const Font& scaledFont = textLayoutItem.scaledFont(); | 49 const Font& scaledFont = textLayoutItem.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.getFontMetrics().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(LineLayoutSVGInlineText textLayoutItem,
unsigned position, unsigned length, TextDirection textDirection) | 59 TextRun SVGTextMetrics::constructTextRun(LineLayoutSVGInlineText textLayoutItem,
unsigned position, unsigned length, TextDirection textDirection) |
| 60 { | 60 { |
| 61 const ComputedStyle& style = textLayoutItem.styleRef(); | 61 const ComputedStyle& style = textLayoutItem.styleRef(); |
| 62 | 62 |
| 63 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be
low if non-zero. | 63 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be
low if non-zero. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 SVGTextMetrics::SVGTextMetrics(LineLayoutSVGInlineText textLayoutItem, unsigned
length, float width) | 93 SVGTextMetrics::SVGTextMetrics(LineLayoutSVGInlineText textLayoutItem, unsigned
length, float width) |
| 94 { | 94 { |
| 95 ASSERT(textLayoutItem); | 95 ASSERT(textLayoutItem); |
| 96 | 96 |
| 97 float scalingFactor = textLayoutItem.scalingFactor(); | 97 float scalingFactor = textLayoutItem.scalingFactor(); |
| 98 ASSERT(scalingFactor); | 98 ASSERT(scalingFactor); |
| 99 | 99 |
| 100 m_width = width / scalingFactor; | 100 m_width = width / scalingFactor; |
| 101 m_height = textLayoutItem.scaledFont().fontMetrics().floatHeight() / scaling
Factor; | 101 m_height = textLayoutItem.scaledFont().getFontMetrics().floatHeight() / scal
ingFactor; |
| 102 | 102 |
| 103 m_length = length; | 103 m_length = length; |
| 104 } | 104 } |
| 105 | 105 |
| 106 float SVGTextMetrics::advance(FontOrientation orientation) const | 106 float SVGTextMetrics::advance(FontOrientation orientation) const |
| 107 { | 107 { |
| 108 switch (orientation) { | 108 switch (orientation) { |
| 109 case FontOrientation::Horizontal: | 109 case FontOrientation::Horizontal: |
| 110 case FontOrientation::VerticalRotated: | 110 case FontOrientation::VerticalRotated: |
| 111 return width(); | 111 return width(); |
| 112 case FontOrientation::VerticalUpright: | 112 case FontOrientation::VerticalUpright: |
| 113 return height(); | 113 return height(); |
| 114 default: | 114 default: |
| 115 ASSERT_NOT_REACHED(); | 115 ASSERT_NOT_REACHED(); |
| 116 return width(); | 116 return width(); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |