Use generics for the filter property

This introduces an additional shadow type for drop-shadow().
This commit is contained in:
Anthony Ramine 2017-06-19 10:05:44 +02:00
parent e41b7d06b4
commit 6f4061d4ad
21 changed files with 822 additions and 496 deletions

View file

@ -28,6 +28,7 @@ pub use self::background::BackgroundSize;
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderCornerRadius};
pub use self::color::{Color, RGBAColor};
pub use self::effects::FilterList;
pub use self::flex::FlexBasis;
pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, ImageRect};
#[cfg(feature = "gecko")]
@ -49,6 +50,7 @@ pub mod background;
pub mod basic_shape;
pub mod border;
pub mod color;
pub mod effects;
pub mod flex;
pub mod image;
#[cfg(feature = "gecko")]
@ -249,6 +251,22 @@ impl<T> ToComputedValue for Vec<T>
}
}
impl<T> ToComputedValue for Box<[T]>
where T: ToComputedValue
{
type ComputedValue = Box<[<T as ToComputedValue>::ComputedValue]>;
#[inline]
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
self.iter().map(|item| item.to_computed_value(context)).collect::<Vec<_>>().into_boxed_slice()
}
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
computed.iter().map(T::from_computed_value).collect::<Vec<_>>().into_boxed_slice()
}
}
/// A marker trait to represent that the specified value is also the computed
/// value.
pub trait ComputedValueAsSpecified {}