Exemplo n.º 1
0
bool SVGLengthTearOff::hasExposedLengthUnit() {
  if (target()->isCalculated())
    return false;

  CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved();
  return isValidLengthUnit(unit) ||
         unit == CSSPrimitiveValue::UnitType::Unknown ||
         unit == CSSPrimitiveValue::UnitType::UserUnits;
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
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();
}