コード例 #1
0
ファイル: SVGLength.cpp プロジェクト: Igalia/blink
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionState& exceptionState)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
    m_valueInSpecifiedUnits = value;
}
コード例 #2
0
void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionState& exceptionState)
{
    if (isImmutable()) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only.");
        return;
    }

    if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
        exceptionState.throwDOMException(NotSupportedError, "Cannot set value with unknown or invalid units (" + String::number(unitType) + ").");
        return;
    }

    target()->newValueSpecifiedUnits(toSVGLengthType(unitType), valueInSpecifiedUnits);
    commitChange();
}
コード例 #3
0
void SVGLengthTearOff::convertToSpecifiedUnits(unsigned short unitType, ExceptionState& exceptionState)
{
    if (isImmutable()) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only.");
        return;
    }

    if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
        exceptionState.throwDOMException(NotSupportedError, "Cannot convert to unknown or invalid units (" + String::number(unitType) + ").");
        return;
    }

    SVGLengthContext lengthContext(contextElement());
    target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext, exceptionState);
    commitChange();
}
コード例 #4
0
ファイル: SVGLength.cpp プロジェクト: Igalia/blink
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context, ExceptionState& exceptionState)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
        return;
    }

    float valueInUserUnits = value(context, exceptionState);
    if (exceptionState.hadException())
        return;

    unsigned int originalUnitAndType = m_unit;
    m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
    setValue(valueInUserUnits, context, exceptionState);
    if (!exceptionState.hadException())
        return;

    // Eventually restore old unit and type
    m_unit = originalUnitAndType;
}
コード例 #5
0
ファイル: SVGLength.cpp プロジェクト: Igalia/blink
static inline SVGLengthType extractType(unsigned int unit)
{
    unsigned int mode = unit >> 4;
    unsigned int type = unit ^ (mode << 4);
    return toSVGLengthType(type);
}
コード例 #6
0
SVGLengthType SVGLengthTearOff::unitType()
{
return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolved()) : LengthTypeUnknown;
}