| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 { | 34 { |
| 35 ASSERT(m_effectiveZoom); | 35 ASSERT(m_effectiveZoom); |
| 36 } | 36 } |
| 37 | 37 |
| 38 float SVGTextLayoutEngineBaseline::calculateBaselineShift(const ComputedStyle& s
tyle) const | 38 float SVGTextLayoutEngineBaseline::calculateBaselineShift(const ComputedStyle& s
tyle) const |
| 39 { | 39 { |
| 40 const SVGComputedStyle& svgStyle = style.svgStyle(); | 40 const SVGComputedStyle& svgStyle = style.svgStyle(); |
| 41 | 41 |
| 42 switch (svgStyle.baselineShift()) { | 42 switch (svgStyle.baselineShift()) { |
| 43 case BS_LENGTH: | 43 case BS_LENGTH: |
| 44 return SVGLengthContext::valueForLength(svgStyle.baselineShiftValue(), s
tyle, m_font.fontDescription().computedPixelSize() / m_effectiveZoom); | 44 return SVGLengthContext::valueForLength(svgStyle.baselineShiftValue(), s
tyle, m_font.getFontDescription().computedPixelSize() / m_effectiveZoom); |
| 45 case BS_SUB: | 45 case BS_SUB: |
| 46 return -m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom; | 46 return -m_font.getFontMetrics().floatHeight() / 2 / m_effectiveZoom; |
| 47 case BS_SUPER: | 47 case BS_SUPER: |
| 48 return m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom; | 48 return m_font.getFontMetrics().floatHeight() / 2 / m_effectiveZoom; |
| 49 default: | 49 default: |
| 50 ASSERT_NOT_REACHED(); | 50 ASSERT_NOT_REACHED(); |
| 51 return 0; | 51 return 0; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel
ine(bool isVerticalText, LineLayoutItem textLineLayout) const | 55 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel
ine(bool isVerticalText, LineLayoutItem textLineLayout) const |
| 56 { | 56 { |
| 57 ASSERT(textLineLayout); | 57 ASSERT(textLineLayout); |
| 58 ASSERT(textLineLayout.style()); | 58 ASSERT(textLineLayout.style()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 LineLayoutItem textLineLayoutParent = textLineLayout.parent(); | 110 LineLayoutItem textLineLayoutParent = textLineLayout.parent(); |
| 111 ASSERT(textLineLayoutParent); | 111 ASSERT(textLineLayoutParent); |
| 112 | 112 |
| 113 EAlignmentBaseline baseline = textLineLayout.style()->svgStyle().alignmentBa
seline(); | 113 EAlignmentBaseline baseline = textLineLayout.style()->svgStyle().alignmentBa
seline(); |
| 114 if (baseline == AB_AUTO || baseline == AB_BASELINE) { | 114 if (baseline == AB_AUTO || baseline == AB_BASELINE) { |
| 115 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textLineL
ayoutParent); | 115 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textLineL
ayoutParent); |
| 116 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); | 116 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); |
| 117 } | 117 } |
| 118 | 118 |
| 119 const FontMetrics& fontMetrics = m_font.fontMetrics(); | 119 const FontMetrics& fontMetrics = m_font.getFontMetrics(); |
| 120 float ascent = fontMetrics.floatAscent() / m_effectiveZoom; | 120 float ascent = fontMetrics.floatAscent() / m_effectiveZoom; |
| 121 float descent = fontMetrics.floatDescent() / m_effectiveZoom; | 121 float descent = fontMetrics.floatDescent() / m_effectiveZoom; |
| 122 float xheight = fontMetrics.xHeight() / m_effectiveZoom; | 122 float xheight = fontMetrics.xHeight() / m_effectiveZoom; |
| 123 | 123 |
| 124 // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling | 124 // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling |
| 125 switch (baseline) { | 125 switch (baseline) { |
| 126 case AB_BEFORE_EDGE: | 126 case AB_BEFORE_EDGE: |
| 127 case AB_TEXT_BEFORE_EDGE: | 127 case AB_TEXT_BEFORE_EDGE: |
| 128 return ascent; | 128 return ascent; |
| 129 case AB_MIDDLE: | 129 case AB_MIDDLE: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 141 case AB_MATHEMATICAL: | 141 case AB_MATHEMATICAL: |
| 142 return ascent / 2; | 142 return ascent / 2; |
| 143 case AB_BASELINE: | 143 case AB_BASELINE: |
| 144 default: | 144 default: |
| 145 ASSERT_NOT_REACHED(); | 145 ASSERT_NOT_REACHED(); |
| 146 return 0; | 146 return 0; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |