Bug 1264787: Make nsCSSValue's AdoptListValue & AdoptPairListValue methods take a UniquePtr. r=heycam

MozReview-Commit-ID: 94aYEtySHsW
This commit is contained in:
Daniel Holbert 2016-04-20 10:37:06 -07:00
Родитель 85ba14a3e5
Коммит ed653d2220
3 изменённых файлов: 11 добавлений и 12 удалений

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

@ -1971,7 +1971,7 @@ AddShapeFunction(nsCSSProperty aProperty,
if (!resultPoints) {
return nullptr;
}
resultFuncArgs->Item(2).AdoptPairListValue(resultPoints.release());
resultFuncArgs->Item(2).AdoptPairListValue(Move(resultPoints));
break;
}
case eCSSKeyword_inset: {
@ -3096,7 +3096,7 @@ StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
UniquePtr<nsCSSValueList> computedList =
aComputedValue.TakeCSSValueListValue();
if (computedList) {
aSpecifiedValue.AdoptListValue(computedList.release());
aSpecifiedValue.AdoptListValue(Move(computedList));
} else {
aSpecifiedValue.SetNoneValue();
}
@ -3107,7 +3107,7 @@ StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
UniquePtr<nsCSSValuePairList> computedList =
aComputedValue.TakeCSSValuePairListValue();
MOZ_ASSERT(computedList, "Pair list should never be null");
aSpecifiedValue.AdoptPairListValue(computedList.release());
aSpecifiedValue.AdoptPairListValue(Move(computedList));
}
break;
default:

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

@ -622,7 +622,7 @@ void nsCSSValue::SetDependentListValue(nsCSSValueList* aList)
}
void
nsCSSValue::AdoptListValue(nsCSSValueList*&& aValue)
nsCSSValue::AdoptListValue(UniquePtr<nsCSSValueList> aValue)
{
// We have to copy the first element since for owned lists the first
// element should be an nsCSSValueList_heap object.
@ -632,8 +632,7 @@ nsCSSValue::AdoptListValue(nsCSSValueList*&& aValue)
mValue.mList->mValue = aValue->mValue;
mValue.mList->mNext = aValue->mNext;
aValue->mNext = nullptr;
delete aValue;
aValue = nullptr;
aValue.reset();
}
nsCSSValuePairList* nsCSSValue::SetPairListValue()
@ -655,9 +654,9 @@ void nsCSSValue::SetDependentPairListValue(nsCSSValuePairList* aList)
}
void
nsCSSValue::AdoptPairListValue(nsCSSValuePairList*&& aValue)
nsCSSValue::AdoptPairListValue(UniquePtr<nsCSSValuePairList> aValue)
{
// We have to copy the first element since for owned pair lists the first
// We have to copy the first element, since for owned pair lists, the first
// element should be an nsCSSValuePairList_heap object.
SetPairListValue();
// FIXME: If nsCSSValue gets a swap method or move assignment operator,
@ -666,8 +665,7 @@ nsCSSValue::AdoptPairListValue(nsCSSValuePairList*&& aValue)
mValue.mPairList->mYValue = aValue->mYValue;
mValue.mPairList->mNext = aValue->mNext;
aValue->mNext = nullptr;
delete aValue;
aValue = nullptr;
aValue.reset();
}
void nsCSSValue::SetAutoValue()

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

@ -11,6 +11,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/SheetType.h"
#include "mozilla/UniquePtr.h"
#include "nsIPrincipal.h"
#include "nsIURI.h"
@ -719,8 +720,8 @@ public:
nsCSSValuePairList* SetPairListValue();
// These take ownership of the passed-in resource.
void AdoptListValue(nsCSSValueList*&& aValue);
void AdoptPairListValue(nsCSSValuePairList*&& aValue);
void AdoptListValue(mozilla::UniquePtr<nsCSSValueList> aValue);
void AdoptPairListValue(mozilla::UniquePtr<nsCSSValuePairList> aValue);
void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const