예제 #1
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value)
{
    ASSERT(type <= LengthTypePC);

    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    m_valueInSpecifiedUnits = value;
}
예제 #2
0
void SVGLength::convertToSpecifiedUnits(unsigned short type)
{
    ASSERT(type <= LengthTypePC);

    float valueInUserUnits = value();
    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    setValue(valueInUserUnits);
}
예제 #3
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return;

    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    m_valueInSpecifiedUnits = value;
}
예제 #4
0
ExceptionOr<void> SVGLengthValue::newValueSpecifiedUnits(unsigned short type, float value)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return Exception { NOT_SUPPORTED_ERR };

    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    m_valueInSpecifiedUnits = value;
    return { };
}
예제 #5
0
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return;

    float valueInUserUnits = value(context);
    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    setValue(valueInUserUnits);
}
예제 #6
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionCode& ec)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    m_valueInSpecifiedUnits = value;
}
예제 #7
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;
}
예제 #8
0
void SVGLength::setValueAsString(const String& s)
{
    if (s.isEmpty())
        return;

    double convertedNumber = 0;
    const UChar* ptr = s.characters();
    const UChar* end = ptr + s.length();
    parseNumber(ptr, end, convertedNumber, false);

    m_unit = storeUnit(extractMode(m_unit), stringToLengthType(s));
    m_valueInSpecifiedUnits = narrowPrecisionToFloat(convertedNumber);
}
예제 #9
0
ExceptionOr<void> SVGLengthValue::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return Exception { NOT_SUPPORTED_ERR };

    auto valueInUserUnits = valueForBindings(context);
    if (valueInUserUnits.hasException())
        return valueInUserUnits.releaseException();

    auto originalUnitAndType = m_unit;
    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    auto result = setValue(valueInUserUnits.releaseReturnValue(), context);
    if (result.hasException()) {
        m_unit = originalUnitAndType;
        return result.releaseException();
    }

    return { };
}
예제 #10
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;
}
예제 #11
0
파일: SVGLength.cpp 프로젝트: Igalia/blink
void SVGLength::setValueAsString(const String& string, ExceptionState& exceptionState)
{
    if (string.isEmpty())
        return;

    float convertedNumber = 0;
    SVGLengthType type = LengthTypeUnknown;

    bool success = string.is8Bit() ?
        parseValueInternal<LChar>(string, convertedNumber, type) :
        parseValueInternal<UChar>(string, convertedNumber, type);

    if (!success) {
        exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
}
예제 #12
0
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context, ExceptionCode& ec)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    float valueInUserUnits = value(context, ec);
    if (ec)
        return;

    unsigned int originalUnitAndType = m_unit;    
    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    setValue(valueInUserUnits, context, ec);
    if (!ec)
        return;

    // Eventually restore old unit and type
    m_unit = originalUnitAndType;
}
예제 #13
0
bool SVGLength::setValueAsString(const String& s)
{
    if (s.isEmpty())
        return false;

    float convertedNumber = 0.0f;
    const UChar* ptr = s.characters();
    const UChar* end = ptr + s.length();

    if (!parseNumber(ptr, end, convertedNumber, false))
        return false;

    SVGLengthType type = stringToLengthType(ptr, end);
    if (type == LengthTypeUnknown)
        return false;

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
    return true;
}
예제 #14
0
ExceptionOr<void> SVGLengthValue::setValueAsString(const String& string)
{
    if (string.isEmpty())
        return { };

    float convertedNumber = 0;
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
    const UChar* ptr = upconvertedCharacters;
    const UChar* end = ptr + string.length();

    if (!parseNumber(ptr, end, convertedNumber, false))
        return Exception { SYNTAX_ERR };

    auto type = parseLengthType(ptr, end);
    if (type == LengthTypeUnknown)
        return Exception { SYNTAX_ERR };

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
    return { };
}
예제 #15
0
void SVGLength::setValueAsString(const String& string, ExceptionCode& ec)
{
    if (string.isEmpty())
        return;

    float convertedNumber = 0;
    const UChar* ptr = string.characters();
    const UChar* end = ptr + string.length();

    if (!parseNumber(ptr, end, convertedNumber, false)) {
        ec = SYNTAX_ERR;
        return;
    }

    SVGLengthType type = stringToLengthType(ptr, end);
    ASSERT(ptr <= end);
    if (type == LengthTypeUnknown) {
        ec = SYNTAX_ERR;
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
}
예제 #16
0
SVGLengthValue::SVGLengthValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
    : m_unit(storeUnit(mode, unitType))
{
    setValue(value, context);
}
예제 #17
0
파일: SVGLength.cpp 프로젝트: Igalia/blink
void SVGLength::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionState& exceptionState)
{
    m_unit = storeUnit(mode, unitType);
    setValue(value, context, exceptionState);
}
예제 #18
0
파일: SVGLength.cpp 프로젝트: Igalia/blink
void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionState& exceptionState)
{
    m_valueInSpecifiedUnits = 0;
    m_unit = storeUnit(mode, LengthTypeNumber);
    setValueAsString(valueAsString, exceptionState);
}
예제 #19
0
파일: SVGLength.cpp 프로젝트: Igalia/blink
SVGLength::SVGLength(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
    : m_valueInSpecifiedUnits(0)
    , m_unit(storeUnit(mode, unitType))
{
    setValue(value, context, ASSERT_NO_EXCEPTION);
}
예제 #20
0
파일: SVGLength.cpp 프로젝트: Igalia/blink
SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString)
    : m_valueInSpecifiedUnits(0)
    , m_unit(storeUnit(mode, LengthTypeNumber))
{
    setValueAsString(valueAsString, IGNORE_EXCEPTION);
}
예제 #21
0
ExceptionOr<void> SVGLengthValue::setValueAsString(const String& valueAsString, SVGLengthMode mode)
{
    m_valueInSpecifiedUnits = 0;
    m_unit = storeUnit(mode, LengthTypeNumber);
    return setValueAsString(valueAsString);
}
예제 #22
0
ExceptionOr<void> SVGLengthValue::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
{
    // FIXME: Seems like a bug that we change the value of m_unit even if setValue throws an exception.
    m_unit = storeUnit(mode, unitType);
    return setValue(value, context);
}
예제 #23
0
SVGLengthValue::SVGLengthValue(SVGLengthMode mode, const String& valueAsString)
    : m_unit(storeUnit(mode, LengthTypeNumber))
{
    setValueAsString(valueAsString);
}
예제 #24
0
SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString)
    : m_valueInSpecifiedUnits(0.0f)
    , m_unit(storeUnit(mode, LengthTypeNumber))
{
    setValueAsString(valueAsString);
}