Further changes required by Servo

This commit is contained in:
Oriol Brufau 2023-11-15 21:32:34 +01:00 committed by Martin Robinson
parent 8c1c4073e2
commit b6db94bdf5
9 changed files with 94 additions and 66 deletions

View file

@ -29,6 +29,7 @@ use net_traits::image_cache::UsePlaceholder;
use range::Range;
use servo_config::opts;
use servo_geometry::{self, MaxRect};
use style::color::AbsoluteColor;
use style::computed_values::border_style::T as BorderStyle;
use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::pointer_events::T as PointerEvents;
@ -43,7 +44,6 @@ use style::values::computed::{ClipRectOrAuto, Gradient};
use style::values::generics::background::BackgroundSize;
use style::values::generics::image::PaintWorklet;
use style::values::specified::ui::CursorKind;
use style::values::RGBA;
use style_traits::{CSSPixel, ToCss};
use webrender_api::units::{LayoutRect, LayoutTransform, LayoutVector2D};
use webrender_api::{
@ -671,7 +671,7 @@ impl Fragment {
state: &mut DisplayListBuildState,
style: &ComputedValues,
background: &style_structs::Background,
background_color: RGBA,
background_color: AbsoluteColor,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
) {
@ -2202,7 +2202,7 @@ impl Fragment {
fn build_display_list_for_text_decoration(
&self,
state: &mut DisplayListBuildState,
color: &RGBA,
color: &AbsoluteColor,
stacking_relative_box: &LogicalRect<Au>,
clip: Rect<Au>,
) {
@ -2860,7 +2860,7 @@ impl BlockFlow {
&self,
state: &mut DisplayListBuildState,
background: &style_structs::Background,
background_color: RGBA,
background_color: AbsoluteColor,
) {
let stacking_relative_border_box = self
.base

View file

@ -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,
)
}
}