Bug 1166544 - Surroud FallibleTArray functions that are known to succeed with MOZ_ALWAYS_TRUE in dom/{smil,svg}/. r=dholbert

This commit is contained in:
Birunthan Mohanathas 2015-05-20 16:20:39 +01:00
parent 01b743a06b
commit 59360f960e
8 changed files with 22 additions and 15 deletions

View File

@ -784,22 +784,23 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
return NS_ERROR_FAILURE;
}
// AppendElement() below must succeed, because SetCapacity() succeeded.
if (!to.IsNull()) {
if (!from.IsNull()) {
result.AppendElement(from);
result.AppendElement(to);
MOZ_ALWAYS_TRUE(result.AppendElement(from));
MOZ_ALWAYS_TRUE(result.AppendElement(to));
} else {
result.AppendElement(to);
MOZ_ALWAYS_TRUE(result.AppendElement(to));
}
} else if (!by.IsNull()) {
nsSMILValue effectiveFrom(by.mType);
if (!from.IsNull())
effectiveFrom = from;
// Set values to 'from; from + by'
result.AppendElement(effectiveFrom);
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveFrom));
nsSMILValue effectiveTo(effectiveFrom);
if (!effectiveTo.IsNull() && NS_SUCCEEDED(effectiveTo.Add(by))) {
result.AppendElement(effectiveTo);
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveTo));
} else {
// Using by-animation with non-additive type or bad base-value
return NS_ERROR_FAILURE;

View File

@ -266,7 +266,7 @@ DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGLength());
mItems.InsertElementAt(index, domItem.get());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad

View File

@ -250,7 +250,7 @@ DOMSVGNumberList::InsertItemBefore(DOMSVGNumber& aItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGNumber());
mItems.InsertElementAt(index, domItem);
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad

View File

@ -384,8 +384,12 @@ DOMSVGPathSegList::InsertItemBefore(DOMSVGPathSeg& aNewItem,
float segAsRaw[1 + NS_SVG_PATH_SEG_MAX_ARGS];
domItem->ToSVGPathSegEncodedData(segAsRaw);
InternalList().mData.InsertElementsAt(internalIndex, segAsRaw, 1 + argCount);
mItems.InsertElementAt(aIndex, ItemProxy(domItem.get(), internalIndex));
MOZ_ALWAYS_TRUE(InternalList().mData.InsertElementsAt(internalIndex,
segAsRaw,
1 + argCount));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex,
ItemProxy(domItem.get(),
internalIndex)));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad

View File

@ -317,7 +317,7 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
MaybeInsertNullInAnimValListAt(aIndex);
InternalList().InsertItem(aIndex, domItem->ToSVGPoint());
mItems.InsertElementAt(aIndex, domItem);
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex, domItem));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad

View File

@ -258,7 +258,7 @@ DOMSVGTransformList::InsertItemBefore(SVGTransform& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGTransform());
mItems.InsertElementAt(index, domItem.get());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad

View File

@ -441,8 +441,9 @@ SVGMotionSMILType::Interpolate(const nsSMILValue& aStartVal,
// Construct the intermediate result segment, and put it in our outparam.
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
resultArr.AppendElement(MotionSegment(path, resultDist,
rotateType, rotateAngle));
MOZ_ALWAYS_TRUE(resultArr.AppendElement(MotionSegment(path, resultDist,
rotateType,
rotateAngle)));
return NS_OK;
}
@ -484,7 +485,8 @@ SVGMotionSMILType::ConstructSMILValue(Path* aPath,
MotionSegmentArray& arr = ExtractMotionSegmentArray(smilVal);
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
arr.AppendElement(MotionSegment(aPath, aDist, aRotateType, aRotateAngle));
MOZ_ALWAYS_TRUE(arr.AppendElement(MotionSegment(aPath, aDist,
aRotateType, aRotateAngle)));
return smilVal;
}

View File

@ -342,7 +342,7 @@ SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
for (uint32_t i = 0; i < aList.Length(); ++i) {
// No need to check the return value below since we have already allocated
// the necessary space
transforms.AppendElement(SVGTransformSMILData(aList[i]));
MOZ_ALWAYS_TRUE(transforms.AppendElement(SVGTransformSMILData(aList[i])));
}
return true;
}