mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
style: Add computed value ZeroToOneNumber.
Correctly handle clamping to 1 behavior of grayscale(), invert(), opacity() and sepia(). Differential Revision: https://phabricator.services.mozilla.com/D35509
This commit is contained in:
parent
9939c1ee07
commit
2fba62aba9
6 changed files with 132 additions and 73 deletions
|
@ -52,34 +52,34 @@ pub use self::GenericBoxShadow as BoxShadow;
|
|||
ToShmem,
|
||||
)]
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericFilter<Angle, Factor, Length, Shadow, U> {
|
||||
pub enum GenericFilter<Angle, NonNegativeFactor, ZeroToOneFactor, Length, Shadow, U> {
|
||||
/// `blur(<length>)`
|
||||
#[css(function)]
|
||||
Blur(Length),
|
||||
/// `brightness(<factor>)`
|
||||
#[css(function)]
|
||||
Brightness(Factor),
|
||||
Brightness(NonNegativeFactor),
|
||||
/// `contrast(<factor>)`
|
||||
#[css(function)]
|
||||
Contrast(Factor),
|
||||
Contrast(NonNegativeFactor),
|
||||
/// `grayscale(<factor>)`
|
||||
#[css(function)]
|
||||
Grayscale(Factor),
|
||||
Grayscale(ZeroToOneFactor),
|
||||
/// `hue-rotate(<angle>)`
|
||||
#[css(function)]
|
||||
HueRotate(Angle),
|
||||
/// `invert(<factor>)`
|
||||
#[css(function)]
|
||||
Invert(Factor),
|
||||
Invert(ZeroToOneFactor),
|
||||
/// `opacity(<factor>)`
|
||||
#[css(function)]
|
||||
Opacity(Factor),
|
||||
Opacity(ZeroToOneFactor),
|
||||
/// `saturate(<factor>)`
|
||||
#[css(function)]
|
||||
Saturate(Factor),
|
||||
Saturate(NonNegativeFactor),
|
||||
/// `sepia(<factor>)`
|
||||
#[css(function)]
|
||||
Sepia(Factor),
|
||||
Sepia(ZeroToOneFactor),
|
||||
/// `drop-shadow(...)`
|
||||
#[css(function)]
|
||||
DropShadow(Shadow),
|
||||
|
|
|
@ -227,6 +227,28 @@ impl<T: Zero> Zero for NonNegative<T> {
|
|||
)]
|
||||
pub struct GreaterThanOrEqualToOne<T>(pub T);
|
||||
|
||||
/// A wrapper of values between zero and one.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
ComputeSquaredDistance,
|
||||
Copy,
|
||||
Debug,
|
||||
Hash,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
SpecifiedValueInfo,
|
||||
ToAnimatedZero,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct ZeroToOne<T>(pub T);
|
||||
|
||||
/// A clip rect for clip and image-region
|
||||
#[allow(missing_docs)]
|
||||
#[derive(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue