Bug 1266621 part 4 - Remove constructors of StyleComplexColor. r=heycam draft
authorXidorn Quan <me@upsuper.org>
Tue, 27 Sep 2016 14:00:05 +1000
changeset 418917 9626d350649f4ba6dba597e3df05fe1829307610
parent 418916 18ff94f359dde9cd174e2991b7dd848686058057
child 418918 fba71e92cf7d23728a7c963ae12027e7aee7e986
push id30801
push userxquan@mozilla.com
push dateThu, 29 Sep 2016 09:22:37 +0000
reviewersheycam
bugs1266621
milestone52.0a1
Bug 1266621 part 4 - Remove constructors of StyleComplexColor. r=heycam So that they can be put inside anonymous structs and unions. MozReview-Commit-ID: 8OMxkSZJEOz
layout/style/StyleComplexColor.h
layout/style/nsCSSValue.h
--- a/layout/style/StyleComplexColor.h
+++ b/layout/style/StyleComplexColor.h
@@ -20,24 +20,18 @@ namespace mozilla {
  * where p is mForegroundRatio. See mozilla::LinearBlendColors for
  * the actual algorithm.
  */
 struct StyleComplexColor
 {
   nscolor mColor;
   uint8_t mForegroundRatio;
 
-  StyleComplexColor() {}
-  StyleComplexColor(nscolor aColor, uint_fast8_t aForegroundRatio)
-    : mColor(aColor), mForegroundRatio(aForegroundRatio) {}
-
-  static StyleComplexColor FromColor(nscolor aColor)
-    { return StyleComplexColor(aColor, 0); }
-  static StyleComplexColor CurrentColor()
-    { return StyleComplexColor(NS_RGBA(0, 0, 0, 0), 255); }
+  static StyleComplexColor FromColor(nscolor aColor) { return {aColor, 0}; }
+  static StyleComplexColor CurrentColor() { return {NS_RGBA(0, 0, 0, 0), 255}; }
 
   bool IsNumericColor() const { return mForegroundRatio == 0; }
   bool IsCurrentColor() const { return mForegroundRatio == 255; }
 
   bool operator==(const StyleComplexColor& aOther) const {
     return mForegroundRatio == aOther.mForegroundRatio &&
            (IsCurrentColor() || mColor == aOther.mColor);
   }
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -370,18 +370,17 @@ struct ComplexColorData
     return !(*this == aOther);
   }
 
   bool IsCurrentColor() const { return mForegroundRatio >= 1.0f; }
   bool IsNumericColor() const { return mForegroundRatio <= 0.0f; }
 
   StyleComplexColor ToComplexColor() const
   {
-    return StyleComplexColor(
-      mColor.ToColor(), ClampColor(mForegroundRatio * 255.0f));
+    return {mColor.ToColor(), ClampColor(mForegroundRatio * 255.0f)};
   }
 };
 
 struct ComplexColorValue final : public ComplexColorData
 {
   // Just redirect any parameter to the data struct.
   template<typename... Args>
   explicit ComplexColorValue(Args&&... aArgs)