Bug 1448763 part 9 - Remove nsCSSRect. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Thu, 05 Apr 2018 14:37:17 +1000
changeset 777690 81edc14eeb3dc932c668db44c3662b599ab200ca
parent 777689 fc6a807430dbe634ee9b8ef8feddb52ead16bffe
child 777740 49f3892b8c119937b0c1a004b113f26498262ac7
push id105263
push userxquan@mozilla.com
push dateThu, 05 Apr 2018 05:22:06 +0000
reviewersemilio
bugs1448763
milestone61.0a1
Bug 1448763 part 9 - Remove nsCSSRect. r?emilio MozReview-Commit-ID: BOsjszpdKwt
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -149,20 +149,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_Rect == mUnit) {
-    mValue.mRect = aCopy.mValue.mRect;
-    mValue.mRect->AddRef();
-  }
   else if (eCSSUnit_List == mUnit) {
     mValue.mList = aCopy.mValue.mList;
     mValue.mList->AddRef();
   }
   else if (eCSSUnit_ListDep == mUnit) {
     mValue.mListDependent = aCopy.mValue.mListDependent;
   }
   else if (eCSSUnit_SharedList == mUnit) {
@@ -241,19 +237,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_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;
     }
     else if (eCSSUnit_PairList == mUnit) {
       return nsCSSValuePairList::Equal(mValue.mPairList,
@@ -365,18 +358,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_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);
   } else if (eCSSUnit_GridTemplateAreas == mUnit) {
     DO_RELEASE(mGridTemplateAreas);
@@ -518,25 +509,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();
 }
 
-nsCSSRect& nsCSSValue::SetRectValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Rect;
-  mValue.mRect = new nsCSSRect_heap;
-  mValue.mRect->AddRef();
-  return *mValue.mRect;
-}
-
 nsCSSValueList* nsCSSValue::SetListValue()
 {
   Reset();
   mUnit = eCSSUnit_List;
   mValue.mList = new nsCSSValueList_heap;
   mValue.mList->AddRef();
   return mValue.mList;
 }
@@ -878,21 +860,16 @@ nsCSSValue::SizeOfExcludingThis(mozilla:
       n += mValue.mImage->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
     // Pair
     case eCSSUnit_Pair:
       n += mValue.mPair->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
-    // Rect
-    case eCSSUnit_Rect:
-      n += mValue.mRect->SizeOfIncludingThis(aMallocSizeOf);
-      break;
-
     // List
     case eCSSUnit_List:
       n += mValue.mList->SizeOfIncludingThis(aMallocSizeOf);
       break;
 
     // ListDep: not measured because it's non-owning.
     case eCSSUnit_ListDep:
       break;
@@ -1067,71 +1044,16 @@ nsCSSValueSharedList::SizeOfIncludingThi
   size_t n = 0;
   if (mRefCnt <= 1) {
     n += aMallocSizeOf(this);
     n += mHead->SizeOfIncludingThis(aMallocSizeOf);
   }
   return n;
 }
 
-// --- nsCSSRect -----------------
-
-nsCSSRect::nsCSSRect(void)
-{
-  MOZ_COUNT_CTOR(nsCSSRect);
-}
-
-nsCSSRect::nsCSSRect(const nsCSSRect& aCopy)
-  : mTop(aCopy.mTop),
-    mRight(aCopy.mRight),
-    mBottom(aCopy.mBottom),
-    mLeft(aCopy.mLeft)
-{
-  MOZ_COUNT_CTOR(nsCSSRect);
-}
-
-nsCSSRect::~nsCSSRect()
-{
-  MOZ_COUNT_DTOR(nsCSSRect);
-}
-
-void nsCSSRect::SetAllSidesTo(const nsCSSValue& aValue)
-{
-  mTop = aValue;
-  mRight = aValue;
-  mBottom = aValue;
-  mLeft = aValue;
-}
-
-size_t
-nsCSSRect_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 += mTop   .SizeOfExcludingThis(aMallocSizeOf);
-    n += mRight .SizeOfExcludingThis(aMallocSizeOf);
-    n += mBottom.SizeOfExcludingThis(aMallocSizeOf);
-    n += mLeft  .SizeOfExcludingThis(aMallocSizeOf);
-  }
-  return n;
-}
-
-static_assert(eSideTop == 0 && eSideRight == 1 &&
-              eSideBottom == 2 && eSideLeft == 3,
-              "box side constants not top/right/bottom/left == 0/1/2/3");
-
-/* static */ const nsCSSRect::side_type nsCSSRect::sides[4] = {
-  &nsCSSRect::mTop,
-  &nsCSSRect::mRight,
-  &nsCSSRect::mBottom,
-  &nsCSSRect::mLeft,
-};
-
 // --- nsCSSValuePair -----------------
 
 size_t
 nsCSSValuePair::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   size_t n = 0;
   n += mXValue.SizeOfExcludingThis(aMallocSizeOf);
   n += mYValue.SizeOfExcludingThis(aMallocSizeOf);
--- 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_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
                                   //   but does not own the list
@@ -465,18 +464,16 @@ enum nsCSSUnit {
   eCSSUnit_Milliseconds = 3001,    // (float) 1/1000 second
 
   // Flexible fraction (CSS Grid)
   eCSSUnit_FlexFraction = 4000     // (float) Fraction of free space
 };
 
 struct nsCSSValuePair;
 struct nsCSSValuePair_heap;
