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
parent cc78dd2bcf
commit 9e27700875
5 changed files with 39 additions and 0 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.