Пример #1
0
float SVGLength::value(const SVGLengthContext& context) const {
  if (isCalculated())
    return context.resolveValue(asCSSPrimitiveValue(), unitMode());

  return context.convertValueToUserUnits(m_value->getFloatValue(), unitMode(),
                                         m_value->typeWithCalcResolved());
}
Пример #2
0
DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray, const ComputedStyle& style, const SVGLengthContext& lengthContext)
{
    DashArray dashArray;
    for (const Length& dashLength : svgDashArray.vector())
        dashArray.append(lengthContext.valueForLength(dashLength, style));
    return dashArray;
}
Пример #3
0
void SVGLength::convertToSpecifiedUnits(CSSPrimitiveValue::UnitType type, const SVGLengthContext& context)
{
    ASSERT(isSupportedCSSUnitType(type));

    float valueInUserUnits = value(context);
    m_value = CSSPrimitiveValue::create(
        context.convertValueFromUserUnits(valueInUserUnits, unitMode(), type),
        type);
}
Пример #4
0
void SVGLength::setValue(float value, const SVGLengthContext& context, ExceptionState& exceptionState)
{
    // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
    if (extractType(m_unit) == LengthTypePercentage)
        value = value / 100;

    float convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit), exceptionState);
    if (!exceptionState.hadException())
        m_valueInSpecifiedUnits = convertedValue;
}
Пример #5
0
ExceptionOr<void> SVGLengthValue::setValue(float value, const SVGLengthContext& context)
{
    // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
    if (extractType(m_unit) == LengthTypePercentage)
        value = value / 100;

    auto convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit));
    if (convertedValue.hasException())
        return convertedValue.releaseException();
    m_valueInSpecifiedUnits = convertedValue.releaseReturnValue();
    return { };
}
Пример #6
0
float SVGLength::value(const SVGLengthContext& context, ExceptionState& exceptionState) const
{
    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit), exceptionState);
}
Пример #7
0
void SVGLength::setValue(float value, const SVGLengthContext& context)
{
    m_value = CSSPrimitiveValue::create(
        context.convertValueFromUserUnits(value, unitMode(), m_value->typeWithCalcResolved()),
        m_value->typeWithCalcResolved());
}
Пример #8
0
float SVGLength::value(const SVGLengthContext& context) const
{
    return context.convertValueToUserUnits(
        m_value->getFloatValue(), unitMode(), m_value->typeWithCalcResolved());
}
Пример #9
0
ExceptionOr<float> SVGLengthValue::valueForBindings(const SVGLengthContext& context) const
{
    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit));
}