Bug 1467622 - P1: nsStyleSVGPaint - Change nscolor to StyleComplexColor. r?xidorn draft
authorDan Glastonbury <dan.glastonbury@gmail.com>
Wed, 27 Jun 2018 17:07:37 +1000
changeset 815857 4648245a3c880d320881e87e0c712287e43efa0f
parent 815516 ffb7b5015fc331bdc4c5e6ab52b9de669faa8864
child 815858 a8c2c97d7d88e4af729e2ed01e0f2c0e2646ee11
push id115663
push userbmo:dglastonbury@mozilla.com
push dateTue, 10 Jul 2018 03:53:29 +0000
reviewersxidorn
bugs1467622
milestone63.0a1
Bug 1467622 - P1: nsStyleSVGPaint - Change nscolor to StyleComplexColor. r?xidorn MozReview-Commit-ID: 1bbQzOoOuBe
layout/generic/nsImageFrame.cpp
layout/style/ComputedStyle.cpp
layout/style/ServoBindings.cpp
layout/style/StyleComplexColor.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/svg/SVGImageContext.cpp
layout/svg/nsSVGUtils.cpp
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/values/computed/svg.rs
servo/components/style/values/specified/svg.rs
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1342,17 +1342,17 @@ nsImageFrame::DisplayAltText(nsPresConte
   }
 }
 
 struct nsRecessedBorder : public nsStyleBorder {
   nsRecessedBorder(nscoord aBorderWidth, nsPresContext* aPresContext)
     : nsStyleBorder(aPresContext)
   {
     NS_FOR_CSS_SIDES(side) {
-      BorderColorFor(side) = StyleComplexColor::FromColor(NS_RGB(0, 0, 0));
+      BorderColorFor(side) = StyleComplexColor::Black();
       mBorder.Side(side) = aBorderWidth;
       // Note: use SetBorderStyle here because we want to affect
       // mComputedBorder
       SetBorderStyle(side, NS_STYLE_BORDER_STYLE_INSET);
     }
   }
 };
 
