already_AddRefed<nsISVGPoint> DOMSVGPointList::Initialize(nsISVGPoint& aNewItem, ErrorResult& aError) { if (IsAnimValList()) { aError.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return nullptr; } // If aNewItem is already in a list we should insert a clone of aNewItem, // and for consistency, this should happen even if *this* is the list that // aNewItem is currently in. Note that in the case of aNewItem being in this // list, the Clear() call before the InsertItemBefore() call would remove it // from this list, and so the InsertItemBefore() call would not insert a // clone of aNewItem, it would actually insert aNewItem. To prevent that // from happening we have to do the clone here, if necessary. nsCOMPtr<nsISVGPoint> domItem = &aNewItem; if (domItem->HasOwner() || domItem->IsReadonly() || domItem->IsTranslatePoint()) { domItem = domItem->Copy(); // must do this before changing anything! } ErrorResult rv; Clear(rv); MOZ_ASSERT(!rv.Failed()); return InsertItemBefore(*domItem, 0, aError); }
/* nsIDOMSVGTransform consolidate (); */ NS_IMETHODIMP DOMSVGTransformList::Consolidate(nsIDOMSVGTransform **_retval) { *_retval = nsnull; if (IsAnimValList()) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; } if (Length() == 0) return NS_OK; // Note that SVG 1.1 says, "The consolidation operation creates new // SVGTransform object as the first and only item in the list" hence, even if // Length() == 1 we can't return that one item (after making it a matrix // type). We must orphan the existing item and then make a new one. // First calculate our matrix gfxMatrix mx = InternalList().GetConsolidationMatrix(); // Then orphan the existing items Clear(); // And append the new transform nsRefPtr<DOMSVGTransform> transform = new DOMSVGTransform(mx); return InsertItemBefore(transform, Length(), _retval); }
already_AddRefed<DOMSVGPathSeg> DOMSVGPathSegList::Initialize(DOMSVGPathSeg& aNewItem, ErrorResult& aError) { if (IsAnimValList()) { aError.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return nullptr; } // If aNewItem is already in a list we should insert a clone of aNewItem, // and for consistency, this should happen even if *this* is the list that // aNewItem is currently in. Note that in the case of aNewItem being in this // list, the Clear() call before the InsertItemBefore() call would remove it // from this list, and so the InsertItemBefore() call would not insert a // clone of aNewItem, it would actually insert aNewItem. To prevent that // from happening we have to do the clone here, if necessary. nsRefPtr<DOMSVGPathSeg> domItem = &aNewItem; if (aNewItem.HasOwner()) { domItem = aNewItem.Clone(); } Clear(aError); MOZ_ASSERT(!aError.Failed(), "How could this fail?"); return InsertItemBefore(*domItem, 0, aError); }
void DOMSVGStringList::Initialize(const nsAString& aNewItem, nsAString& aRetval, ErrorResult& aRv) { if (InternalList().IsExplicitlySet()) { InternalList().Clear(); } InsertItemBefore(aNewItem, 0, aRetval, aRv); }
already_AddRefed<nsIDOMSVGPoint> DOMSVGPointList::Initialize(nsIDOMSVGPoint *aNewItem, ErrorResult& aError) { if (IsAnimValList()) { aError.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return nullptr; } // If aNewItem is already in a list we should insert a clone of aNewItem, // and for consistency, this should happen even if *this* is the list that // aNewItem is currently in. Note that in the case of aNewItem being in this // list, the Clear() call before the InsertItemBefore() call would remove it // from this list, and so the InsertItemBefore() call would not insert a // clone of aNewItem, it would actually insert aNewItem. To prevent that // from happening we have to do the clone here, if necessary. nsCOMPtr<DOMSVGPoint> domItem = do_QueryInterface(aNewItem); if (!domItem) { aError.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR); return nullptr; } if (domItem->HasOwner() || domItem->IsReadonly()) { aNewItem = domItem->Clone(); } Clear(); return InsertItemBefore(aNewItem, 0, aError); }
NS_IMETHODIMP DOMSVGLengthList::Initialize(nsIDOMSVGLength *newItem, nsIDOMSVGLength **_retval) { *_retval = nsnull; if (IsAnimValList()) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; } // If newItem is already in a list we should insert a clone of newItem, and // for consistency, this should happen even if *this* is the list that // newItem is currently in. Note that in the case of newItem being in this // list, the Clear() call before the InsertItemBefore() call would remove it // from this list, and so the InsertItemBefore() call would not insert a // clone of newItem, it would actually insert newItem. To prevent that from // happening we have to do the clone here, if necessary. nsCOMPtr<DOMSVGLength> domItem = do_QueryInterface(newItem); if (!domItem) { return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR; } if (domItem->HasOwner()) { newItem = domItem->Copy(); } Clear(); return InsertItemBefore(newItem, 0, _retval); }
already_AddRefed<SVGTransform> DOMSVGTransformList::Consolidate(ErrorResult& error) { if (IsAnimValList()) { error.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return nullptr; } if (LengthNoFlush() == 0) { return nullptr; } // Note that SVG 1.1 says, "The consolidation operation creates new // SVGTransform object as the first and only item in the list" hence, even if // LengthNoFlush() == 1 we can't return that one item (after making it a // matrix type). We must orphan the existing item and then make a new one. // First calculate our matrix gfxMatrix mx = InternalList().GetConsolidationMatrix(); // Then orphan the existing items Clear(error); MOZ_ASSERT(!error.Failed(), "How could this fail?"); // And append the new transform nsRefPtr<SVGTransform> transform = new SVGTransform(mx); return InsertItemBefore(*transform, LengthNoFlush(), error); }
already_AddRefed<SVGTransform> DOMSVGTransformList::Initialize(SVGTransform& newItem, ErrorResult& error) { if (IsAnimValList()) { error.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return nullptr; } // If newItem is already in a list we should insert a clone of newItem, and // for consistency, this should happen even if *this* is the list that // newItem is currently in. Note that in the case of newItem being in this // list, the Clear() call before the InsertItemBefore() call would remove it // from this list, and so the InsertItemBefore() call would not insert a // clone of newItem, it would actually insert newItem. To prevent that from // happening we have to do the clone here, if necessary. nsRefPtr<SVGTransform> domItem = &newItem; if (domItem->HasOwner()) { domItem = newItem.Clone(); } Clear(error); MOZ_ASSERT(!error.Failed(), "How could this fail?"); return InsertItemBefore(*domItem, 0, error); }
NS_IMETHODIMP DOMSVGStringList::Initialize(const nsAString & newItem, nsAString & _retval) { if (InternalList().IsExplicitlySet()) { InternalList().Clear(); } return InsertItemBefore(newItem, 0, _retval); }
NS_IMETHODIMP DOMSVGPointList::InsertItemBefore(nsIDOMSVGPoint *aNewItem, uint32_t aIndex, nsIDOMSVGPoint **_retval) { ErrorResult rv; *_retval = InsertItemBefore(aNewItem, aIndex, rv).get(); return rv.ErrorCode(); }
void DOMSVGStringList::AppendItem(const nsAString& aNewItem, nsAString& aRetval, ErrorResult& aRv) { InsertItemBefore(aNewItem, InternalList().Length(), aRetval, aRv); }
NS_IMETHODIMP DOMSVGLengthList::AppendItem(nsIDOMSVGLength *newItem, nsIDOMSVGLength **_retval) { return InsertItemBefore(newItem, Length(), _retval); }
NS_IMETHODIMP DOMSVGStringList::AppendItem(const nsAString & newItem, nsAString & _retval) { return InsertItemBefore(newItem, InternalList().Length(), _retval); }
NS_IMETHODIMP DOMSVGPathSegList::AppendItem(nsIDOMSVGPathSeg *aNewItem, nsIDOMSVGPathSeg **_retval) { return InsertItemBefore(aNewItem, Length(), _retval); }