mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Use generics for SimpleShadow
This commit is contained in:
parent
a29261dec1
commit
81a01f6ce1
4 changed files with 23 additions and 45 deletions
|
@ -16,6 +16,7 @@ use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
|
||||||
use values::computed::length::Length;
|
use values::computed::length::Length;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::FilterList as GenericFilterList;
|
use values::generics::effects::FilterList as GenericFilterList;
|
||||||
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
|
|
||||||
/// An animated value for the `filter` property.
|
/// An animated value for the `filter` property.
|
||||||
pub type FilterList = GenericFilterList<Filter>;
|
pub type FilterList = GenericFilterList<Filter>;
|
||||||
|
@ -29,21 +30,7 @@ pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow>;
|
||||||
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
||||||
|
|
||||||
/// An animated value for the `drop-shadow()` filter.
|
/// An animated value for the `drop-shadow()` filter.
|
||||||
///
|
pub type SimpleShadow = GenericSimpleShadow<IntermediateColor, Length, Length>;
|
||||||
/// 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,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl From<ComputedFilterList> for FilterList {
|
impl From<ComputedFilterList> for FilterList {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use values::computed::color::Color;
|
||||||
use values::computed::length::Length;
|
use values::computed::length::Length;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::FilterList as GenericFilterList;
|
use values::generics::effects::FilterList as GenericFilterList;
|
||||||
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
|
|
||||||
/// A computed value for the `filter` property.
|
/// A computed value for the `filter` property.
|
||||||
pub type FilterList = GenericFilterList<Filter>;
|
pub type FilterList = GenericFilterList<Filter>;
|
||||||
|
@ -24,21 +25,7 @@ pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow>;
|
||||||
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
||||||
|
|
||||||
/// A computed value for the `drop-shadow()` filter.
|
/// A computed value for the `drop-shadow()` filter.
|
||||||
///
|
pub type SimpleShadow = GenericSimpleShadow<Color, Length, Length>;
|
||||||
/// 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,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FilterList {
|
impl FilterList {
|
||||||
/// Returns the resulting opacity of this filter pipeline.
|
/// Returns the resulting opacity of this filter pipeline.
|
||||||
|
|
|
@ -55,6 +55,23 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
|
||||||
Url(SpecifiedUrl),
|
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, SizeLength, ShapeLength> {
|
||||||
|
/// Color.
|
||||||
|
pub color: Color,
|
||||||
|
/// Horizontal radius.
|
||||||
|
pub horizontal: SizeLength,
|
||||||
|
/// Vertical radius.
|
||||||
|
pub vertical: SizeLength,
|
||||||
|
/// Blur radius.
|
||||||
|
pub blur: ShapeLength,
|
||||||
|
}
|
||||||
|
|
||||||
impl<F> FilterList<F> {
|
impl<F> FilterList<F> {
|
||||||
/// Returns `none`.
|
/// Returns `none`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -13,6 +13,7 @@ use values::computed::{Context, Number as ComputedNumber, ToComputedValue};
|
||||||
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
|
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::FilterList as GenericFilterList;
|
use values::generics::effects::FilterList as GenericFilterList;
|
||||||
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
use values::specified::{Angle, Percentage};
|
use values::specified::{Angle, Percentage};
|
||||||
use values::specified::color::Color;
|
use values::specified::color::Color;
|
||||||
use values::specified::length::Length;
|
use values::specified::length::Length;
|
||||||
|
@ -43,21 +44,7 @@ pub enum Factor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified value for the `drop-shadow()` filter.
|
/// A specified value for the `drop-shadow()` filter.
|
||||||
///
|
pub type SimpleShadow = GenericSimpleShadow<Option<Color>, Length, Option<Length>>;
|
||||||
/// 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<Color>,
|
|
||||||
/// Horizontal radius.
|
|
||||||
pub horizontal: Length,
|
|
||||||
/// Vertical radius.
|
|
||||||
pub vertical: Length,
|
|
||||||
/// Blur radius.
|
|
||||||
pub blur: Option<Length>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for FilterList {
|
impl Parse for FilterList {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue