Bug 1496486 - Remove a bunch of unused nsCSSValue code. r=heycam
☠☠ backed out by be1729663405 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 03 Oct 2018 17:49:53 +0200
changeset 488603 ab92ed3e0a2369a5a1764ba8e496e8f186fdbcd1
parent 488602 0db994314ad3fe2a9cd2478ef0df0f121bed3374
child 488604 86382b2249f6eab5f660e6e6c3aea69909e7f956
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersheycam
bugs1496486
milestone64.0a1
Bug 1496486 - Remove a bunch of unused nsCSSValue code. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D7752
layout/style/ServoBindings.cpp
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2224,17 +2224,17 @@ Gecko_CSSValue_SetPixelLength(nsCSSValue
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null ||
              aCSSValue->GetUnit() == eCSSUnit_Pixel);
   aCSSValue->SetFloatValue(aLen, eCSSUnit_Pixel);
 }
 
 void
 Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut aCSSValue, nsStyleCoord::CalcValue aCalc)
 {
-  aCSSValue->SetCalcValue(&aCalc);
+  aCSSValue->SetCalcValue(aCalc);
 }
 
 nsStyleCoord::CalcValue
 Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue)
 {
   return aCSSValue->GetCalcValue();
 }
 
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -440,31 +440,16 @@ void nsCSSValue::SetArrayValue(nsCSSValu
 void nsCSSValue::SetURLValue(mozilla::css::URLValue* aValue)
 {
   Reset();
   mUnit = eCSSUnit_URL;
   mValue.mURL = aValue;
   mValue.mURL->AddRef();
 }
 
-void nsCSSValue::SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue)
-{
-  Reset();
-  mUnit = eCSSUnit_GridTemplateAreas;
-  mValue.mGridTemplateAreas = aValue;
-  mValue.mGridTemplateAreas->AddRef();
-}
-
-void nsCSSValue::SetFontFamilyListValue(already_AddRefed<SharedFontList> aValue)
-{
-  Reset();
-  mUnit = eCSSUnit_FontFamilyList;
-  mValue.mFontFamilyList = aValue.take();
-}
-
 void nsCSSValue::SetFontStretch(FontStretch aStretch)
 {
   Reset();
   mUnit = eCSSUnit_FontStretch;
   mValue.mFontStretch = aStretch;
 }
 
 void nsCSSValue::SetFontSlantStyle(FontSlantStyle aStyle)
@@ -530,148 +515,50 @@ nsCSSValueList* nsCSSValue::SetListValue
 void nsCSSValue::SetSharedListValue(nsCSSValueSharedList* aList)
 {
   Reset();
   mUnit = eCSSUnit_SharedList;
   mValue.mSharedList = aList;
   mValue.mSharedList->AddRef();
 }
 
-void nsCSSValue::SetDependentListValue(nsCSSValueList* aList)
-{
-  Reset();
-  if (aList) {
-    mUnit = eCSSUnit_ListDep;
-    mValue.mListDependent = aList;
-  }
-}
-
-void
-nsCSSValue::AdoptListValue(UniquePtr<nsCSSValueList> aValue)
-{
-  // We have to copy the first element since for owned lists the first
-  // element should be an nsCSSValueList_heap object.
-  SetListValue();
-  mValue.mList->mValue = std::move(aValue->mValue);
-  mValue.mList->mNext  = aValue->mNext;
-  aValue->mNext = nullptr;
-  aValue.reset();
-}
-
 nsCSSValuePairList* nsCSSValue::SetPairListValue()
 {
   Reset();
   mUnit = eCSSUnit_PairList;
   mValue.mPairList = new nsCSSValuePairList_heap;
   mValue.mPairList->AddRef();
   return mValue.mPairList;
 }
 
