示例#1
0
void SVGLengthTearOff::setValueAsString(const String& str,
                                        ExceptionState& exceptionState) {
  if (isImmutable()) {
    throwReadOnly(exceptionState);
    return;
  }
  String oldValue = target()->valueAsString();
  SVGParsingError status = target()->setValueAsString(str);
  if (status == SVGParseStatus::NoError && !hasExposedLengthUnit()) {
    target()->setValueAsString(oldValue);  // rollback to old value
    status = SVGParseStatus::ParsingFailed;
  }
  if (status != SVGParseStatus::NoError) {
    exceptionState.throwDOMException(
        SyntaxError, "The value provided ('" + str + "') is invalid.");
    return;
  }
  commitChange();
}
void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& exceptionState)
{
if (isImmutable()) {
    exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
    return;
}

String oldValue = target()->valueAsString();

SVGParsingError status = target()->setValueAsString(str);

if (status == NoError && !hasExposedLengthUnit()) {
    target()->setValueAsString(oldValue); // rollback to old value
    status = ParsingAttributeFailedError;
}
if (status != NoError) {
    exceptionState.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid.");
    return;
}

commitChange();
}
示例#3
0
String SVGLengthTearOff::valueAsString() {
  // TODO([email protected]): Not all <length> properties have 0 (with no
  // unit) as the default (lacuna) value. We need to return default value
  // instead of 0.
  return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0);
}
示例#4
0
unsigned short SVGLengthTearOff::unitType() {
  return hasExposedLengthUnit()
             ? toInterfaceConstant(target()->typeWithCalcResolved())
             : kSvgLengthtypeUnknown;
}
SVGLengthType SVGLengthTearOff::unitType()
{
return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolved()) : LengthTypeUnknown;
}