Bug 1325940 part 1 - Added a constructor for nsCSSValue to accept enumerations. r=xidorn
authorGajanan <grhegde09@gmail.com>
Thu, 21 Dec 2017 12:23:36 +1100
changeset 397130 06ac73f3f76fccb670d383e2c5614eef7e40063d
parent 397129 6392d652d00572f5f75e243a5ce5e9f98794217f
child 397131 c9fceb1a76ec9b85dd4aeb6be1ea61e04b421ec8
push id33127
push useraiakab@mozilla.com
push dateThu, 21 Dec 2017 22:17:05 +0000
treeherdermozilla-central@d20967c26da5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1325940
milestone59.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 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
@@ -617,16 +617,26 @@ public:
   explicit nsCSSValue(mozilla::SharedFontList* 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
   {