tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

effects.rs (3287B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      4 
      5 //! Generic types for CSS values related to effects.
      6 use crate::derives::*;
      7 
      8 use crate::values::generics::{NonNegative, ZeroToOne};
      9 
     10 /// A generic value for a single `box-shadow`.
     11 #[derive(
     12    Animate,
     13    Clone,
     14    ComputeSquaredDistance,
     15    Debug,
     16    MallocSizeOf,
     17    PartialEq,
     18    SpecifiedValueInfo,
     19    ToAnimatedValue,
     20    ToAnimatedZero,
     21    ToCss,
     22    ToResolvedValue,
     23    ToShmem,
     24 )]
     25 #[repr(C)]
     26 pub struct GenericBoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
     27    /// The base shadow.
     28    pub base: GenericSimpleShadow<Color, SizeLength, BlurShapeLength>,
     29    /// The spread radius.
     30    pub spread: ShapeLength,
     31    /// Whether this is an inset box shadow.
     32    #[animation(constant)]
     33    #[css(represents_keyword)]
     34    pub inset: bool,
     35 }
     36 
     37 pub use self::GenericBoxShadow as BoxShadow;
     38 
     39 /// A generic value for a single `filter`.
     40 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
     41 #[derive(
     42    Clone,
     43    ComputeSquaredDistance,
     44    Debug,
     45    MallocSizeOf,
     46    PartialEq,
     47    SpecifiedValueInfo,
     48    ToAnimatedValue,
     49    ToComputedValue,
     50    ToCss,
     51    ToResolvedValue,
     52    ToShmem,
     53 )]
     54 #[animation(no_bound(U))]
     55 #[repr(C, u8)]
     56 pub enum GenericFilter<Angle, Factor, Length, Shadow, U> {
     57    /// `blur(<length>)`
     58    #[css(function)]
     59    Blur(#[animation(field_bound)] NonNegative<Length>),
     60    /// `brightness(<factor>)`
     61    #[css(function)]
     62    Brightness(#[animation(field_bound)] NonNegative<Factor>),
     63    /// `contrast(<factor>)`
     64    #[css(function)]
     65    Contrast(#[animation(field_bound)] NonNegative<Factor>),
     66    /// `grayscale(<factor>)`
     67    #[css(function)]
     68    Grayscale(#[animation(field_bound)] ZeroToOne<Factor>),
     69    /// `hue-rotate(<angle>)`
     70    #[css(function)]
     71    HueRotate(Angle),
     72    /// `invert(<factor>)`
     73    #[css(function)]
     74    Invert(#[animation(field_bound)] ZeroToOne<Factor>),
     75    /// `opacity(<factor>)`
     76    #[css(function)]
     77    Opacity(#[animation(field_bound)] ZeroToOne<Factor>),
     78    /// `saturate(<factor>)`
     79    #[css(function)]
     80    Saturate(#[animation(field_bound)] NonNegative<Factor>),
     81    /// `sepia(<factor>)`
     82    #[css(function)]
     83    Sepia(#[animation(field_bound)] ZeroToOne<Factor>),
     84    /// `drop-shadow(...)`
     85    #[css(function)]
     86    DropShadow(Shadow),
     87    /// `<url>`
     88    #[animation(error)]
     89    Url(U),
     90 }
     91 
     92 pub use self::GenericFilter as Filter;
     93 
     94 /// A generic value for the `drop-shadow()` filter and the `text-shadow` property.
     95 ///
     96 /// Contrary to the canonical order from the spec, the color is serialised
     97 /// first, like in Gecko and Webkit.
     98 #[derive(
     99    Animate,
    100    Clone,
    101    ComputeSquaredDistance,
    102    Debug,
    103    MallocSizeOf,
    104    PartialEq,
    105    SpecifiedValueInfo,
    106    ToAnimatedValue,
    107    ToAnimatedZero,
    108    ToCss,
    109    ToResolvedValue,
    110    ToShmem,
    111 )]
    112 #[repr(C)]
    113 pub struct GenericSimpleShadow<Color, SizeLength, ShapeLength> {
    114    /// Color.
    115    pub color: Color,
    116    /// Horizontal radius.
    117    pub horizontal: SizeLength,
    118    /// Vertical radius.
    119    pub vertical: SizeLength,
    120    /// Blur radius.
    121    pub blur: ShapeLength,
    122 }
    123 
    124 pub use self::GenericSimpleShadow as SimpleShadow;