Bug 1288797 - Replace nsAutoPtr with UniquePtr in nsStyleStruct.h (for variable "mCropRect"). Changes after review. r?dholbert draft
authorNeerja Pancholi <npancholi@mozilla.com>
Thu, 28 Jul 2016 15:06:02 -0700
changeset 393948 6eb1aab76ecfc6ae947f36dee689ffe79502f862
parent 393922 493e26d97704b53163c8adfc85290d6c535c18bf
child 526711 68da2e39c4cdf781a9446e2fa3b5b99494042482
push id24459
push userbmo:npancholi@mozilla.com
push dateThu, 28 Jul 2016 22:06:53 +0000
reviewersdholbert
bugs1288797
milestone50.0a1
Bug 1288797 - Replace nsAutoPtr with UniquePtr in nsStyleStruct.h (for variable "mCropRect"). Changes after review. r?dholbert MozReview-Commit-ID: DxBHK6ZOVz4
layout/style/nsComputedDOMStyle.cpp
layout/style/nsStyleStruct.cpp
--- 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) {