float SVGLength::value(const SVGLengthContext& context) const { if (isCalculated()) return context.resolveValue(asCSSPrimitiveValue(), unitMode()); return context.convertValueToUserUnits(m_value->getFloatValue(), unitMode(), m_value->typeWithCalcResolved()); }
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; }
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); }
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; }
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 { }; }
float SVGLength::value(const SVGLengthContext& context, ExceptionState& exceptionState) const { return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit), exceptionState); }
void SVGLength::setValue(float value, const SVGLengthContext& context) { m_value = CSSPrimitiveValue::create( context.convertValueFromUserUnits(value, unitMode(), m_value->typeWithCalcResolved()), m_value->typeWithCalcResolved()); }
float SVGLength::value(const SVGLengthContext& context) const { return context.convertValueToUserUnits( m_value->getFloatValue(), unitMode(), m_value->typeWithCalcResolved()); }
ExceptionOr<float> SVGLengthValue::valueForBindings(const SVGLengthContext& context) const { return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit)); }