Backed out changeset acf56d9e08c5 (bug 1285320) for conflicting with merge from m-c to mozilla-inbound
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 29 Jul 2016 12:33:14 +0200
changeset 332335 bff4f9be49619c6d224f716cfbb9c258424c5983
parent 332334 b3cd11b98793db8a9222f76b849068b96c66392d
child 332336 674c51af1dcc31a139b792ebef9ebcd509f87ed3
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1285320
milestone50.0a1
backs outacf56d9e08c5e44278e62c28ad1ac8c198718d53
Backed out changeset acf56d9e08c5 (bug 1285320) for conflicting with merge from m-c to mozilla-inbound
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/nsStyleStructInlines.h
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1905,40 +1905,16 @@ nsStyleGradient::HasCalc()
       return true;
     }
   }
   return mBgPosX.IsCalcUnit() || mBgPosY.IsCalcUnit() || mAngle.IsCalcUnit() ||
          mRadiusX.IsCalcUnit() || mRadiusY.IsCalcUnit();
 }
 
 // --------------------
-// CachedBorderImageData
-//
-void
-CachedBorderImageData::PurgeCachedImages()
-{
-  mSubImages.Clear();
-}
-
-void
-CachedBorderImageData::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage)
-{
-  mSubImages.ReplaceObjectAt(aSubImage, aIndex);
-}
-
-imgIContainer*
-CachedBorderImageData::GetSubImage(uint8_t aIndex)
-{
-  imgIContainer* subImage = nullptr;
-  if (aIndex < mSubImages.Count())
-    subImage = mSubImages[aIndex];
-  return subImage;
-}
-
-// --------------------
 // nsStyleImage
 //
 
 nsStyleImage::nsStyleImage()
   : mType(eStyleImageType_Null)
   , mCropRect(nullptr)
 #ifdef DEBUG
   , mImageTracked(false)
@@ -2023,19 +1999,17 @@ nsStyleImage::SetImageData(imgRequestPro
   if (mType != eStyleImageType_Null) {
     SetNull();
   }
 
   if (aImage) {
     mImage = aImage;
     mType = eStyleImageType_Image;
   }
-  if (mCachedBIData) {
-    mCachedBIData->PurgeCachedImages();
-  }
+  mSubImages.Clear();
 }
 
 void
 nsStyleImage::TrackImage(nsPresContext* aContext)
 {
   // Sanity
   MOZ_ASSERT(!mImageTracked, "Already tracking image!");
   MOZ_ASSERT(mType == eStyleImageType_Image,
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -13,17 +13,16 @@
 #define nsStyleStruct_h___
 
 #include "mozilla/ArenaObjectID.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CSSVariableValues.h"
 #include "mozilla/SheetType.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/StyleStructContext.h"
-#include "mozilla/UniquePtr.h"
 #include "nsAutoPtr.h"
 #include "nsColor.h"
 #include "nsCoord.h"
 #include "nsMargin.h"
 #include "nsFont.h"
 #include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsChangeHint.h"
@@ -242,26 +241,16 @@ private:
 
 enum nsStyleImageType {
   eStyleImageType_Null,
   eStyleImageType_Image,
   eStyleImageType_Gradient,
   eStyleImageType_Element
 };
 
-struct CachedBorderImageData
-{
-  void PurgeCachedImages();
-  void SetSubImage(uint8_t aIndex, imgIContainer* aSubImage);
-  imgIContainer* GetSubImage(uint8_t aIndex);
-
-private:
-  nsCOMArray<imgIContainer> mSubImages;
-};
-
 /**
  * Represents a paintable image of one of the following types.
  * (1) A real image loaded from an external source.
  * (2) A CSS linear or radial gradient.
  * (3) An element within a document, or an <img>, <video>, or <canvas> element
  *     not in a document.
  * (*) Optionally a crop rect can be set to paint a partial (rectangular)
  * region of an image. (Currently, this feature is only supported with an
@@ -367,21 +356,19 @@ struct nsStyleImage
 
   // These methods are used for the caller to caches the sub images created
   // during a border-image paint operation
   inline void SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const;
   inline imgIContainer* GetSubImage(uint8_t aIndex) const;
 
 private:
   void DoCopy(const nsStyleImage& aOther);
-  void EnsureCachedBIData() const;
-
-  // This variable keeps some cache data for border image and is lazily
-  // allocated since it is only used in border image case.
-  mozilla::UniquePtr<CachedBorderImageData> mCachedBIData;
+
+  // Cache for border-image painting.
+  nsCOMArray<imgIContainer> mSubImages;
 
   nsStyleImageType mType;
   union {
     imgRequestProxy* mImage;
     nsStyleGradient* mGradient;
     char16_t* mElementId;
   };
 
--- a/layout/style/nsStyleStructInlines.h
+++ b/layout/style/nsStyleStructInlines.h
@@ -12,35 +12,28 @@
 #define nsStyleStructInlines_h_
 
 #include "nsIFrame.h"
 #include "nsStyleStruct.h"
 #include "nsIContent.h" // for GetParent()
 #include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak
 
 inline void
-nsStyleImage::EnsureCachedBIData() const
-{
-  if (!mCachedBIData) {
-    const_cast<nsStyleImage*>(this)->mCachedBIData =
-      mozilla::MakeUnique<CachedBorderImageData>();
-  }
-}
-
-inline void
 nsStyleImage::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const
 {
-  EnsureCachedBIData();
-  mCachedBIData->SetSubImage(aIndex, aSubImage);
+  const_cast<nsStyleImage*>(this)->mSubImages.ReplaceObjectAt(aSubImage, aIndex);
 }
 
 inline imgIContainer*
 nsStyleImage::GetSubImage(uint8_t aIndex) const
 {
-  return (mCachedBIData) ? mCachedBIData->GetSubImage(aIndex) : nullptr;
+  imgIContainer* subImage = nullptr;
+  if (aIndex < mSubImages.Count())
+    subImage = mSubImages[aIndex];
+  return subImage;
 }
 
 bool
 nsStyleText::HasTextShadow() const
 {
   return mTextShadow;
 }