aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/display_list/conversions.rs
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2023-11-15 21:32:34 +0100
committerMartin Robinson <mrobinson@igalia.com>2023-11-21 15:36:35 +0100
commitb6db94bdf5fdb59550380a0b0b3f418afb01965f (patch)
treed1d5d360e2b001e46fe1984a1f80ee0a0de66ecf /components/layout/display_list/conversions.rs
parent8c1c4073e250502822604c71fcaab9c183e4372a (diff)
downloadservo-b6db94bdf5fdb59550380a0b0b3f418afb01965f.tar.gz
servo-b6db94bdf5fdb59550380a0b0b3f418afb01965f.zip
Further changes required by Servo
Diffstat (limited to 'components/layout/display_list/conversions.rs')
-rw-r--r--components/layout/display_list/conversions.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/components/layout/display_list/conversions.rs b/components/layout/display_list/conversions.rs
index 112e6c00d6b..c4f6dc5f04b 100644
--- a/components/layout/display_list/conversions.rs
+++ b/components/layout/display_list/conversions.rs
@@ -4,12 +4,12 @@
use app_units::Au;
use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
+use style::color::{AbsoluteColor, ColorSpace};
use style::computed_values::image_rendering::T as ImageRendering;
use style::computed_values::mix_blend_mode::T as MixBlendMode;
use style::computed_values::transform_style::T as TransformStyle;
use style::values::computed::{BorderStyle, Filter};
use style::values::specified::border::BorderImageRepeatKeyword;
-use style::values::RGBA;
use webrender_api as wr;
pub trait ToLayout {
@@ -19,7 +19,7 @@ pub trait ToLayout {
pub trait FilterToLayout {
type Type;
- fn to_layout(&self, current_color: &RGBA) -> Self::Type;
+ fn to_layout(&self, current_color: &AbsoluteColor) -> Self::Type;
}
impl ToLayout for BorderStyle {
@@ -42,7 +42,7 @@ impl ToLayout for BorderStyle {
impl FilterToLayout for Filter {
type Type = wr::FilterOp;
- fn to_layout(&self, current_color: &RGBA) -> Self::Type {
+ fn to_layout(&self, current_color: &AbsoluteColor) -> Self::Type {
match *self {
Filter::Blur(radius) => wr::FilterOp::Blur(radius.px(), radius.px()),
Filter::Brightness(amount) => wr::FilterOp::Brightness(amount.0),
@@ -59,7 +59,11 @@ impl FilterToLayout for Filter {
shadow.horizontal.px(),
shadow.vertical.px(),
),
- color: shadow.color.clone().into_rgba(*current_color).to_layout(),
+ color: shadow
+ .color
+ .clone()
+ .resolve_into_absolute(current_color)
+ .to_layout(),
}),
// Statically check that Url is impossible.
Filter::Url(ref url) => match *url {},
@@ -112,14 +116,15 @@ impl ToLayout for TransformStyle {
}
}
-impl ToLayout for RGBA {
+impl ToLayout for AbsoluteColor {
type Type = wr::ColorF;
fn to_layout(&self) -> Self::Type {
+ let rgba = self.to_color_space(ColorSpace::Srgb);
wr::ColorF::new(
- self.red_f32(),
- self.green_f32(),
- self.blue_f32(),
- self.alpha_f32(),
+ rgba.components.0.clamp(0.0, 1.0),
+ rgba.components.1.clamp(0.0, 1.0),
+ rgba.components.2.clamp(0.0, 1.0),
+ rgba.alpha,
)
}
}