Bug 1288797 - Replace nsAutoPtr with UniquePtr in nsStyleStruct.h (for variable "mCropRect"). Changes after review. r?dholbert
MozReview-Commit-ID: DxBHK6ZOVz4
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -2083,17 +2083,17 @@ nsComputedDOMStyle::SetValueToStyleImage
{
switch (aStyleImage.GetType()) {
case eStyleImageType_Image:
{
imgIRequest *req = aStyleImage.GetImageData();
nsCOMPtr<nsIURI> uri;
req->GetURI(getter_AddRefs(uri));
- const mozilla::UniquePtr<nsStyleSides>& cropRect = aStyleImage.GetCropRect();
+ const UniquePtr<nsStyleSides>& cropRect = aStyleImage.GetCropRect();
if (cropRect) {
nsAutoString imageRectString;
GetImageRectString(uri, *cropRect, imageRectString);
aValue->SetString(imageRectString);
} else {
aValue->SetURI(uri);
}
break;
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1962,18 +1962,17 @@ nsStyleImage::DoCopy(const nsStyleImage&
if (aOther.mType == eStyleImageType_Image) {
SetImageData(aOther.mImage);
} else if (aOther.mType == eStyleImageType_Gradient) {
SetGradientData(aOther.mGradient);
} else if (aOther.mType == eStyleImageType_Element) {
SetElementId(aOther.mElementId);
}
- nsStyleSides* copyOfCropRect = new nsStyleSides(*(aOther.mCropRect.get()));
- SetCropRect(MakeUnique<nsStyleSides>(*copyOfCropRect));
+ SetCropRect(MakeUnique<nsStyleSides>(*aOther.mCropRect.get()));
}
void
nsStyleImage::SetNull()
{
MOZ_ASSERT(!mImageTracked,
"Calling SetNull() with image tracked!");
@@ -2074,23 +2073,19 @@ nsStyleImage::SetElementId(const char16_
if (aElementId) {
mElementId = NS_strdup(aElementId);
mType = eStyleImageType_Element;
}
}
void
-nsStyleImage::SetCropRect(mozilla::UniquePtr<nsStyleSides> aCropRect)
+nsStyleImage::SetCropRect(UniquePtr<nsStyleSides> aCropRect)
{
- if (aCropRect) {
mCropRect = Move(aCropRect);
- } else {
- mCropRect = nullptr;
- }
}
static int32_t
ConvertToPixelCoord(const nsStyleCoord& aCoord, int32_t aPercentScale)
{
double pixelValue;
switch (aCoord.GetUnit()) {
case eStyleUnit_Percent:
@@ -2232,30 +2227,30 @@ nsStyleImage::IsLoaded() const
}
default:
NS_NOTREACHED("unexpected image type");
return false;
}
}
static inline bool
-EqualRects(const nsStyleSides* aRect1, const nsStyleSides* aRect2)
+EqualRects(const UniquePtr<nsStyleSides>& aRect1, const UniquePtr<nsStyleSides>& aRect2)
{
return aRect1 == aRect2 || /* handles null== null, and optimize */
(aRect1 && aRect2 && *aRect1 == *aRect2);
}
bool
nsStyleImage::operator==(const nsStyleImage& aOther) const
{
if (mType != aOther.mType) {
return false;
}
- if (!EqualRects(mCropRect.get(), aOther.mCropRect.get())) {
+ if (!EqualRects(mCropRect, aOther.mCropRect) ) {
return false;
}
if (mType == eStyleImageType_Image) {
return EqualImages(mImage, aOther.mImage);
}
if (mType == eStyleImageType_Gradient) {