Beispiel #1
0
ExceptionOr<float> SVGLengthContext::convertValueFromEMSToUserUnits(float value) const
{
    auto* style = renderStyleForLengthResolving(m_context);
    if (!style)
        return Exception { NOT_SUPPORTED_ERR };

    return value * style->fontSize();
}
Beispiel #2
0
float SVGLengthContext::convertValueFromEMSToUserUnits(float value, ExceptionCode& ec) const
{
    auto* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    return value * style->fontSize();
}
float SVGLengthContext::convertValueFromEMSToUserUnits(float value, ExceptionState& es) const
{
    RenderStyle* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        es.throwDOMException(NotSupportedError);
        return 0;
    }

    return value * style->specifiedFontSize();
}
Beispiel #4
0
ExceptionOr<float> SVGLengthContext::convertValueFromEXSToUserUnits(float value) const
{
    auto* style = renderStyleForLengthResolving(m_context);
    if (!style)
        return Exception { NOT_SUPPORTED_ERR };

    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
    // if this causes problems in real world cases maybe it would be best to remove this
    return value * std::ceil(style->fontMetrics().xHeight());
}
float SVGLengthContext::convertValueFromEXSToUserUnits(float value, ExceptionState& es) const
{
    RenderStyle* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        es.throwDOMException(NotSupportedError);
        return 0;
    }

    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
    // if this causes problems in real world cases maybe it would be best to remove this
    return value * ceilf(style->fontMetrics().xHeight());
}
float SVGLengthContext::convertValueFromUserUnitsToEMS(float value, ExceptionState& exceptionState) const
{
    RenderStyle* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        exceptionState.throwDOMException(NotSupportedError, "No context could be found.");
        return 0;
    }

    float fontSize = style->specifiedFontSize();
    if (!fontSize) {
        exceptionState.throwDOMException(NotSupportedError, "No font-size could be determined.");
        return 0;
    }

    return value / fontSize;
}
Beispiel #7
0
float SVGLengthContext::convertValueFromUserUnitsToEMS(float value, ExceptionCode& ec) const
{
    RenderStyle* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    float fontSize = style->fontSize();
    if (!fontSize) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    return value / fontSize;
}
Beispiel #8
0
float SVGLengthContext::convertValueFromUserUnitsToEXS(float value, ExceptionCode& ec) const
{
    auto* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
    // if this causes problems in real world cases maybe it would be best to remove this
    float xHeight = ceilf(style->fontMetrics().xHeight());
    if (!xHeight) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    return value / xHeight;
}
float SVGLengthContext::convertValueFromUserUnitsToEXS(float value, ExceptionState& exceptionState) const
{
    RenderStyle* style = renderStyleForLengthResolving(m_context);
    if (!style) {
        exceptionState.throwDOMException(NotSupportedError, "No context could be found.");
        return 0;
    }

    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
    // if this causes problems in real world cases maybe it would be best to remove this
    float xHeight = ceilf(style->fontMetrics().xHeight());
    if (!xHeight) {
        exceptionState.throwDOMException(NotSupportedError, "No x-height could be determined.");
        return 0;
    }

    return value / xHeight;
}