float SVGLengthTearOff::value(ExceptionState& exceptionState) { if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length."); return 0; } SVGLengthContext lengthContext(contextElement()); return target()->value(lengthContext); }
void SVGLengthTearOff::setValue(float value, ExceptionState& exceptionState) { if (isImmutable()) { exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only."); return; } if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length."); return; } SVGLengthContext lengthContext(contextElement()); target()->setValue(value, lengthContext); commitChange(); }
void SVGLengthTearOff::setValue(float value, ExceptionState& exceptionState) { if (isImmutable()) { throwReadOnly(exceptionState); return; } if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length."); return; } SVGLengthContext lengthContext(contextElement()); if (target()->isCalculated()) target()->setValueAsNumber(value); else target()->setValue(value, lengthContext); commitChange(); }
void SVGLengthTearOff::convertToSpecifiedUnits(unsigned short unitType, ExceptionState& exceptionState) { if (isImmutable()) { exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only."); return; } if (!isValidLengthUnit(unitType)) { exceptionState.throwDOMException(NotSupportedError, "Cannot convert to unknown or invalid units (" + String::number(unitType) + ")."); return; } if ((target()->isRelative() || SVGLength::isRelativeUnit(toCSSUnitType(unitType))) && !canResolveRelativeUnits(contextElement())) { exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length."); return; } SVGLengthContext lengthContext(contextElement()); target()->convertToSpecifiedUnits(toCSSUnitType(unitType), lengthContext); commitChange(); }