bool SVGLengthTearOff::hasExposedLengthUnit() { if (target()->isCalculated()) return false; CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved(); return isValidLengthUnit(unit) || unit == CSSPrimitiveValue::UnitType::Unknown || unit == CSSPrimitiveValue::UnitType::UserUnits; }
void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionState& exceptionState) { if (isImmutable()) { exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only."); return; } if (!isValidLengthUnit(unitType)) { exceptionState.throwDOMException(NotSupportedError, "Cannot set value with unknown or invalid units (" + String::number(unitType) + ")."); return; } target()->newValueSpecifiedUnits(toCSSUnitType(unitType), valueInSpecifiedUnits); 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(); }