SVGParsingError SVGLength::setValueAsString(const String& string)
{
    if (string.isEmpty()) {
        m_value = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::UserUnits);
        return SVGParseStatus::NoError;
    }

    CSSParserContext svgParserContext(SVGAttributeMode, nullptr);
    CSSValue* parsed = CSSParser::parseSingleValue(CSSPropertyX, string, svgParserContext);
    if (!parsed || !parsed->isPrimitiveValue())
        return SVGParseStatus::ExpectedLength;

    CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed);
    // TODO(fs): Enable calc for SVG lengths
    if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCalcResolved()))
        return SVGParseStatus::ExpectedLength;

    m_value = newValue;
    return SVGParseStatus::NoError;
}