-void nsCSSValue::SetDependentPairListValue(nsCSSValuePairList* aList)
-{
-  Reset();
-  if (aList) {
-    mUnit = eCSSUnit_PairListDep;
-    mValue.mPairListDependent = aList;
-  }
-}
-
-void
-nsCSSValue::AdoptPairListValue(UniquePtr<nsCSSValuePairList> aValue)
-{
-  // We have to copy the first element, since for owned pair lists, the first
-  // element should be an nsCSSValuePairList_heap object.
-  SetPairListValue();
-  mValue.mPairList->mXValue = std::move(aValue->mXValue);
-  mValue.mPairList->mYValue = std::move(aValue->mYValue);
-  mValue.mPairList->mNext   = aValue->mNext;
-  aValue->mNext = nullptr;
-  aValue.reset();
-}
-
-void nsCSSValue::SetAutoValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Auto;
-}
-
-void nsCSSValue::SetInheritValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Inherit;
-}
-
-void nsCSSValue::SetInitialValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Initial;
-}
-
-void nsCSSValue::SetUnsetValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Unset;
-}
-
 void nsCSSValue::SetNoneValue()
 {
   Reset();
   mUnit = eCSSUnit_None;
 }
 
-void nsCSSValue::SetAllValue()
-{
-  Reset();
-  mUnit = eCSSUnit_All;
-}
-
-void nsCSSValue::SetNormalValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Normal;
-}
-
-void nsCSSValue::SetSystemFontValue()
-{
-  Reset();
-  mUnit = eCSSUnit_System_Font;
-}
-
-void nsCSSValue::SetDummyValue()
-{
-  Reset();
-  mUnit = eCSSUnit_Dummy;
-}
-
-void nsCSSValue::SetDummyInheritValue()
-{
-  Reset();
-  mUnit = eCSSUnit_DummyInherit;
-}
-
-void nsCSSValue::SetCalcValue(const nsStyleCoord::CalcValue* aCalc)
+void nsCSSValue::SetCalcValue(const nsStyleCoord::CalcValue& aCalc)
 {
   RefPtr<nsCSSValue::Array> arr = nsCSSValue::Array::Create(1);
-  if (!aCalc->mHasPercent) {
-    arr->Item(0).SetIntegerCoordValue(aCalc->mLength);
+  if (!aCalc.mHasPercent) {
+    arr->Item(0).SetIntegerCoordValue(aCalc.mLength);
   } else {
-    nsCSSValue::Array *arr2 = nsCSSValue::Array::Create(2);
+    nsCSSValue::Array* arr2 = nsCSSValue::Array::Create(2);
     arr->Item(0).SetArrayValue(arr2, eCSSUnit_Calc_Plus);
-    arr2->Item(0).SetIntegerCoordValue(aCalc->mLength);
-    arr2->Item(1).SetPercentValue(aCalc->mPercent);
+    arr2->Item(0).SetIntegerCoordValue(aCalc.mLength);
+    arr2->Item(1).SetPercentValue(aCalc.mPercent);
   }
 
   SetArrayValue(arr, eCSSUnit_Calc);
 }
 
 nsStyleCoord::CalcValue
 nsCSSValue::GetCalcValue() const
 {
-  MOZ_ASSERT(mUnit == eCSSUnit_Calc,
-             "The unit should be eCSSUnit_Calc");
+  MOZ_ASSERT(mUnit == eCSSUnit_Calc, "The unit should be eCSSUnit_Calc");
 
   const nsCSSValue::Array* array = GetArrayValue();
   MOZ_ASSERT(array->Count() == 1,
              "There should be a 1-length array");
 
   const nsCSSValue& rootValue = array->Item(0);
 
   nsStyleCoord::CalcValue result;
@@ -697,41 +584,16 @@ nsCSSValue::GetCalcValue() const
     result.mLength = length.GetPixelLength();
     result.mPercent = percent.GetPercentValue();
     result.mHasPercent = true;
   }
 
   return result;
 }
 
