From 81a01f6ce1526091e6904bea34a5481c0b0ee3f1 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 24 Jun 2017 13:01:20 +0200 Subject: [PATCH] Use generics for SimpleShadow --- components/style/values/animated/effects.rs | 17 ++--------------- components/style/values/computed/effects.rs | 17 ++--------------- components/style/values/generics/effects.rs | 17 +++++++++++++++++ components/style/values/specified/effects.rs | 17 ++--------------- 4 files changed, 23 insertions(+), 45 deletions(-) diff --git a/components/style/values/animated/effects.rs b/components/style/values/animated/effects.rs index d53afdfc90b..bbf60483613 100644 --- a/components/style/values/animated/effects.rs +++ b/components/style/values/animated/effects.rs @@ -16,6 +16,7 @@ use values::computed::effects::SimpleShadow as ComputedSimpleShadow; use values::computed::length::Length; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::FilterList as GenericFilterList; +use values::generics::effects::SimpleShadow as GenericSimpleShadow; /// An animated value for the `filter` property. pub type FilterList = GenericFilterList; @@ -29,21 +30,7 @@ pub type Filter = GenericFilter; pub type Filter = GenericFilter; /// An animated value for the `drop-shadow()` filter. -/// -/// Contrary to the canonical order from the spec, the color is serialised -/// first, like in Gecko and Webkit. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq)] -pub struct SimpleShadow { - /// Color. - pub color: IntermediateColor, - /// Horizontal radius. - pub horizontal: Length, - /// Vertical radius. - pub vertical: Length, - /// Blur radius. - pub blur: Length, -} +pub type SimpleShadow = GenericSimpleShadow; #[cfg(feature = "gecko")] impl From for FilterList { diff --git a/components/style/values/computed/effects.rs b/components/style/values/computed/effects.rs index 8db3c3880a3..fb5ae5453a6 100644 --- a/components/style/values/computed/effects.rs +++ b/components/style/values/computed/effects.rs @@ -11,6 +11,7 @@ use values::computed::color::Color; use values::computed::length::Length; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::FilterList as GenericFilterList; +use values::generics::effects::SimpleShadow as GenericSimpleShadow; /// A computed value for the `filter` property. pub type FilterList = GenericFilterList; @@ -24,21 +25,7 @@ pub type Filter = GenericFilter; pub type Filter = GenericFilter; /// A computed value for the `drop-shadow()` filter. -/// -/// Contrary to the canonical order from the spec, the color is serialised -/// first, like in Gecko and Webkit. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq, ToCss)] -pub struct SimpleShadow { - /// Color. - pub color: Color, - /// Horizontal radius. - pub horizontal: Length, - /// Vertical radius. - pub vertical: Length, - /// Blur radius. - pub blur: Length, -} +pub type SimpleShadow = GenericSimpleShadow; impl FilterList { /// Returns the resulting opacity of this filter pipeline. diff --git a/components/style/values/generics/effects.rs b/components/style/values/generics/effects.rs index 504b8544e3d..3b29429dd51 100644 --- a/components/style/values/generics/effects.rs +++ b/components/style/values/generics/effects.rs @@ -55,6 +55,23 @@ pub enum Filter { Url(SpecifiedUrl), } +/// A generic value for the `drop-shadow()` filter and the `text-shadow` property. +/// +/// Contrary to the canonical order from the spec, the color is serialised +/// first, like in Gecko and Webkit. +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +pub struct SimpleShadow { + /// Color. + pub color: Color, + /// Horizontal radius. + pub horizontal: SizeLength, + /// Vertical radius. + pub vertical: SizeLength, + /// Blur radius. + pub blur: ShapeLength, +} + impl FilterList { /// Returns `none`. #[inline] diff --git a/components/style/values/specified/effects.rs b/components/style/values/specified/effects.rs index 7dd8763da9a..abd02653ed9 100644 --- a/components/style/values/specified/effects.rs +++ b/components/style/values/specified/effects.rs @@ -13,6 +13,7 @@ use values::computed::{Context, Number as ComputedNumber, ToComputedValue}; use values::computed::effects::SimpleShadow as ComputedSimpleShadow; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::FilterList as GenericFilterList; +use values::generics::effects::SimpleShadow as GenericSimpleShadow; use values::specified::{Angle, Percentage}; use values::specified::color::Color; use values::specified::length::Length; @@ -43,21 +44,7 @@ pub enum Factor { } /// A specified value for the `drop-shadow()` filter. -/// -/// Contrary to the canonical order from the spec, the color is serialised -/// first, like in Gecko's computed values and in all Webkit's values. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] -pub struct SimpleShadow { - /// Color. - pub color: Option, - /// Horizontal radius. - pub horizontal: Length, - /// Vertical radius. - pub vertical: Length, - /// Blur radius. - pub blur: Option, -} +pub type SimpleShadow = GenericSimpleShadow, Length, Option>; impl Parse for FilterList { #[inline]