void SVGAnimatedEnumerationBase::setBaseVal(unsigned short value, ExceptionState& exceptionState)
{
    if (this->isReadOnly()) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
        return;
    }

    if (!value) {
        exceptionState.throwTypeError("The enumeration value provided is 0, which is not settable.");
        return;
    }

    if (value > baseValue()->maxExposedEnumValue()) {
        exceptionState.throwTypeError("The enumeration value provided (" + String::number(value) + ") is larger than the largest allowed value (" + String::number(baseValue()->maxExposedEnumValue()) + ").");
        return;
    }

    baseValue()->setValue(value);

    m_baseValueUpdated = true;

    ASSERT(this->attributeName() != QualifiedName::null());
    contextElement()->invalidateSVGAttributes();
    contextElement()->svgAttributeChanged(this->attributeName());
}
Ejemplo n.º 2
0
void SVGPropertyTearOffBase::commitChange() {
  DCHECK(!isImmutable());
  if (!contextElement() || isAnimVal())
    return;
  DCHECK(m_attributeName != QualifiedName::null());
  contextElement()->invalidateSVGAttributes();
  contextElement()->svgAttributeBaseValChanged(m_attributeName);
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
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();
}
bool SVGFitToViewBox::parseViewBox(const UChar*& c, const UChar* end, float& x, float& y, float& w, float& h, bool validate)
{
    Document* doc = contextElement()->document();
    String str(c, end - c);

    skipOptionalSpaces(c, end);

    bool valid = (parseNumber(c, end, x) && parseNumber(c, end, y) &&
          parseNumber(c, end, w) && parseNumber(c, end, h, false));
    if (!validate)
        return true;
    if (!valid) {
        doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
        return false;
    }

    if (w < 0.0) { // check that width is positive
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed");
        return false;
    } else if (h < 0.0) { // check that height is positive
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed");
        return false;
    } else {
        skipOptionalSpaces(c, end);
        if (c < end) { // nothing should come after the last, fourth number
            doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
            return false;
        }
    }

    return true;
}
Ejemplo n.º 6
0
void SVGFitToViewBox::parseViewBox(const String& str)
{
    double x = 0, y = 0, w = 0, h = 0;
    const UChar* c = str.characters();
    const UChar* end = c + str.length();
    Document* doc = contextElement()->document();

    skipOptionalSpaces(c, end);

    if (!(parseNumber(c, end, x) && parseNumber(c, end, y) &&
          parseNumber(c, end, w) && parseNumber(c, end, h, false))) {
        doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
        return;
    }

    if (w < 0.0) // check that width is positive
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed");
    else if (h < 0.0) // check that height is positive
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed");
    else {
        skipOptionalSpaces(c, end);
        if (c < end) // nothing should come after the last, fourth number
            doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
        else
            setViewBoxBaseValue(FloatRect(x, y, w, h));
    }
}
SVGStringListTearOff* SVGStaticStringList::tearOff()
{
    if (!m_tearOff)
        m_tearOff = SVGStringListTearOff::create(m_value, contextElement(), PropertyIsNotAnimVal, attributeName());

    return m_tearOff.get();
}
Ejemplo n.º 8
0
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();
}
Ejemplo n.º 9
0
void registerSymbol(pt_context *context, char *name, pt_value value) {
	pt_value *value_ref;
	if(context == NULL || name == NULL) return;

	value_ref = contextElement(context, name);
	if(value_ref == NULL) return;

	memcpy(value_ref, &value, sizeof(pt_value));
}
Ejemplo n.º 10
0
void SVGAnimatedAngle::synchronizeAttribute()
{
    AtomicString value;
    if (m_orientType->currentValue()->enumValue() == SVGMarkerOrientAuto)
        value = "auto";
    else
        value = AtomicString(currentValue()->valueAsString());

    contextElement()->setSynchronizedLazyAttribute(attributeName(), value);
}
Ejemplo n.º 11
0
void SVGAnimatedAngle::synchronizeAttribute()
{
    DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto", AtomicString::ConstructFromLiteral));
    AtomicString value;
    if (m_orientType->currentValue()->enumValue() == SVGMarkerOrientAuto)
        value = autoValue;
    else
        value = AtomicString(currentValue()->valueAsString());

    contextElement()->setSynchronizedLazyAttribute(attributeName(), value);
}
void SVGLengthTearOff::setValue(float value, ExceptionState& es)
{
    if (isImmutable()) {
        es.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
        return;
    }

    SVGLengthContext lengthContext(contextElement());
    target()->setValue(value, lengthContext, es);
    commitChange();
}
Ejemplo n.º 13
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();
}
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();
}
bool SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify)
{
    SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContext*>(newItem.get());
    SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedProperty();

    // Alter the role, after calling animatedProperty(), as that may influence the returned animated property.
    newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole);

    if (!animatedPropertyOfItem)
        return true;

    // newItem belongs to a SVGPathElement, but its associated SVGAnimatedProperty is not an animated list tear off.
    // (for example: "pathElement.pathSegList.appendItem(pathElement.createSVGPathSegClosepath())")
    if (!animatedPropertyOfItem->isAnimatedListTearOff())
        return true;

    // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
    // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal.
    bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty;
    SVGAnimatedPathSegListPropertyTearOff* propertyTearOff = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(animatedPropertyOfItem);
    int indexToRemove = propertyTearOff->findItem(newItem.get());
    ASSERT(indexToRemove != -1);

    // Do not remove newItem if already in this list at the target index.
    if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToRemove) == *indexToModify)
        return false;

    propertyTearOff->removeItemFromList(indexToRemove, livesInOtherList);

    if (!indexToModify)
        return true;

    // If the item lived in our list, adjust the insertion index.
    if (!livesInOtherList) {
        unsigned& index = *indexToModify;
        // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item.
        if (static_cast<unsigned>(indexToRemove) < index)
            --index;
    }

    return true;
}
float SVGLengthTearOff::value(ExceptionState& es)
{
    SVGLengthContext lengthContext(contextElement());
    return target()->value(lengthContext, es);
}
Ejemplo n.º 17
0
 void commitChange() override
 {
     ASSERT(contextElement());
     toSVGSVGElement(contextElement())->updateCurrentTranslate();
 }
Ejemplo n.º 18
0
void SVGAnimatedHref::setBaseVal(const String& value,
                                 ExceptionState& exceptionState) {
  UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal);
  return backingString()->SVGAnimatedString::setBaseVal(value, exceptionState);
}
Ejemplo n.º 19
0
String SVGAnimatedHref::animVal() {
  UseCounter::count(contextElement()->document(), UseCounter::SVGHrefAnimVal);
  return backingString()->SVGAnimatedString::animVal();
}
Ejemplo n.º 20
0
 void commitChange() override {
   ASSERT(contextElement());
   toSVGSVGElement(contextElement())->updateUserTransform();
 }
SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::getItem(unsigned index, ExceptionState& es)
{
    ListItemType returnedItem = Base::getItemValues(index, es);
    if (returnedItem) {
        ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextElement() == contextElement());
        ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() == m_pathSegRole);
    }
    return returnedItem.release();
}