Beispiel #1
0
SVGLengthValue SVGLengthValue::fromCSSPrimitiveValue(const CSSPrimitiveValue& value)
{
    SVGLengthType type;
    switch (value.primitiveType()) {
    case CSSPrimitiveValue::CSS_NUMBER:
        type = LengthTypeNumber;
        break;
    case CSSPrimitiveValue::CSS_PERCENTAGE:
        type = LengthTypePercentage;
        break;
    case CSSPrimitiveValue::CSS_EMS:
        type = LengthTypeEMS;
        break;
    case CSSPrimitiveValue::CSS_EXS:
        type = LengthTypeEXS;
        break;
    case CSSPrimitiveValue::CSS_PX:
        type = LengthTypePX;
        break;
    case CSSPrimitiveValue::CSS_CM:
        type = LengthTypeCM;
        break;
    case CSSPrimitiveValue::CSS_MM:
        type = LengthTypeMM;
        break;
    case CSSPrimitiveValue::CSS_IN:
        type = LengthTypeIN;
        break;
    case CSSPrimitiveValue::CSS_PT:
        type = LengthTypePT;
        break;
    case CSSPrimitiveValue::CSS_PC:
        type = LengthTypePC;
        break;
    case CSSPrimitiveValue::CSS_UNKNOWN:
    default:
        return { };
    };

    SVGLengthValue length;
    length.newValueSpecifiedUnits(type, value.floatValue());
    return length;
}