-nsCSSValue::Array*
-nsCSSValue::InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs)
-{
-  RefPtr<nsCSSValue::Array> func = Array::Create(aNumArgs + 1);
-  func->Item(0).SetIntValue(aFunctionId, eCSSUnit_Enumerated);
-  SetArrayValue(func, eCSSUnit_Function);
-  return func;
-}
-
-bool
-nsCSSValue::EqualsFunction(nsCSSKeyword aFunctionId) const
-{
-  if (mUnit != eCSSUnit_Function) {
-    return false;
-  }
-
-  nsCSSValue::Array* func = mValue.mArray;
-  MOZ_ASSERT(func && func->Count() >= 1 &&
-             func->Item(0).GetUnit() == eCSSUnit_Enumerated,
-             "illegally structured function value");
-
-  nsCSSKeyword thisFunctionId = func->Item(0).GetKeywordValue();
-  return thisFunctionId == aFunctionId;
-}
-
 // static
 already_AddRefed<nsStringBuffer>
 nsCSSValue::BufferFromString(const nsString& aValue)
 {
   RefPtr<nsStringBuffer> buffer = nsStringBuffer::FromString(aValue);
   if (buffer) {
     return buffer.forget();
   }
@@ -748,26 +610,16 @@ nsCSSValue::BufferFromString(const nsStr
 
   char16_t* data = static_cast<char16_t*>(buffer->Data());
   nsCharTraits<char16_t>::copy(data, aValue.get(), length);
   // Null-terminate.
   data[length] = 0;
   return buffer.forget();
 }
 
-void
-nsCSSValue::AtomizeIdentValue()
-{
-  MOZ_ASSERT(mUnit == eCSSUnit_Ident);
-  RefPtr<nsAtom> atom = NS_Atomize(GetStringBufferValue());
-  Reset();
-  mUnit = eCSSUnit_AtomIdent;
-  mValue.mAtom = atom.forget().take();
-}
-
 /* static */ void
 nsCSSValue::AppendAlignJustifyValueToString(int32_t aValue, nsAString& aResult)
 {
   auto legacy = aValue & NS_STYLE_ALIGN_LEGACY;
   if (legacy) {
     aValue &= ~legacy;
     aResult.AppendLiteral("legacy");
     if (!aValue) {
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -715,51 +715,26 @@ public:
   void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
   void SetFontFamilyListValue(already_AddRefed<mozilla::SharedFontList> aFontListValue);
   void SetFontStretch(mozilla::FontStretch aStretch);
   void SetFontSlantStyle(mozilla::FontSlantStyle aStyle);
   void SetFontWeight(mozilla::FontWeight aWeight);
   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 SetAutoValue();
-  void SetInheritValue();
-  void SetInitialValue();
-  void SetUnsetValue();
   void SetNoneValue();
-  void SetAllValue();
-  void SetNormalValue();
-  void SetSystemFontValue();
-  void SetDummyValue();
-  void SetDummyInheritValue();
-
-  // Converts an nsStyleCoord::CalcValue back into a CSSValue
-  void SetCalcValue(const nsStyleCoord::CalcValue* aCalc);
 
   nsStyleCoord::CalcValue GetCalcValue() const;
+  void SetCalcValue(const nsStyleCoord::CalcValue&);
 
   // These are a little different - they allocate storage for you and
   // return a handle.
   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,
-                      mozilla::CORSMode aCORSMode) const;  // Only pretend const
-
-  // Initializes as a function value with the specified function id.
-  Array* InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs);
-  // Checks if this is a function value with the specified function id.
-  bool EqualsFunction(nsCSSKeyword aFunctionId) const;
-
   // Returns an already addrefed buffer.  Guaranteed to return non-null.
   // (Will abort on allocation failure.)
   static already_AddRefed<nsStringBuffer>
     BufferFromString(const nsString& aValue);
 
   // Convert the given Ident value into AtomIdent.
   void AtomizeIdentValue();