style: Change nscolor to StyleComplexColor in nsCSSShadowItem.

Bug: 1467621
Reviewed-by: xidorn
MozReview-Commit-ID: moE2CI7fT8
This commit is contained in:
Dan Glastonbury 2018-06-19 14:18:33 +10:00 committed by Emilio Cobos Álvarez
parent 9c243a115e
commit a055e8af89
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 27 additions and 42 deletions

View file

@ -186,7 +186,7 @@ impl ComputeSquaredDistance for Color {
(Foreground, Foreground) => SquaredDistance::from_sqrt(0.),
(Numeric(c1), Numeric(c2)) => c1.compute_squared_distance(&c2)?,
(Foreground, Numeric(color)) | (Numeric(color), Foreground) => {
// `computed_squared_distance` is symmetic.
// `computed_squared_distance` is symmetric.
color.compute_squared_distance(&RGBA::transparent())?
+ SquaredDistance::from_sqrt(1.)
}
@ -207,7 +207,6 @@ impl ComputeSquaredDistance for Color {
impl ToAnimatedZero for Color {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
// FIXME(nox): This does not look correct to me.
Err(())
Ok(RGBA::transparent().into())
}
}

View file

@ -6,7 +6,7 @@
#[cfg(not(feature = "gecko"))]
use values::Impossible;
use values::animated::color::RGBA;
use values::animated::color::Color;
use values::computed::{Angle, Number};
use values::computed::length::Length;
#[cfg(feature = "gecko")]
@ -17,7 +17,7 @@ use values::generics::effects::Filter as GenericFilter;
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
/// An animated value for a single `box-shadow`.
pub type BoxShadow = GenericBoxShadow<Option<RGBA>, Length, Length, Length>;
pub type BoxShadow = GenericBoxShadow<Color, Length, Length, Length>;
/// An animated value for a single `filter`.
#[cfg(feature = "gecko")]
@ -28,7 +28,7 @@ pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow, ComputedUrl
pub type Filter = GenericFilter<Angle, Number, Length, Impossible, Impossible>;
/// An animated value for the `drop-shadow()` filter.
pub type SimpleShadow = GenericSimpleShadow<Option<RGBA>, Length, Length>;
pub type SimpleShadow = GenericSimpleShadow<Color, Length, Length>;
impl ComputeSquaredDistance for BoxShadow {
#[inline]

View file

@ -7,7 +7,7 @@
#[cfg(not(feature = "gecko"))]
use values::Impossible;
use values::computed::{Angle, NonNegativeNumber};
use values::computed::color::RGBAColor;
use values::computed::color::Color;
use values::computed::length::{Length, NonNegativeLength};
#[cfg(feature = "gecko")]
use values::computed::url::ComputedUrl;
@ -16,7 +16,7 @@ use values::generics::effects::Filter as GenericFilter;
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
/// A computed value for a single shadow of the `box-shadow` property.
pub type BoxShadow = GenericBoxShadow<Option<RGBAColor>, Length, NonNegativeLength, Length>;
pub type BoxShadow = GenericBoxShadow<Color, Length, NonNegativeLength, Length>;
/// A computed value for a single `filter`.
#[cfg(feature = "gecko")]
@ -27,4 +27,4 @@ pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Sim
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible, Impossible>;
/// A computed value for the `drop-shadow()` filter.
pub type SimpleShadow = GenericSimpleShadow<Option<RGBAColor>, Length, NonNegativeLength>;
pub type SimpleShadow = GenericSimpleShadow<Color, Length, NonNegativeLength>;

View file

@ -17,14 +17,14 @@ use values::generics::effects::BoxShadow as GenericBoxShadow;
use values::generics::effects::Filter as GenericFilter;
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
use values::specified::{Angle, NumberOrPercentage};
use values::specified::color::RGBAColor;
use values::specified::color::Color;
use values::specified::length::{Length, NonNegativeLength};
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
/// A specified value for a single shadow of the `box-shadow` property.
pub type BoxShadow =
GenericBoxShadow<Option<RGBAColor>, Length, Option<NonNegativeLength>, Option<Length>>;
GenericBoxShadow<Option<Color>, Length, Option<NonNegativeLength>, Option<Length>>;
/// A specified value for a single `filter`.
#[cfg(feature = "gecko")]
@ -93,7 +93,7 @@ impl ToComputedValue for Factor {
}
/// A specified value for the `drop-shadow()` filter.
pub type SimpleShadow = GenericSimpleShadow<Option<RGBAColor>, Length, Option<NonNegativeLength>>;
pub type SimpleShadow = GenericSimpleShadow<Option<Color>, Length, Option<NonNegativeLength>>;
impl Parse for BoxShadow {
fn parse<'i, 't>(
@ -135,7 +135,7 @@ impl Parse for BoxShadow {
}
}
if color.is_none() {
if let Ok(value) = input.try(|i| RGBAColor::parse(context, i)) {
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
color = Some(value);
continue;
}
@ -249,16 +249,18 @@ impl Parse for SimpleShadow {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let color = input.try(|i| RGBAColor::parse(context, i)).ok();
let color = input.try(|i| Color::parse(context, i)).ok();
let horizontal = Length::parse(context, input)?;
let vertical = Length::parse(context, input)?;
let blur = input.try(|i| Length::parse_non_negative(context, i)).ok();
let color = color.or_else(|| input.try(|i| RGBAColor::parse(context, i)).ok());
let blur = blur.map(NonNegative::<Length>);
let color = color.or_else(|| input.try(|i| Color::parse(context, i)).ok());
Ok(SimpleShadow {
color: color,
horizontal: horizontal,
vertical: vertical,
blur: blur.map(NonNegative::<Length>),
color,
horizontal,
vertical,
blur,
})
}
}
@ -269,7 +271,10 @@ impl ToComputedValue for SimpleShadow {
#[inline]
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
ComputedSimpleShadow {
color: self.color.to_computed_value(context),
color: self.color
.as_ref()
.unwrap_or(&Color::currentcolor())
.to_computed_value(context),
horizontal: self.horizontal.to_computed_value(context),
vertical: self.vertical.to_computed_value(context),
blur: self.blur
@ -282,7 +287,7 @@ impl ToComputedValue for SimpleShadow {
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
SimpleShadow {
color: ToComputedValue::from_computed_value(&computed.color),
color: Some(ToComputedValue::from_computed_value(&computed.color)),
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
vertical: ToComputedValue::from_computed_value(&computed.vertical),
blur: Some(ToComputedValue::from_computed_value(&computed.blur)),