OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 | 21 |
22 #include "core/rendering/svg/SVGTextLayoutEngineBaseline.h" | 22 #include "core/rendering/svg/SVGTextLayoutEngineBaseline.h" |
23 | 23 |
24 #include "core/rendering/RenderObject.h" | 24 #include "core/layout/LayoutObject.h" |
25 #include "core/rendering/style/SVGRenderStyle.h" | 25 #include "core/rendering/style/SVGRenderStyle.h" |
26 #include "core/rendering/svg/SVGTextMetrics.h" | 26 #include "core/rendering/svg/SVGTextMetrics.h" |
27 #include "core/svg/SVGLengthContext.h" | 27 #include "core/svg/SVGLengthContext.h" |
28 #include "platform/fonts/Font.h" | 28 #include "platform/fonts/Font.h" |
29 #include "platform/text/UnicodeRange.h" | 29 #include "platform/text/UnicodeRange.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font) | 33 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font) |
34 : m_font(font) | 34 : m_font(font) |
(...skipping 17 matching lines...) Expand all Loading... |
52 case BS_SUB: | 52 case BS_SUB: |
53 return -m_font.fontMetrics().floatHeight() / 2; | 53 return -m_font.fontMetrics().floatHeight() / 2; |
54 case BS_SUPER: | 54 case BS_SUPER: |
55 return m_font.fontMetrics().floatHeight() / 2; | 55 return m_font.fontMetrics().floatHeight() / 2; |
56 default: | 56 default: |
57 ASSERT_NOT_REACHED(); | 57 ASSERT_NOT_REACHED(); |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel
ine(bool isVerticalText, const RenderObject* textRenderer) const | 62 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel
ine(bool isVerticalText, const LayoutObject* textRenderer) const |
63 { | 63 { |
64 ASSERT(textRenderer); | 64 ASSERT(textRenderer); |
65 ASSERT(textRenderer->style()); | 65 ASSERT(textRenderer->style()); |
66 ASSERT(textRenderer->parent()); | 66 ASSERT(textRenderer->parent()); |
67 ASSERT(textRenderer->parent()->style()); | 67 ASSERT(textRenderer->parent()->style()); |
68 | 68 |
69 const SVGRenderStyle& style = textRenderer->style()->svgStyle(); | 69 const SVGRenderStyle& style = textRenderer->style()->svgStyle(); |
70 | 70 |
71 EDominantBaseline baseline = style.dominantBaseline(); | 71 EDominantBaseline baseline = style.dominantBaseline(); |
72 if (baseline == DB_AUTO) { | 72 if (baseline == DB_AUTO) { |
(...skipping 26 matching lines...) Expand all Loading... |
99 case DB_TEXT_AFTER_EDGE: | 99 case DB_TEXT_AFTER_EDGE: |
100 return AB_TEXT_AFTER_EDGE; | 100 return AB_TEXT_AFTER_EDGE; |
101 case DB_TEXT_BEFORE_EDGE: | 101 case DB_TEXT_BEFORE_EDGE: |
102 return AB_TEXT_BEFORE_EDGE; | 102 return AB_TEXT_BEFORE_EDGE; |
103 default: | 103 default: |
104 ASSERT_NOT_REACHED(); | 104 ASSERT_NOT_REACHED(); |
105 return AB_AUTO; | 105 return AB_AUTO; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic
alText, const RenderObject* textRenderer) const | 109 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic
alText, const LayoutObject* textRenderer) const |
110 { | 110 { |
111 ASSERT(textRenderer); | 111 ASSERT(textRenderer); |
112 ASSERT(textRenderer->style()); | 112 ASSERT(textRenderer->style()); |
113 ASSERT(textRenderer->parent()); | 113 ASSERT(textRenderer->parent()); |
114 | 114 |
115 const RenderObject* textRendererParent = textRenderer->parent(); | 115 const LayoutObject* textRendererParent = textRenderer->parent(); |
116 ASSERT(textRendererParent); | 116 ASSERT(textRendererParent); |
117 | 117 |
118 EAlignmentBaseline baseline = textRenderer->style()->svgStyle().alignmentBas
eline(); | 118 EAlignmentBaseline baseline = textRenderer->style()->svgStyle().alignmentBas
eline(); |
119 if (baseline == AB_AUTO || baseline == AB_BASELINE) { | 119 if (baseline == AB_AUTO || baseline == AB_BASELINE) { |
120 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textRende
rerParent); | 120 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textRende
rerParent); |
121 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); | 121 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); |
122 } | 122 } |
123 | 123 |
124 const FontMetrics& fontMetrics = m_font.fontMetrics(); | 124 const FontMetrics& fontMetrics = m_font.fontMetrics(); |
125 | 125 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 xOrientationShift = metrics.width(); | 222 xOrientationShift = metrics.width(); |
223 | 223 |
224 // Horizontal advance calculation. | 224 // Horizontal advance calculation. |
225 if (angle && !orientationIsMultiplyOf180Degrees) | 225 if (angle && !orientationIsMultiplyOf180Degrees) |
226 return metrics.height(); | 226 return metrics.height(); |
227 | 227 |
228 return metrics.width(); | 228 return metrics.width(); |
229 } | 229 } |
230 | 230 |
231 } | 231 } |
OLD | NEW |