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 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(); }
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(); }
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; }
static inline SVGLengthType extractType(unsigned int unit) { unsigned int mode = unit >> 4; unsigned int type = unit ^ (mode << 4); return toSVGLengthType(type); }
SVGLengthType SVGLengthTearOff::unitType() { return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolved()) : LengthTypeUnknown; }