Bug 1325940 part 1 - Added a constructor for nsCSSValue to accept enumerations. r=xidorn
☠☠ backed out by 9c7d9aa4c2f3 ☠ ☠
authorGajanan <grhegde09@gmail.com>
Mon, 13 Mar 2017 21:19:19 +1100
changeset 497519 be602e750e399e19e32a6a06ea22ce090495b4b2
parent 497518 d2f740260b400810da80773e2d61576f51ab0972
child 497520 a035c2b6ae72b394debf576a29a97a1274232597
push id48933
push userbmo:james@hoppipolla.co.uk
push dateMon, 13 Mar 2017 13:53:04 +0000
reviewersxidorn
bugs1325940
milestone55.0a1
Bug 1325940 part 1 - Added a constructor for nsCSSValue to accept enumerations. r=xidorn MozReview-Commit-ID: 5Vns9QGA8c5
layout/style/nsCSSValue.h
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -602,16 +602,26 @@ public:
   explicit nsCSSValue(mozilla::css::FontFamilyListRefCnt* aValue);
   nsCSSValue(const nsCSSValue& aCopy);
   nsCSSValue(nsCSSValue&& aOther)
     : mUnit(aOther.mUnit)
     , mValue(aOther.mValue)
   {
     aOther.mUnit = eCSSUnit_Null;
   }
+  template<typename T,
+           typename = typename std::enable_if<std::is_enum<T>::value>::type>
+  explicit nsCSSValue(T aValue)
+    : mUnit(eCSSUnit_Enumerated)
+  {
+    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
+                  "aValue must be an enum that fits within mValue.mInt");
+    mValue.mInt = static_cast<int32_t>(aValue);
+  }
+
   ~nsCSSValue() { Reset(); }
 
   nsCSSValue&  operator=(const nsCSSValue& aCopy);
   nsCSSValue&  operator=(nsCSSValue&& aCopy);
   bool        operator==(const nsCSSValue& aOther) const;
 
   bool operator!=(const nsCSSValue& aOther) const
   {