Bug 1448763 part 6 - Remove nsCSSValueTriplet. r=emilio
authorXidorn Quan <me@upsuper.org>
Thu, 05 Apr 2018 18:27:33 +1000
changeset 465415 e56285e2657c40d60322b3d4ea7638c3a0308210
parent 465414 1754cae1e273f31fece9ce58d4a13890c012f5f1
child 465416 f43518ccb6f90d43b95ddab982543dcd708af8c8
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1448763
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1448763 part 6 - Remove nsCSSValueTriplet. r=emilio MozReview-Commit-ID: 29GtK1gtreU
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -150,20 +150,16 @@ nsCSSValue::nsCSSValue(const nsCSSValue&
   else if (eCSSUnit_Image == mUnit) {
     mValue.mImage = aCopy.mValue.mImage;
     mValue.mImage->AddRef();
   }
   else if (eCSSUnit_Pair == mUnit) {
     mValue.mPair = aCopy.mValue.mPair;
     mValue.mPair->AddRef();
   }
-  else if (eCSSUnit_Triplet == mUnit) {
-    mValue.mTriplet = aCopy.mValue.mTriplet;
-    mValue.mTriplet->AddRef();
-  }
   else if (eCSSUnit_Rect == mUnit) {
     mValue.mRect = aCopy.mValue.mRect;
     mValue.mRect->AddRef();
   }
   else if (eCSSUnit_List == mUnit) {
     mValue.mList = aCopy.mValue.mList;
     mValue.mList->AddRef();
   }
@@ -246,19 +242,16 @@ bool nsCSSValue::operator==(const nsCSSV
       return mValue.mURL->Equals(*aOther.mValue.mURL);
     }
     else if (eCSSUnit_Image == mUnit) {
       return mValue.mImage->Equals(*aOther.mValue.mImage);
     }
     else if (eCSSUnit_Pair == mUnit) {
       return *mValue.mPair == *aOther.mValue.mPair;
     }
-    else if (eCSSUnit_Triplet == mUnit) {
-      return *mValue.mTriplet == *aOther.mValue.mTriplet;
-    }
     else if (eCSSUnit_Rect == mUnit) {
       return *mValue.mRect == *aOther.mValue.mRect;
     }
     else if (eCSSUnit_List == mUnit) {
       return nsCSSValueList::Equal(mValue.mList, aOther.mValue.mList);
     }
     else if (eCSSUnit_SharedList == mUnit) {
       return *mValue.mSharedList == *aOther.mValue.mSharedList;
@@ -373,18 +366,16 @@ void nsCSSValue::DoReset()
   } else if (UnitHasArrayValue()) {
     DO_RELEASE(mArray);
   } else if (eCSSUnit_URL == mUnit) {
     DO_RELEASE(mURL);
   } else if (eCSSUnit_Image == mUnit) {
     DO_RELEASE(mImage);
   } else if (eCSSUnit_Pair == mUnit) {
     DO_RELEASE(mPair);
-  } else if (eCSSUnit_Triplet == mUnit) {
-    DO_RELEASE(mTriplet);
   } else if (eCSSUnit_Rect == mUnit) {
     DO_RELEASE(mRect);
   } else if (eCSSUnit_List == mUnit) {
     DO_RELEASE(mList);
   } else if (eCSSUnit_SharedList == mUnit) {
     DO_RELEASE(mSharedList);
   } else if (eCSSUnit_PairList == mUnit) {
     DO_RELEASE(mPairList);
@@ -528,62 +519,16 @@ void nsCSSValue::SetPairValue(const nsCS
              yValue.GetUnit() != eCSSUnit_Unset,
              "inappropriate pair value");
   Reset();
   mUnit = eCSSUnit_Pair;
   mValue.mPair = new nsCSSValuePair_heap(xValue, yValue);
   mValue.mPair->AddRef();
 }
 
-void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
-{
-  // triplet should not be used for null/inherit/initial values
-  MOZ_ASSERT(aValue &&
-             aValue->mXValue.GetUnit() != eCSSUnit_Null &&
-             aValue->mYValue.GetUnit() != eCSSUnit_Null &&
-             aValue->mZValue.GetUnit() != eCSSUnit_Null &&
-             aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
-             aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
-             aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
-             aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
-             aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
-             aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
-             aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
-             aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
-             aValue->mZValue.GetUnit() != eCSSUnit_Unset,
-             "missing or inappropriate triplet value");
-  Reset();
-  mUnit = eCSSUnit_Triplet;
-  mValue.mTriplet = new nsCSSValueTriplet_heap(aValue->mXValue, aValue->mYValue, aValue->mZValue);
-  mValue.mTriplet->AddRef();
-}
-
-void nsCSSValue::SetTripletValue(const nsCSSValue& xValue,
-                                 const nsCSSValue& yValue,
-                                 const nsCSSValue& zValue)
-{
-  // Only allow Null for the z component
-  MOZ_ASSERT(xValue.GetUnit() != eCSSUnit_Null &&
-             yValue.GetUnit() != eCSSUnit_Null &&
-             xValue.GetUnit() != eCSSUnit_Inherit &&
-             yValue.GetUnit() != eCSSUnit_Inherit &&
-             zValue.GetUnit() != eCSSUnit_Inherit &&
-             xValue.GetUnit() != eCSSUnit_Initial &&
-             yValue.GetUnit() != eCSSUnit_Initial &&
-             zValue.GetUnit() != eCSSUnit_Initial &&
-             xValue.GetUnit() != eCSSUnit_Unset &&
-             yValue.GetUnit() != eCSSUnit_Unset &&
-             zValue.GetUnit() != eCSSUnit_Unset,
-             "inappropriate triplet value");
-  Reset();
-  mUnit = eCSSUnit_Triplet;
-  mValue.mTriplet = new nsCSSValueTriplet_heap(xValue, yValue, zValue);
-  mValue.mTriplet->AddRef();
-}
-
 nsCSSRect& nsCSSValue::SetRectValue()
 {
   Reset();
   mUnit = eCSSUnit_Rect;
   mValue.mRect = new nsCSSRect_heap;
   mValue.mRect->AddRef();
   return *mValue.mRect;
 }
@@ -934,21 +879,16 @@ nsCSSValue::SizeOfExcludingThis(mozilla:
       n += mValue.mImage->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
     // Pair
     case eCSSUnit_Pair:
       n += mValue.mPair->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
-    // Triplet
-    case eCSSUnit_Triplet:
-      n += mValue.mTriplet->SizeOfIncludingThis(aMallocSizeOf);
-      break;
-
     // Rect
     case eCSSUnit_Rect:
       n += mValue.mRect->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
     // List
     case eCSSUnit_List:
       n += mValue.mList->SizeOfIncludingThis(aMallocSizeOf);
@@ -1207,32 +1147,16 @@ nsCSSValuePair_heap::SizeOfIncludingThis
   if (mRefCnt <= 1) {
     n += aMallocSizeOf(this);
     n += mXValue.SizeOfExcludingThis(aMallocSizeOf);
     n += mYValue.SizeOfExcludingThis(aMallocSizeOf);
   }
   return n;
 }
 
-// --- nsCSSValueTriplet -----------------
-
-size_t
-nsCSSValueTriplet_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
-{
-  // Only measure it if it's unshared, to avoid double-counting.
-  size_t n = 0;
-  if (mRefCnt <= 1) {
-    n += aMallocSizeOf(this);
-    n += mXValue.SizeOfExcludingThis(aMallocSizeOf);
-    n += mYValue.SizeOfExcludingThis(aMallocSizeOf);
-    n += mZValue.SizeOfExcludingThis(aMallocSizeOf);
-  }
-  return n;
-}
-
 // --- nsCSSValuePairList -----------------
 
 nsCSSValuePairList::~nsCSSValuePairList()
 {
   MOZ_COUNT_DTOR(nsCSSValuePairList);
   NS_CSS_DELETE_LIST_MEMBER(nsCSSValuePairList, this, mNext);
 }
 
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -402,17 +402,16 @@ enum nsCSSUnit {
   eCSSUnit_Calc_Divided = 35,     // (nsCSSValue::Array*) / within calc
 
   eCSSUnit_URL          = 40,     // (nsCSSValue::URL*) value
   eCSSUnit_Image        = 41,     // (nsCSSValue::Image*) value
   eCSSUnit_GridTemplateAreas   = 44,   // (GridTemplateAreasValue*)
                                        // for grid-template-areas
 
   eCSSUnit_Pair         = 50,     // (nsCSSValuePair*) pair of values
-  eCSSUnit_Triplet      = 51,     // (nsCSSValueTriplet*) triplet of values
   eCSSUnit_Rect         = 52,     // (nsCSSRect*) rectangle (four values)
   eCSSUnit_List         = 53,     // (nsCSSValueList*) list of values
   eCSSUnit_ListDep      = 54,     // (nsCSSValueList*) same as List
                                   //   but does not own the list
   eCSSUnit_SharedList   = 55,     // (nsCSSValueSharedList*) same as list
                                   //   but reference counted and shared
   eCSSUnit_PairList     = 56,     // (nsCSSValuePairList*) list of value pairs
   eCSSUnit_PairListDep  = 57,     // (nsCSSValuePairList*) same as PairList
@@ -473,18 +472,16 @@ struct nsCSSValuePair;
 struct nsCSSValuePair_heap;
 struct nsCSSRect;
 struct nsCSSRect_heap;
 struct nsCSSValueList;
 struct nsCSSValueList_heap;
 struct nsCSSValueSharedList;
 struct nsCSSValuePairList;
 struct nsCSSValuePairList_heap;
-struct nsCSSValueTriplet;
-struct nsCSSValueTriplet_heap;
 
 class nsCSSValue {
 public:
   struct Array;
   friend struct Array;
 
   friend struct mozilla::css::URLValueData;
 
@@ -668,20 +665,16 @@ public:
   inline const nsCSSRect& GetRectValue() const;
 
   inline nsCSSValueList* GetListValue();
   inline const nsCSSValueList* GetListValue() const;
 
   inline nsCSSValuePairList* GetPairListValue();
   inline const nsCSSValuePairList* GetPairListValue() const;
 
-  inline nsCSSValueTriplet& GetTripletValue();
-  inline const nsCSSValueTriplet& GetTripletValue() const;
-
-
   mozilla::css::URLValue* GetURLStructValue() const
   {
     // Not allowing this for Image values, because if the caller takes
     // a ref to them they won't be able to delete them properly.
     MOZ_ASSERT(mUnit == eCSSUnit_URL, "not a URL value");
     return mValue.mURL;
   }
 
@@ -753,18 +746,16 @@ public:
   void SetImageValue(mozilla::css::ImageValue* aImage);
   void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
   void SetFontFamilyListValue(already_AddRefed<mozilla::SharedFontList> aFontListValue);
   void SetPairValue(const nsCSSValuePair* aPair);
   void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
   void SetSharedListValue(nsCSSValueSharedList* aList);
   void SetDependentListValue(nsCSSValueList* aList);
   void SetDependentPairListValue(nsCSSValuePairList* aList);
-  void SetTripletValue(const nsCSSValueTriplet* aTriplet);
-  void SetTripletValue(const nsCSSValue& xValue, const nsCSSValue& yValue, const nsCSSValue& zValue);
   void SetAutoValue();
   void SetInheritValue();
   void SetInitialValue();
   void SetUnsetValue();
   void SetNoneValue();
   void SetAllValue();
   void SetNormalValue();
   void SetSystemFontValue();
@@ -822,17 +813,16 @@ protected:
     nsStringBuffer* MOZ_OWNING_REF mString;
     nsAtom* MOZ_OWNING_REF mAtom;
     Array* MOZ_OWNING_REF mArray;
     mozilla::css::URLValue* MOZ_OWNING_REF mURL;
     mozilla::css::ImageValue* MOZ_OWNING_REF mImage;
     mozilla::css::GridTemplateAreasValue* MOZ_OWNING_REF mGridTemplateAreas;
     nsCSSValuePair_heap* MOZ_OWNING_REF mPair;
     nsCSSRect_heap* MOZ_OWNING_REF mRect;
-    nsCSSValueTriplet_heap* MOZ_OWNING_REF mTriplet;
     nsCSSValueList_heap* MOZ_OWNING_REF mList;
     nsCSSValueList* mListDependent;
     nsCSSValueSharedList* MOZ_OWNING_REF mSharedList;
     nsCSSValuePairList_heap* MOZ_OWNING_REF mPairList;
     nsCSSValuePairList* mPairListDependent;
     mozilla::SharedFontList* MOZ_OWNING_REF mFontFamilyList;
   } mValue;
 };
@@ -1189,134 +1179,32 @@ struct nsCSSValuePair_heap final : publi
 
 private:
   // Private destructor, to discourage deletion outside of Release():
   ~nsCSSValuePair_heap()
   {
   }
 };
 
