зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1179282 - Use nsTArray::Assign instead of the assignment operator in dom/svg/. r=dholbert
This commit is contained in:
Родитель
30fedff9e1
Коммит
0136850d8b
|
@ -18,11 +18,9 @@ namespace mozilla {
|
|||
nsresult
|
||||
SVGLengthList::CopyFrom(const SVGLengthList& rhs)
|
||||
{
|
||||
if (!mLengths.SetCapacity(rhs.Length(), fallible)) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mLengths.Assign(rhs.mLengths, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mLengths = rhs.mLengths;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,13 +197,10 @@ SVGMotionSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
|
|||
|
||||
const MotionSegmentArray& srcArr = ExtractMotionSegmentArray(aSrc);
|
||||
MotionSegmentArray& dstArr = ExtractMotionSegmentArray(aDest);
|
||||
|
||||
// Ensure we have sufficient memory.
|
||||
if (!dstArr.SetCapacity(srcArr.Length(), fallible)) {
|
||||
if (!dstArr.Assign(srcArr, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
dstArr = srcArr; // Do the assignment.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,9 @@ namespace mozilla {
|
|||
nsresult
|
||||
SVGNumberList::CopyFrom(const SVGNumberList& rhs)
|
||||
{
|
||||
if (!mNumbers.SetCapacity(rhs.Length(), fallible)) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mNumbers.Assign(rhs.mNumbers, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mNumbers = rhs.mNumbers;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,9 @@ static bool IsMoveto(uint16_t aSegType)
|
|||
nsresult
|
||||
SVGPathData::CopyFrom(const SVGPathData& rhs)
|
||||
{
|
||||
if (!mData.SetCapacity(rhs.mData.Length(), fallible)) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mData.Assign(rhs.mData, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mData = rhs.mData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,9 @@ namespace mozilla {
|
|||
nsresult
|
||||
SVGPointList::CopyFrom(const SVGPointList& rhs)
|
||||
{
|
||||
if (!SetCapacity(rhs.Length())) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mItems.Assign(rhs.mItems, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mItems = rhs.mItems;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,9 @@ namespace mozilla {
|
|||
nsresult
|
||||
SVGStringList::CopyFrom(const SVGStringList& rhs)
|
||||
{
|
||||
if (!mStrings.SetCapacity(rhs.Length(), fallible)) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mStrings.Assign(rhs.mStrings, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mStrings = rhs.mStrings;
|
||||
mIsSet = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -43,11 +43,9 @@ SVGTransformList::CopyFrom(const SVGTransformList& rhs)
|
|||
nsresult
|
||||
SVGTransformList::CopyFrom(const nsTArray<nsSVGTransform>& aTransformArray)
|
||||
{
|
||||
if (!mItems.SetCapacity(aTransformArray.Length(), fallible)) {
|
||||
// Yes, we do want fallible alloc here
|
||||
if (!mItems.Assign(aTransformArray, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mItems = aTransformArray;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,12 +48,9 @@ SVGTransformListSMILType::Assign(nsSMILValue& aDest,
|
|||
const TransformArray* srcTransforms =
|
||||
static_cast<const TransformArray*>(aSrc.mU.mPtr);
|
||||
TransformArray* dstTransforms = static_cast<TransformArray*>(aDest.mU.mPtr);
|
||||
|
||||
// Before we assign, ensure we have sufficient memory
|
||||
bool result = dstTransforms->SetCapacity(srcTransforms->Length(), fallible);
|
||||
NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*dstTransforms = *srcTransforms;
|
||||
if (!dstTransforms->Assign(*srcTransforms, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче