style: Use cbindgen for filters.

Had to implement some OwnedSlice bits that the canvas code used.

Differential Revision: https://phabricator.services.mozilla.com/D31799
This commit is contained in:
Emilio Cobos Álvarez 2019-05-27 12:37:37 +00:00
parent ccff9b294f
commit 57868f571f
8 changed files with 26 additions and 150 deletions

View file

@ -34,8 +34,10 @@ pub struct GenericBoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
pub use self::GenericBoxShadow as BoxShadow;
/// A generic value for a single `filter`.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[animation(no_bound(Url))]
#[animation(no_bound(U))]
#[derive(
Clone,
ComputeSquaredDistance,
@ -49,7 +51,8 @@ pub use self::GenericBoxShadow as BoxShadow;
ToResolvedValue,
ToShmem,
)]
pub enum Filter<Angle, Factor, Length, DropShadow, Url> {
#[repr(C, u8)]
pub enum GenericFilter<Angle, Factor, Length, Shadow, U> {
/// `blur(<length>)`
#[css(function)]
Blur(Length),
@ -79,12 +82,14 @@ pub enum Filter<Angle, Factor, Length, DropShadow, Url> {
Sepia(Factor),
/// `drop-shadow(...)`
#[css(function)]
DropShadow(DropShadow),
DropShadow(Shadow),
/// `<url>`
#[animation(error)]
Url(Url),
Url(U),
}
pub use self::GenericFilter as Filter;
/// 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