Bug 1304632 - Part 2: Remove unnecessary nsStyleImage::mImage null checking. r?bholley draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 15 Aug 2016 09:57:13 +0800
changeset 416443 533d9170ccbe92f59161ab3dea132496fe68b54e
parent 416442 00e9a0bc27dae6ad94721771dd5ab1149f7493fb
child 531861 d8034359f62691a9db7c6e47105a28cab4aa2e22
push id30150
push userbmo:cam@mcc.id.au
push dateThu, 22 Sep 2016 07:18:57 +0000
reviewersbholley
bugs1304632
milestone51.0a1
Bug 1304632 - Part 2: Remove unnecessary nsStyleImage::mImage null checking. r?bholley nsStyleImage::mImage is always set to a non-null object when its mType is eStyleImageType_Image, so let's just assert that and stop null checking in that case. MozReview-Commit-ID: 2ect4coV0LV
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2190,17 +2190,17 @@ nsStyleImage::ComputeActualCropRect(nsIn
     *aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
   }
   return true;
 }
 
 nsresult
 nsStyleImage::StartDecoding() const
 {
-  if ((mType == eStyleImageType_Image) && mImage) {
+  if (mType == eStyleImageType_Image) {
     return mImage->StartDecoding();
   }
   return NS_OK;
 }
 
 bool
 nsStyleImage::IsOpaque() const
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -359,16 +359,17 @@ struct nsStyleImage
   void SetElementId(const char16_t* aElementId);
   void SetCropRect(mozilla::UniquePtr<nsStyleSides> aCropRect);
 
   nsStyleImageType GetType() const {
     return mType;
   }
   imgRequestProxy* GetImageData() const {
     MOZ_ASSERT(mType == eStyleImageType_Image, "Data is not an image!");
+    MOZ_ASSERT(mImage);
     MOZ_ASSERT(mImageTracked,
                "Should be tracking any image we're going to use!");
     return mImage;
   }
   nsStyleGradient* GetGradientData() const {
     NS_ASSERTION(mType == eStyleImageType_Gradient, "Data is not a gradient!");
     return mGradient;
   }