void SVGLength::newValueSpecifiedUnits(unsigned short type, float value) { ASSERT(type <= LengthTypePC); m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); m_valueInSpecifiedUnits = value; }
void SVGLength::convertToSpecifiedUnits(unsigned short type) { ASSERT(type <= LengthTypePC); float valueInUserUnits = value(); m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); setValue(valueInUserUnits); }
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; }
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 { }; }
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); }
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; }
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; }
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); }
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 { }; }
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; }
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; }
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; }
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; }
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 { }; }
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; }
SVGLengthValue::SVGLengthValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType) : m_unit(storeUnit(mode, unitType)) { setValue(value, context); }
void SVGLength::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionState& exceptionState) { m_unit = storeUnit(mode, unitType); setValue(value, context, exceptionState); }
void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionState& exceptionState) { m_valueInSpecifiedUnits = 0; m_unit = storeUnit(mode, LengthTypeNumber); setValueAsString(valueAsString, exceptionState); }
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); }
SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString) : m_valueInSpecifiedUnits(0) , m_unit(storeUnit(mode, LengthTypeNumber)) { setValueAsString(valueAsString, IGNORE_EXCEPTION); }
ExceptionOr<void> SVGLengthValue::setValueAsString(const String& valueAsString, SVGLengthMode mode) { m_valueInSpecifiedUnits = 0; m_unit = storeUnit(mode, LengthTypeNumber); return setValueAsString(valueAsString); }
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); }
SVGLengthValue::SVGLengthValue(SVGLengthMode mode, const String& valueAsString) : m_unit(storeUnit(mode, LengthTypeNumber)) { setValueAsString(valueAsString); }
SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString) : m_valueInSpecifiedUnits(0.0f) , m_unit(storeUnit(mode, LengthTypeNumber)) { setValueAsString(valueAsString); }