-struct nsCSSRect;
-struct nsCSSRect_heap;
 struct nsCSSValueList;
 struct nsCSSValueList_heap;
 struct nsCSSValueSharedList;
 struct nsCSSValuePairList;
 struct nsCSSValuePairList_heap;
 
 class nsCSSValue {
 public:
@@ -656,19 +653,16 @@ public:
                  "font family list value should never be null");
     return mozilla::WrapNotNull(mValue.mFontFamilyList);
   }
 
   // bodies of these are below
   inline nsCSSValuePair& GetPairValue();
   inline const nsCSSValuePair& GetPairValue() const;
 
-  inline nsCSSRect& GetRectValue();
-  inline const nsCSSRect& GetRectValue() const;
-
   inline nsCSSValueList* GetListValue();
   inline const nsCSSValueList* GetListValue() const;
 
   inline nsCSSValuePairList* GetPairListValue();
   inline const nsCSSValuePairList* GetPairListValue() const;
 
   mozilla::css::URLValue* GetURLStructValue() const
   {
@@ -764,17 +758,16 @@ public:
 
   // Converts an nsStyleCoord::CalcValue back into a CSSValue
   void SetCalcValue(const nsStyleCoord::CalcValue* aCalc);
 
   nsStyleCoord::CalcValue GetCalcValue() const;
 
   // These are a little different - they allocate storage for you and
   // return a handle.
-  nsCSSRect& SetRectValue();
   nsCSSValueList* SetListValue();
   nsCSSValuePairList* SetPairListValue();
 
   // These take ownership of the passed-in resource.
   void AdoptListValue(mozilla::UniquePtr<nsCSSValueList> aValue);
   void AdoptPairListValue(mozilla::UniquePtr<nsCSSValuePairList> aValue);
 
   void StartImageLoad(nsIDocument* aDocument,
@@ -812,17 +805,16 @@ protected:
     // If we're of a string type, mString is not null.
     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;
     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;
 };
@@ -1009,99 +1001,16 @@ nsCSSValue::GetListValue() const
   if (mUnit == eCSSUnit_List)
     return mValue.mList;
   else {
     MOZ_ASSERT(mUnit == eCSSUnit_ListDep, "not a list value");
     return mValue.mListDependent;
   }
 }
 
-struct nsCSSRect {
-  nsCSSRect(void);
-  nsCSSRect(const nsCSSRect& aCopy);
-  ~nsCSSRect();
-
-  bool operator==(const nsCSSRect& aOther) const {
-    return mTop == aOther.mTop &&
-           mRight == aOther.mRight &&
-           mBottom == aOther.mBottom &&
-           mLeft == aOther.mLeft;
-  }
-
-  bool operator!=(const nsCSSRect& aOther) const {
-    return mTop != aOther.mTop ||
-           mRight != aOther.mRight ||
-           mBottom != aOther.mBottom ||
-           mLeft != aOther.mLeft;
-  }
-
-  void SetAllSidesTo(const nsCSSValue& aValue);
-
-  bool AllSidesEqualTo(const nsCSSValue& aValue) const {
-    return mTop == aValue &&
-           mRight == aValue &&
-           mBottom == aValue &&
-           mLeft == aValue;
-  }
-
-  void Reset() {
-    mTop.Reset();
-    mRight.Reset();
-    mBottom.Reset();
-    mLeft.Reset();
-  }
-
-  bool HasValue() const {
-    return
-      mTop.GetUnit() != eCSSUnit_Null ||
-      mRight.GetUnit() != eCSSUnit_Null ||
-      mBottom.GetUnit() != eCSSUnit_Null ||
-      mLeft.GetUnit() != eCSSUnit_Null;
-  }
-
-  nsCSSValue mTop;
-  nsCSSValue mRight;
-  nsCSSValue mBottom;
-  nsCSSValue mLeft;
-
-  typedef nsCSSValue nsCSSRect::*side_type;
-  static const side_type sides[4];
-};
-
-// nsCSSRect_heap differs from nsCSSRect only in being
-// refcounted.  It should not be necessary to use this class directly;
-// it's an implementation detail of nsCSSValue.
-struct nsCSSRect_heap final : public nsCSSRect {
-  NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap)
-
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-
-private:
-  // Private destructor, to discourage deletion outside of Release():
-  ~nsCSSRect_heap()
-  {
-  }
-};
-
-// This has to be here so that the relationship between nsCSSRect
-// and nsCSSRect_heap is visible.
-inline nsCSSRect&
-nsCSSValue::GetRectValue()
-{
-  MOZ_ASSERT(mUnit == eCSSUnit_Rect, "not a rect value");
-  return *mValue.mRect;
-}
-
-inline const nsCSSRect&
-nsCSSValue::GetRectValue() const
-{
-  MOZ_ASSERT(mUnit == eCSSUnit_Rect, "not a rect value");
-  return *mValue.mRect;
-}
-
 struct nsCSSValuePair {
   nsCSSValuePair()
   {
     MOZ_COUNT_CTOR(nsCSSValuePair);
   }
   explicit nsCSSValuePair(nsCSSUnit aUnit)
     : mXValue(aUnit), mYValue(aUnit)
   {