style: Extract {animated,computed}::Color common parts.

Extract the common parts of `animated::Color` and `computed::Color` out
into `generics::color::Color<T>` that is generic over the type of
RGBA color.

Bug: 1465307
Reviewed-by: xidorn
MozReview-Commit-ID: EymSr7aqnAP
This commit is contained in:
Dan Glastonbury 2018-06-05 11:49:51 +10:00 committed by Emilio Cobos Álvarez
parent 314b14d46e
commit 5f74a15f38
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 122 additions and 146 deletions

View file

@ -18,6 +18,7 @@ use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError, StyleParse
use style_traits::{SpecifiedValueInfo, ToCss, ValueParseErrorKind};
use super::AllowQuirks;
use values::computed::{Color as ComputedColor, Context, ToComputedValue};
use values::generics::color::Color as GenericColor;
use values::specified::calc::CalcNode;
/// Specified color value
@ -384,9 +385,9 @@ impl ToComputedValue for Color {
fn from_computed_value(computed: &ComputedColor) -> Self {
match *computed {
ComputedColor::Numeric(color) => Color::rgba(color),
ComputedColor::Foreground => Color::currentcolor(),
ComputedColor::Complex(..) => Color::Complex(*computed),
GenericColor::Numeric(color) => Color::rgba(color),
GenericColor::Foreground => Color::currentcolor(),
GenericColor::Complex(..) => Color::Complex(*computed),
}
}
}