nsresult
SVGAnimatedPathSegList::SetAnimValue(const SVGPathData& aNewAnimValue,
                                     nsSVGElement *aElement)
{
  // Note that a new animation may totally change the number of items in the
  // animVal list, either replacing what was essentially a mirror of the
  // baseVal list, or else replacing and overriding an existing animation.
  // Unfortunately it is not possible for us to reliably distinguish between
  // calls to this method that are setting a new sample for an existing
  // animation, and calls that are setting the first sample of an animation
  // that will override an existing animation. In the case of DOMSVGPathSegList
  // the InternalListWillChangeTo method is not virtually free as it is for the
  // other DOM list classes, so this is a shame. We'd quite like to be able to
  // skip the call if possible.

  // We must send these notifications *before* changing mAnimVal! (See above.)

  DOMSVGPathSegList *domWrapper =
    DOMSVGPathSegList::GetDOMWrapperIfExists(GetAnimValKey());
  if (domWrapper) {
    domWrapper->InternalListWillChangeTo(aNewAnimValue);
  }
  if (!mAnimVal) {
    mAnimVal = new SVGPathData();
  }
  nsresult rv = mAnimVal->CopyFrom(aNewAnimValue);
  if (NS_FAILED(rv)) {
    // OOM. We clear the animation and, importantly, ClearAnimValue() ensures
    // that mAnimVal's DOM wrapper (if any) is kept in sync!
    ClearAnimValue(aElement);
  }
  aElement->DidAnimatePathSegList();
  return rv;
}
nsresult
nsSVGAnimatedTransformList::SetAnimValue(const SVGTransformList& aValue,
                                         nsSVGElement *aElement)
{
  bool prevSet = HasTransform() || aElement->GetAnimateMotionTransform();
  SVGAnimatedTransformList *domWrapper =
    SVGAnimatedTransformList::GetDOMWrapperIfExists(this);
  if (domWrapper) {
    // A new animation may totally change the number of items in the animVal
    // list, replacing what was essentially a mirror of the baseVal list, or
    // else replacing and overriding an existing animation. When this happens
    // we must try and keep our animVal's DOM wrapper in sync (see the comment
    // in SVGAnimatedTransformList::InternalBaseValListWillChangeLengthTo).
    //
    // It's not possible for us to reliably distinguish between calls to this
    // method that are setting a new sample for an existing animation, and
    // calls that are setting the first sample of an animation that will
    // override an existing animation. Happily it's cheap to just blindly
    // notify our animVal's DOM wrapper of its internal counterpart's new value
    // each time this method is called, so that's what we do.
    //
    // Note that we must send this notification *before* setting or changing
    // mAnimVal! (See the comment in SetBaseValueString above.)
    //
    domWrapper->InternalAnimValListWillChangeLengthTo(aValue.Length());
  }
  if (!mAnimVal) {
    mAnimVal = new SVGTransformList();
  }
  nsresult rv = mAnimVal->CopyFrom(aValue);
  if (NS_FAILED(rv)) {
    // OOM. We clear the animation, and, importantly, ClearAnimValue() ensures
    // that mAnimVal and its DOM wrapper (if any) will have the same length!
    ClearAnimValue(aElement);
    return rv;
  }
  int32_t modType;
  if(prevSet) {
    modType = nsIDOMMutationEvent::MODIFICATION;
  } else {
    modType = nsIDOMMutationEvent::ADDITION;
  }
  aElement->DidAnimateTransformList(modType);
  return NS_OK;
}
nsresult
SVGAnimatedPointList::SetAnimValue(const SVGPointList& aNewAnimValue,
                                   nsSVGElement *aElement)
{
    // Note that a new animation may totally change the number of items in the
    // animVal list, either replacing what was essentially a mirror of the
    // baseVal list, or else replacing and overriding an existing animation.
    // It is not possible for us to reliably distinguish between calls to this
    // method that are setting a new sample for an existing animation (in which
    // case our list length isn't changing and we wouldn't need to notify our DOM
    // wrapper to keep its length in sync), and calls to this method that are
    // setting the first sample of a new animation that will override the base
    // value/an existing animation (in which case our length may be changing and
    // our DOM wrapper may need to be notified). Happily though, it's cheap to
    // just blindly notify our animVal's DOM wrapper of our new value each time
    // this method is called, so that's what we do.

    // We must send this notification *before* changing mAnimVal! (See above.)

    DOMSVGPointList *domWrapper =
        DOMSVGPointList::GetDOMWrapperIfExists(GetAnimValKey());
    if (domWrapper) {
        domWrapper->InternalListWillChangeTo(aNewAnimValue);
    }
    if (!mAnimVal) {
        mAnimVal = new SVGPointList();
    }
    nsresult rv = mAnimVal->CopyFrom(aNewAnimValue);
    if (NS_FAILED(rv)) {
        // OOM. We clear the animation and, importantly, ClearAnimValue() ensures
        // that mAnimVal's DOM wrapper (if any) is kept in sync!
        ClearAnimValue(aElement);
        return rv;
    }
    aElement->DidAnimatePointList();
    return NS_OK;
}