-struct nsCSSValueTriplet {
-    nsCSSValueTriplet()
-    {
-        MOZ_COUNT_CTOR(nsCSSValueTriplet);
-    }
-    explicit nsCSSValueTriplet(nsCSSUnit aUnit)
-        : mXValue(aUnit), mYValue(aUnit), mZValue(aUnit)
-    {
-        MOZ_COUNT_CTOR(nsCSSValueTriplet);
-    }
-    nsCSSValueTriplet(const nsCSSValue& aXValue,
-                      const nsCSSValue& aYValue,
-                      const nsCSSValue& aZValue)
-        : mXValue(aXValue), mYValue(aYValue), mZValue(aZValue)
-    {
-        MOZ_COUNT_CTOR(nsCSSValueTriplet);
-    }
-    nsCSSValueTriplet(const nsCSSValueTriplet& aCopy)
-        : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mZValue(aCopy.mZValue)
-    {
-        MOZ_COUNT_CTOR(nsCSSValueTriplet);
-    }
-    ~nsCSSValueTriplet()
-    {
-        MOZ_COUNT_DTOR(nsCSSValueTriplet);
-    }
-
-    bool operator==(const nsCSSValueTriplet& aOther) const {
-        return mXValue == aOther.mXValue &&
-               mYValue == aOther.mYValue &&
-               mZValue == aOther.mZValue;
-    }
-
-    bool operator!=(const nsCSSValueTriplet& aOther) const {
-        return mXValue != aOther.mXValue ||
-               mYValue != aOther.mYValue ||
-               mZValue != aOther.mZValue;
-    }
-
-    bool AllValuesEqualTo(const nsCSSValue& aValue) const {
-        return mXValue == aValue &&
-               mYValue == aValue &&
-               mZValue == aValue;
-    }
-
-    void SetAllValuesTo(const nsCSSValue& aValue) {
-        mXValue = aValue;
-        mYValue = aValue;
-        mZValue = aValue;
-    }
-
-    void Reset() {
-        mXValue.Reset();
-        mYValue.Reset();
-        mZValue.Reset();
-    }
-
-    bool HasValue() const {
-        return mXValue.GetUnit() != eCSSUnit_Null ||
-               mYValue.GetUnit() != eCSSUnit_Null ||
-               mZValue.GetUnit() != eCSSUnit_Null;
-    }
-
-    nsCSSValue mXValue;
-    nsCSSValue mYValue;
-    nsCSSValue mZValue;
-};
-
-// nsCSSValueTriplet_heap differs from nsCSSValueTriplet only in being
-// refcounted.  It should not be necessary to use this class directly;
-// it's an implementation detail of nsCSSValue.
-struct nsCSSValueTriplet_heap final : public nsCSSValueTriplet {
-  // forward constructor
-  nsCSSValueTriplet_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue, const nsCSSValue& aZValue)
-    : nsCSSValueTriplet(aXValue, aYValue, aZValue)
-  {}
-
-  NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap)
-
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-
-private:
-  // Private destructor, to discourage deletion outside of Release():
-  ~nsCSSValueTriplet_heap()
-  {
-  }
-};
-
 // This has to be here so that the relationship between nsCSSValuePair
 // and nsCSSValuePair_heap is visible.
 inline nsCSSValuePair&
 nsCSSValue::GetPairValue()
 {
   MOZ_ASSERT(mUnit == eCSSUnit_Pair, "not a pair value");
   return *mValue.mPair;
 }
 
 inline const nsCSSValuePair&
 nsCSSValue::GetPairValue() const
 {
   MOZ_ASSERT(mUnit == eCSSUnit_Pair, "not a pair value");
   return *mValue.mPair;
 }
 
-inline nsCSSValueTriplet&
-nsCSSValue::GetTripletValue()
-{
-    MOZ_ASSERT(mUnit == eCSSUnit_Triplet, "not a triplet value");
-    return *mValue.mTriplet;
-}
-
-inline const nsCSSValueTriplet&
-nsCSSValue::GetTripletValue() const
-{
-    MOZ_ASSERT(mUnit == eCSSUnit_Triplet, "not a triplet value");
-    return *mValue.mTriplet;
-}
-
 // Maybe should be replaced with nsCSSValueList and nsCSSValue::Array?
 struct nsCSSValuePairList {
   nsCSSValuePairList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValuePairList); }
   ~nsCSSValuePairList();
 
   nsCSSValuePairList* Clone() const; // makes a deep copy. Infallible.
 
   static bool Equal(const nsCSSValuePairList* aList1,