--- a/layout/style/ComputedStyle.cpp
+++ b/layout/style/ComputedStyle.cpp
@@ -312,17 +312,17 @@ ExtractColor(ComputedStyle* aStyle, cons
 {
   return aColor.CalcColor(aStyle);
 }
 
 static nscolor
 ExtractColor(ComputedStyle* aStyle, const nsStyleSVGPaint& aPaintServer)
 {
   return aPaintServer.Type() == eStyleSVGPaintType_Color
-    ? aPaintServer.GetColor() : NS_RGBA(0, 0, 0, 0);
+    ? aPaintServer.GetColor(aStyle) : NS_RGBA(0, 0, 0, 0);
 }
 
 #define STYLE_FIELD(struct_, field_) aField == &struct_::field_ ||
 #define STYLE_STRUCT(name_, fields_)                                          \
   template<> nscolor                                                          \
   ComputedStyle::GetVisitedDependentColor(                                   \
     decltype(nsStyle##name_::MOZ_ARG_1 fields_) nsStyle##name_::* aField)     \
   {                                                                           \
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1655,17 +1655,17 @@ Gecko_CreateGradient(uint8_t aShape,
   result->mAngle.SetNoneValue();
   result->mBgPosX.SetNoneValue();
   result->mBgPosY.SetNoneValue();
   result->mRadiusX.SetNoneValue();
   result->mRadiusY.SetNoneValue();
 
   nsStyleGradientStop dummyStop = {
     nsStyleCoord(eStyleUnit_None),
-    StyleComplexColor::FromColor(NS_RGB(0, 0, 0)),
+    StyleComplexColor::Black(),
     0
   };
 
   for (uint32_t i = 0; i < aStopCount; i++) {
     result->mStops.AppendElement(dummyStop);
   }
 
   return result;
--- a/layout/style/StyleComplexColor.h
+++ b/layout/style/StyleComplexColor.h
@@ -34,16 +34,26 @@ public:
   }
   static StyleComplexColor CurrentColor() {
     return {NS_RGBA(0, 0, 0, 0), 1, eForeground};
   }
   static StyleComplexColor Auto() {
     return {NS_RGBA(0, 0, 0, 0), 1, eAuto};
   }
 
+  static StyleComplexColor Black() {
+    return StyleComplexColor::FromColor(NS_RGB(0, 0, 0));
+  }
+  static StyleComplexColor White() {
+    return StyleComplexColor::FromColor(NS_RGB(255, 255, 255));
+  }
+  static StyleComplexColor Transparent() {
+    return StyleComplexColor::FromColor(NS_RGBA(0, 0, 0, 0));
+  }
+
   bool IsAuto() const { return mTag == eAuto; }
   bool IsCurrentColor() const { return mTag == eForeground; }
 
   bool operator==(const StyleComplexColor& aOther) const {
     if (mTag != aOther.mTag) {
       return false;
     }
 
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4678,17 +4678,17 @@ nsComputedDOMStyle::GetFrameBoundsHeight
   return true;
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::GetFallbackValue(const nsStyleSVGPaint* aPaint)
 {
   RefPtr<nsROCSSPrimitiveValue> fallback = new nsROCSSPrimitiveValue;
   if (aPaint->GetFallbackType() == eStyleSVGFallbackType_Color) {
-    SetToRGBAColor(fallback, aPaint->GetFallbackColor());
+    SetToRGBAColor(fallback, aPaint->GetFallbackColor(mComputedStyle));
   } else {
     fallback->SetIdent(eCSSKeyword_none);
   }
   return fallback.forget();
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::GetSVGPaintFor(bool aFill)
@@ -4700,17 +4700,17 @@ nsComputedDOMStyle::GetSVGPaintFor(bool 
 
   nsAutoString paintString;
 
   switch (paint->Type()) {
     case eStyleSVGPaintType_None:
       val->SetIdent(eCSSKeyword_none);
       break;
     case eStyleSVGPaintType_Color:
-      SetToRGBAColor(val, paint->GetColor());
+      SetToRGBAColor(val, paint->GetColor(mComputedStyle));
       break;
     case eStyleSVGPaintType_Server: {
       SetValueToURLValue(paint->GetPaintServer(), val);
       if (paint->GetFallbackType() != eStyleSVGFallbackType_NotSet) {
         RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
         RefPtr<CSSValue> fallback = GetFallbackValue(paint);
         valueList->AppendCSSValue(val.forget());
         valueList->AppendCSSValue(fallback.forget());
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1225,19 +1225,19 @@ nsStyleFilter::SetDropShadow(nsCSSShadow
   mType = NS_STYLE_FILTER_DROP_SHADOW;
 }
 
 // --------------------
 // nsStyleSVGReset
 //
 nsStyleSVGReset::nsStyleSVGReset(const nsPresContext* aContext)
   : mMask(nsStyleImageLayers::LayerType::Mask)
-  , mStopColor(StyleComplexColor::FromColor(NS_RGB(0, 0, 0)))
-  , mFloodColor(StyleComplexColor::FromColor(NS_RGB(0, 0, 0)))
-  , mLightingColor(StyleComplexColor::FromColor(NS_RGB(255, 255, 255)))
+  , mStopColor(StyleComplexColor::Black())
+  , mFloodColor(StyleComplexColor::Black())
+  , mLightingColor(StyleComplexColor::White())
   , mStopOpacity(1.0f)
   , mFloodOpacity(1.0f)
   , mDominantBaseline(NS_STYLE_DOMINANT_BASELINE_AUTO)
   , mVectorEffect(NS_STYLE_VECTOR_EFFECT_NONE)
   , mMaskType(NS_STYLE_MASK_TYPE_LUMINANCE)
 {
   MOZ_COUNT_CTOR(nsStyleSVGReset);
 }
@@ -1335,24 +1335,24 @@ nsStyleSVGReset::HasMask() const
     }
   }
 
   return false;
 }
 
 // nsStyleSVGPaint implementation
 nsStyleSVGPaint::nsStyleSVGPaint(nsStyleSVGPaintType aType)
-  : mType(aType)
+  : mPaint(StyleComplexColor::Black())
+  , mType(aType)
   , mFallbackType(eStyleSVGFallbackType_NotSet)
-  , mFallbackColor(NS_RGB(0, 0, 0))
+  , mFallbackColor(StyleComplexColor::Black())
 {
   MOZ_ASSERT(aType == nsStyleSVGPaintType(0) ||
              aType == eStyleSVGPaintType_None ||
              aType == eStyleSVGPaintType_Color);
-  mPaint.mColor = NS_RGB(0, 0, 0);
 }
 
 nsStyleSVGPaint::nsStyleSVGPaint(const nsStyleSVGPaint& aSource)
   : nsStyleSVGPaint(nsStyleSVGPaintType(0))
 {
   Assign(aSource);
 }
 
@@ -1363,26 +1363,26 @@ nsStyleSVGPaint::~nsStyleSVGPaint()
 
 void
 nsStyleSVGPaint::Reset()
 {
   switch (mType) {
     case eStyleSVGPaintType_None:
       break;
     case eStyleSVGPaintType_Color:
-      mPaint.mColor = NS_RGB(0, 0, 0);
+      mPaint.mColor = StyleComplexColor::Black();
       break;
     case eStyleSVGPaintType_Server:
       mPaint.mPaintServer->Release();
       mPaint.mPaintServer = nullptr;
       MOZ_FALLTHROUGH;
     case eStyleSVGPaintType_ContextFill:
     case eStyleSVGPaintType_ContextStroke:
       mFallbackType = eStyleSVGFallbackType_NotSet;
-      mFallbackColor = NS_RGB(0, 0, 0);
+      mFallbackColor = StyleComplexColor::Black();
       break;
   }
   mType = nsStyleSVGPaintType(0);
 }
 
 nsStyleSVGPaint&
 nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
 {
@@ -1424,38 +1424,38 @@ nsStyleSVGPaint::SetNone()
 {
   Reset();
   mType = eStyleSVGPaintType_None;
 }
 
 void
 nsStyleSVGPaint::SetContextValue(nsStyleSVGPaintType aType,
                                  nsStyleSVGFallbackType aFallbackType,
-                                 nscolor aFallbackColor)
+                                 StyleComplexColor aFallbackColor)
 {
   MOZ_ASSERT(aType == eStyleSVGPaintType_ContextFill ||
              aType == eStyleSVGPaintType_ContextStroke);
   Reset();
   mType = aType;
   mFallbackType = aFallbackType;
   mFallbackColor = aFallbackColor;
 }
 
 void
-nsStyleSVGPaint::SetColor(nscolor aColor)
+nsStyleSVGPaint::SetColor(StyleComplexColor aColor)
 {
   Reset();
   mType = eStyleSVGPaintType_Color;
   mPaint.mColor = aColor;
 }
 
 void
 nsStyleSVGPaint::SetPaintServer(css::URLValue* aPaintServer,
                                 nsStyleSVGFallbackType aFallbackType,
-                                nscolor aFallbackColor)
+                                StyleComplexColor aFallbackColor)
 {
   MOZ_ASSERT(aPaintServer);
   Reset();
   mType = eStyleSVGPaintType_Server;
   mPaint.mPaintServer = aPaintServer;
   mPaint.mPaintServer->AddRef();
   mFallbackType = aFallbackType;
   mFallbackColor = aFallbackColor;
@@ -3281,17 +3281,17 @@ nsStyleImageLayers::Layer::CalcDifferenc
 }
 
 // --------------------
 // nsStyleBackground
 //
 
 nsStyleBackground::nsStyleBackground(const nsPresContext* aContext)
   : mImage(nsStyleImageLayers::LayerType::Background)
-  , mBackgroundColor(StyleComplexColor::FromColor(NS_RGBA(0, 0, 0, 0)))
+  , mBackgroundColor(StyleComplexColor::Transparent())
 {
   MOZ_COUNT_CTOR(nsStyleBackground);
 }
 
 nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
   : mImage(aSource.mImage)
   , mBackgroundColor(aSource.mBackgroundColor)
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2972,68 +2972,71 @@ public:
   nsStyleSVGPaint(const nsStyleSVGPaint& aSource);
   ~nsStyleSVGPaint();
 
   nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
 
   nsStyleSVGPaintType Type() const { return mType; }
 
   void SetNone();
-  void SetColor(nscolor aColor);
+  void SetColor(mozilla::StyleComplexColor aColor);
   void SetPaintServer(mozilla::css::URLValue* aPaintServer,
                       nsStyleSVGFallbackType aFallbackType,
-                      nscolor aFallbackColor);
+                      mozilla::StyleComplexColor aFallbackColor);
   void SetPaintServer(mozilla::css::URLValue* aPaintServer) {
     SetPaintServer(aPaintServer, eStyleSVGFallbackType_NotSet,
-                   NS_RGB(0, 0, 0));
+                   mozilla::StyleComplexColor::Black());
   }
   void SetContextValue(nsStyleSVGPaintType aType,
                        nsStyleSVGFallbackType aFallbackType,
-                       nscolor aFallbackColor);
+                       mozilla::StyleComplexColor aFallbackColor);
   void SetContextValue(nsStyleSVGPaintType aType) {
-    SetContextValue(aType, eStyleSVGFallbackType_NotSet, NS_RGB(0, 0, 0));
+    SetContextValue(aType, eStyleSVGFallbackType_NotSet,
+                    mozilla::StyleComplexColor::Black());
   }
 
-  nscolor GetColor() const {
+  nscolor GetColor(mozilla::ComputedStyle* aComputedStyle) const {
     MOZ_ASSERT(mType == eStyleSVGPaintType_Color);
-    return mPaint.mColor;
+    return mPaint.mColor.CalcColor(aComputedStyle);
   }
 
   mozilla::css::URLValue* GetPaintServer() const {
     MOZ_ASSERT(mType == eStyleSVGPaintType_Server);
     return mPaint.mPaintServer;
   }
 
   nsStyleSVGFallbackType GetFallbackType() const {
     return mFallbackType;
   }
 
-  nscolor GetFallbackColor() const {
+  nscolor GetFallbackColor(mozilla::ComputedStyle* aComputedStyle) const {
     MOZ_ASSERT(mType == eStyleSVGPaintType_Server ||
                mType == eStyleSVGPaintType_ContextFill ||
                mType == eStyleSVGPaintType_ContextStroke);
-    return mFallbackColor;
+    return mFallbackColor.CalcColor(aComputedStyle);
   }
 
   bool operator==(const nsStyleSVGPaint& aOther) const;
   bool operator!=(const nsStyleSVGPaint& aOther) const {
     return !(*this == aOther);
   }
 
 private:
   void Reset();
   void Assign(const nsStyleSVGPaint& aOther);
 
-  union {
-    nscolor mColor;
+  union ColorOrPaintServer {
+    mozilla::StyleComplexColor mColor;
     mozilla::css::URLValue* mPaintServer;
-  } mPaint;
+    explicit ColorOrPaintServer(mozilla::StyleComplexColor c) : mColor(c) {}
+  };
+  ColorOrPaintServer mPaint;
   nsStyleSVGPaintType mType;
   nsStyleSVGFallbackType mFallbackType;
-  nscolor mFallbackColor;
+  mozilla::StyleComplexColor mFallbackColor;
 };
 
 struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
 {
   explicit nsStyleSVG(const nsPresContext* aContext);
   nsStyleSVG(const nsStyleSVG& aSource);
   ~nsStyleSVG();
   void FinishStyle(nsPresContext*, const nsStyleSVG*) {}
--- a/layout/svg/SVGImageContext.cpp
+++ b/layout/svg/SVGImageContext.cpp
@@ -48,22 +48,22 @@ SVGImageContext::MaybeStoreContextPaint(
 
   bool haveContextPaint = false;
 
   RefPtr<SVGEmbeddingContextPaint> contextPaint = new SVGEmbeddingContextPaint();
 
   if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_FILL) &&
       style->mFill.Type() == eStyleSVGPaintType_Color) {
     haveContextPaint = true;
-    contextPaint->SetFill(style->mFill.GetColor());
+    contextPaint->SetFill(style->mFill.GetColor(aFromComputedStyle));
   }
   if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_STROKE) &&
       style->mStroke.Type() == eStyleSVGPaintType_Color) {
     haveContextPaint = true;
-    contextPaint->SetStroke(style->mStroke.GetColor());
+    contextPaint->SetStroke(style->mStroke.GetColor(aFromComputedStyle));
   }
   if (style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_FILL_OPACITY) {
     haveContextPaint = true;
     contextPaint->SetFillOpacity(style->mFillOpacity);
   }
   if (style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_STROKE_OPACITY) {
     haveContextPaint = true;
     contextPaint->SetStrokeOpacity(style->mStrokeOpacity);
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1434,39 +1434,39 @@ nsSVGUtils::GetFallbackOrPaintColor(Comp
 {
   const nsStyleSVGPaint &paint = aComputedStyle->StyleSVG()->*aFillOrStroke;
   ComputedStyle *styleIfVisited = aComputedStyle->GetStyleIfVisited();
   nscolor color;
   switch (paint.Type()) {
     case eStyleSVGPaintType_Server:
     case eStyleSVGPaintType_ContextStroke:
       color = paint.GetFallbackType() == eStyleSVGFallbackType_Color ?
-                paint.GetFallbackColor() : NS_RGBA(0, 0, 0, 0);
+                paint.GetFallbackColor(aComputedStyle) : NS_RGBA(0, 0, 0, 0);
       break;
     case eStyleSVGPaintType_ContextFill:
       color = paint.GetFallbackType() == eStyleSVGFallbackType_Color ?
-                paint.GetFallbackColor() : NS_RGB(0, 0, 0);
+                paint.GetFallbackColor(aComputedStyle) : NS_RGB(0, 0, 0);
       break;
     default:
-      color = paint.GetColor();
+      color = paint.GetColor(aComputedStyle);
       break;
   }
   if (styleIfVisited) {
     const nsStyleSVGPaint &paintIfVisited =
       styleIfVisited->StyleSVG()->*aFillOrStroke;
     // To prevent Web content from detecting if a user has visited a URL
     // (via URL loading triggered by paint servers or performance
     // differences between paint servers or between a paint server and a
     // color), we do not allow whether links are visited to change which
     // paint server is used or switch between paint servers and simple
     // colors.  A :visited style may only override a simple color with
     // another simple color.
     if (paintIfVisited.Type() == eStyleSVGPaintType_Color &&
         paint.Type() == eStyleSVGPaintType_Color) {
-      nscolor colors[2] = { color, paintIfVisited.GetColor() };
+      nscolor colors[2] = { color, paintIfVisited.GetColor(aComputedStyle) };
       return ComputedStyle::CombineVisitedColors(
                colors, aComputedStyle->RelevantLinkVisited());
     }
   }
   return color;
 }
 
 /* static */ void
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -663,24 +663,24 @@ def set_gecko_property(ffi_name, expr):
             SVGPaintKind::PaintServer(url) => {
                 unsafe {
                     bindings::Gecko_nsStyleSVGPaint_SetURLValue(paint, url.0.url_value.get());
                 }
             }
             SVGPaintKind::Color(color) => {
                 paint.mType = nsStyleSVGPaintType::eStyleSVGPaintType_Color;
                 unsafe {
-                    *paint.mPaint.mColor.as_mut() = convert_rgba_to_nscolor(&color);
+                    *paint.mPaint.mColor.as_mut() = color.into();
                 }
             }
         }
 
         paint.mFallbackType = match fallback {
             Some(Either::First(color)) => {
-                paint.mFallbackColor = convert_rgba_to_nscolor(&color);
+                paint.mFallbackColor = color.into();
                 nsStyleSVGFallbackType::eStyleSVGFallbackType_Color
             },
             Some(Either::Second(_)) => {
                 nsStyleSVGFallbackType::eStyleSVGFallbackType_None
             },
             None => nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet
         };
     }
@@ -705,17 +705,17 @@ def set_gecko_property(ffi_name, expr):
         use values::computed::url::ComputedUrl;
         use values::generics::svg::{SVGPaint, SVGPaintKind};
         use self::structs::nsStyleSVGPaintType;
         use self::structs::nsStyleSVGFallbackType;
         let ref paint = ${get_gecko_property(gecko_ffi_name)};
 
         let fallback = match paint.mFallbackType {
             nsStyleSVGFallbackType::eStyleSVGFallbackType_Color => {
-                Some(Either::First(convert_nscolor_to_rgba(paint.mFallbackColor)))
+                Some(Either::First(paint.mFallbackColor.into()))
             },
             nsStyleSVGFallbackType::eStyleSVGFallbackType_None => {
                 Some(Either::Second(None_))
             },
             nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet => None,
         };
 
         let kind = match paint.mType {
@@ -724,17 +724,18 @@ def set_gecko_property(ffi_name, expr):
             nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke,
             nsStyleSVGPaintType::eStyleSVGPaintType_Server => {
                 SVGPaintKind::PaintServer(unsafe {
                     let url = RefPtr::new(*paint.mPaint.mPaintServer.as_ref());
                     ComputedUrl::from_url_value(url)
                 })
             }
             nsStyleSVGPaintType::eStyleSVGPaintType_Color => {
-                unsafe { SVGPaintKind::Color(convert_nscolor_to_rgba(*paint.mPaint.mColor.as_ref())) }
+                let col = unsafe { *paint.mPaint.mColor.as_ref() };
+                SVGPaintKind::Color(col.into())
             }
         };
         SVGPaint {
             kind: kind,
             fallback: fallback,
         }
     }
 </%def>
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -24,17 +24,17 @@ use properties::{LonghandId, ShorthandId
 use servo_arc::Arc;
 use smallvec::SmallVec;
 use std::{cmp, ptr};
 use std::mem::{self, ManuallyDrop};
 use hash::FnvHashMap;
 use super::ComputedValues;
 use values::CSSFloat;
 use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
-use values::animated::color::RGBA as AnimatedRGBA;
+use values::animated::color::Color as AnimatedColor;
 use values::animated::effects::Filter as AnimatedFilter;
 #[cfg(feature = "gecko")] use values::computed::TransitionProperty;
 use values::computed::{Angle, CalcLengthOrPercentage};
 use values::computed::{ClipRect, Context};
 use values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
 use values::computed::{LengthOrPercentageOrNone, MaxLength};
 use values::computed::{NonNegativeNumber, Number, NumberOrPercentage, Percentage};
 use values::computed::length::NonNegativeLengthOrPercentage;
@@ -2669,20 +2669,20 @@ impl ComputeSquaredDistance for Computed
             return matrix1.compute_squared_distance(&matrix2);
         }
 
         squared_dist
     }
 }
 
 /// Animated SVGPaint
