コード例 #1
0
float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle& style, SVGElement* context) const
{
    if (style.baselineShift() == BS_LENGTH) {
        auto baselineShiftValueLength = style.baselineShiftValue();
        if (baselineShiftValueLength.unitType() == LengthTypePercentage)
            return baselineShiftValueLength.valueAsPercentage() * m_font.pixelSize();

        SVGLengthContext lengthContext(context);
        return baselineShiftValueLength.value(lengthContext);
    }

    switch (style.baselineShift()) {
    case BS_BASELINE:
        return 0;
    case BS_SUB:
        return -m_font.fontMetrics().floatHeight() / 2;
    case BS_SUPER:
        return m_font.fontMetrics().floatHeight() / 2;
    case BS_LENGTH:
        break;
    }
    ASSERT_NOT_REACHED();
    return 0;
}