From a19674a5a74d1af5be599c3b7f9317de9b399358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 22 Jun 2022 23:02:34 +0000 Subject: [PATCH] style: Use style interpolation code for gradients This ensures they're clamped on Animated -> sRGB conversion, and in the future we'll have to implement different color spaces so we'll need to use it anyways. Differential Revision: https://phabricator.services.mozilla.com/D149792 --- components/style/values/animated/color.rs | 4 +++- components/style/values/computed/color.rs | 2 +- components/style/values/generics/color.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/style/values/animated/color.rs b/components/style/values/animated/color.rs index cdfa45dc4e7..e79961661b9 100644 --- a/components/style/values/animated/color.rs +++ b/components/style/values/animated/color.rs @@ -19,7 +19,7 @@ use std::f32::consts::PI; /// range `[0.0, 1.0]`. #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero, ToAnimatedValue)] #[repr(C)] -pub struct RGBA { +pub struct AnimatedRGBA { /// The red component. pub red: f32, /// The green component. @@ -30,6 +30,8 @@ pub struct RGBA { pub alpha: f32, } +use self::AnimatedRGBA as RGBA; + const RAD_PER_DEG: f32 = PI / 180.0; const DEG_PER_RAD: f32 = 180.0 / PI; diff --git a/components/style/values/computed/color.rs b/components/style/values/computed/color.rs index 573cb6fe500..1229793c714 100644 --- a/components/style/values/computed/color.rs +++ b/components/style/values/computed/color.rs @@ -4,7 +4,7 @@ //! Computed color values. -use crate::values::animated::color::RGBA as AnimatedRGBA; +use crate::values::animated::color::AnimatedRGBA; use crate::values::animated::ToAnimatedValue; use crate::values::generics::color::{GenericCaretColor, GenericColor, GenericColorOrAuto}; use crate::values::computed::percentage::Percentage; diff --git a/components/style/values/generics/color.rs b/components/style/values/generics/color.rs index 7ab3880bc1a..65acfee9061 100644 --- a/components/style/values/generics/color.rs +++ b/components/style/values/generics/color.rs @@ -9,7 +9,7 @@ use style_traits::{CssWriter, ParseError, ToCss}; use crate::values::{Parse, ParserContext, Parser}; use crate::values::specified::percentage::ToPercentage; use crate::values::animated::ToAnimatedValue; -use crate::values::animated::color::RGBA as AnimatedRGBA; +use crate::values::animated::color::AnimatedRGBA; /// This struct represents a combined color from a numeric color and /// the current foreground color (currentcolor keyword).