-pub type IntermediateSVGPaint = SVGPaint<AnimatedRGBA, ComputedUrl>;
+pub type IntermediateSVGPaint = SVGPaint<AnimatedColor, ComputedUrl>;
 
 /// Animated SVGPaintKind
-pub type IntermediateSVGPaintKind = SVGPaintKind<AnimatedRGBA, ComputedUrl>;
+pub type IntermediateSVGPaintKind = SVGPaintKind<AnimatedColor, ComputedUrl>;
 
 impl ToAnimatedZero for IntermediateSVGPaint {
     #[inline]
     fn to_animated_zero(&self) -> Result<Self, ()> {
         Ok(IntermediateSVGPaint {
             kind: self.kind.to_animated_zero()?,
             fallback: self.fallback.and_then(|v| v.to_animated_zero().ok()),
         })
--- a/servo/components/style/values/computed/svg.rs
+++ b/servo/components/style/values/computed/svg.rs
@@ -4,41 +4,42 @@
 
 //! Computed types for SVG properties.
 
 use app_units::Au;
 use values::RGBA;
 use values::computed::{LengthOrPercentage, NonNegativeLength};
 use values::computed::{NonNegativeLengthOrPercentage, NonNegativeNumber, Number};
 use values::computed::Opacity;
+use values::computed::color::Color;
 use values::computed::url::ComputedUrl;
 use values::generics::svg as generic;
 
 pub use values::specified::SVGPaintOrder;
 
 pub use values::specified::MozContextProperties;
 
 /// Computed SVG Paint value
-pub type SVGPaint = generic::SVGPaint<RGBA, ComputedUrl>;
+pub type SVGPaint = generic::SVGPaint<Color, ComputedUrl>;
 /// Computed SVG Paint Kind value
-pub type SVGPaintKind = generic::SVGPaintKind<RGBA, ComputedUrl>;
+pub type SVGPaintKind = generic::SVGPaintKind<Color, ComputedUrl>;
 
 impl Default for SVGPaint {
     fn default() -> Self {
         SVGPaint {
             kind: generic::SVGPaintKind::None,
             fallback: None,
         }
     }
 }
 
 impl SVGPaint {
     /// Opaque black color
     pub fn black() -> Self {
-        let rgba = RGBA::from_floats(0., 0., 0., 1.);
+        let rgba = RGBA::from_floats(0., 0., 0., 1.).into();
         SVGPaint {
             kind: generic::SVGPaintKind::Color(rgba),
             fallback: None,
         }
     }
 }
 
 /// A value of <length> | <percentage> | <number> for stroke-dashoffset.
--- a/servo/components/style/values/specified/svg.rs
+++ b/servo/components/style/values/specified/svg.rs
@@ -8,24 +8,24 @@ use cssparser::Parser;
 use parser::{Parse, ParserContext};
 use std::fmt::{self, Write};
 use style_traits::{CommaWithSpace, CssWriter, ParseError, Separator};
 use style_traits::{StyleParseErrorKind, ToCss};
 use values::CustomIdent;
 use values::generics::svg as generic;
 use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber};
 use values::specified::{Number, Opacity};
-use values::specified::color::RGBAColor;
+use values::specified::color::Color;
 use values::specified::url::SpecifiedUrl;
 
 /// Specified SVG Paint value
-pub type SVGPaint = generic::SVGPaint<RGBAColor, SpecifiedUrl>;
+pub type SVGPaint = generic::SVGPaint<Color, SpecifiedUrl>;
 
 /// Specified SVG Paint Kind value
-pub type SVGPaintKind = generic::SVGPaintKind<RGBAColor, SpecifiedUrl>;
+pub type SVGPaintKind = generic::SVGPaintKind<Color, SpecifiedUrl>;
 
 #[cfg(feature = "gecko")]
 fn is_context_value_enabled() -> bool {
     // The prefs can only be mutated on the main thread, so it is safe
     // to read whenever we are on the main thread or the main thread is
     // blocked.
     use gecko_bindings::structs::mozilla;
     unsafe { mozilla::StaticPrefs_sVarCache_gfx_font_rendering_opentype_svg_enabled }