Bug 1166805 part 2 - Call SetCapacity before calling DOMSVGXXXList::MaybeInsertNullInAnimValListAt, to prevent fallible InsertElementAt calls from failing r=dholbert

This commit is contained in:
Robert Longson 2015-11-05 06:32:29 +00:00
Родитель e12ab5ca8b
Коммит 4b121e2bff
5 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -260,6 +260,13 @@ DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
if (AnimListMirrorsBaseList()) {
if (!mAList->mAnimVal->mItems.SetCapacity(
mAList->mAnimVal->mItems.Length() + 1, fallible)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
}
AutoChangeLengthListNotifier notifier(this);
// Now that we know we're inserting, keep animVal list in sync as necessary.

Просмотреть файл

@ -244,6 +244,13 @@ DOMSVGNumberList::InsertItemBefore(DOMSVGNumber& aItem,
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
if (AnimListMirrorsBaseList()) {
if (!mAList->mAnimVal->mItems.SetCapacity(
mAList->mAnimVal->mItems.Length() + 1, fallible)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
}
AutoChangeNumberListNotifier notifier(this);
// Now that we know we're inserting, keep animVal list in sync as necessary.

Просмотреть файл

@ -382,6 +382,15 @@ DOMSVGPathSegList::InsertItemBefore(DOMSVGPathSeg& aNewItem,
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
if (AnimListMirrorsBaseList()) {
DOMSVGPathSegList *animVal =
GetDOMWrapperIfExists(InternalAList().GetAnimValKey());
if (!animVal->mItems.SetCapacity(
animVal->mItems.Length() + 1, fallible)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
}
AutoChangePathSegListNotifier notifier(this);
// Now that we know we're inserting, keep animVal list in sync as necessary.

Просмотреть файл

@ -318,6 +318,15 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
if (AnimListMirrorsBaseList()) {
DOMSVGPointList *animVal =
GetDOMWrapperIfExists(InternalAList().GetAnimValKey());
if (!animVal->mItems.SetCapacity(
animVal->mItems.Length() + 1, fallible)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
}
AutoChangePointListNotifier notifier(this);
// Now that we know we're inserting, keep animVal list in sync as necessary.

Просмотреть файл

@ -252,6 +252,13 @@ DOMSVGTransformList::InsertItemBefore(SVGTransform& newItem,
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
if (AnimListMirrorsBaseList()) {
if (!mAList->mAnimVal->mItems.SetCapacity(
mAList->mAnimVal->mItems.Length() + 1, fallible)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
}
AutoChangeTransformListNotifier notifier(this);
// Now that we know we're inserting, keep animVal list in sync as necessary.