Oriol Brufau 2024-03-18 14:52:40 +01:00 committed by GitHub
parent 94c1f2c992
commit c07484fcb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 235 additions and 491 deletions

View file

@ -984,7 +984,7 @@ impl Fragment {
ref direction,
ref color_interpolation_method,
ref items,
ref repeating,
ref flags,
compat_mode: _,
} => {
let (gradient, stops) = gradient::linear(
@ -993,7 +993,7 @@ impl Fragment {
items,
*direction,
color_interpolation_method,
*repeating,
*flags,
);
let item = webrender_api::GradientDisplayItem {
gradient,
@ -1009,7 +1009,7 @@ impl Fragment {
ref position,
ref color_interpolation_method,
ref items,
ref repeating,
ref flags,
compat_mode: _,
} => {
let (gradient, stops) = gradient::radial(
@ -1019,7 +1019,7 @@ impl Fragment {
shape,
position,
color_interpolation_method,
*repeating,
*flags,
);
let item = webrender_api::RadialGradientDisplayItem {
gradient,
@ -1252,7 +1252,7 @@ impl Fragment {
ref direction,
ref color_interpolation_method,
ref items,
ref repeating,
ref flags,
compat_mode: _,
} => {
let (wr_gradient, linear_stops) = gradient::linear(
@ -1261,7 +1261,7 @@ impl Fragment {
items,
*direction,
color_interpolation_method,
*repeating,
*flags,
);
stops = linear_stops;
NinePatchBorderSource::Gradient(wr_gradient)
@ -1271,7 +1271,7 @@ impl Fragment {
ref position,
ref color_interpolation_method,
ref items,
ref repeating,
ref flags,
compat_mode: _,
} => {
let (wr_gradient, radial_stops) = gradient::radial(
@ -1281,7 +1281,7 @@ impl Fragment {
shape,
position,
color_interpolation_method,
*repeating,
*flags,
);
stops = radial_stops;
NinePatchBorderSource::RadialGradient(wr_gradient)

View file

@ -8,7 +8,9 @@ use style::color::mix::ColorInterpolationMethod;
use style::properties::ComputedValues;
use style::values::computed::image::{EndingShape, LineDirection};
use style::values::computed::{Angle, Color, LengthPercentage, Percentage, Position};
use style::values::generics::image::{Circle, ColorStop, Ellipse, GradientItem, ShapeExtent};
use style::values::generics::image::{
Circle, ColorStop, Ellipse, GradientFlags, GradientItem, ShapeExtent,
};
use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient};
use crate::display_list::ToLayout;
@ -242,10 +244,11 @@ pub fn linear(
stops: &[GradientItem<Color, LengthPercentage>],
direction: LineDirection,
_color_interpolation_method: &ColorInterpolationMethod,
repeating: bool,
flags: GradientFlags,
) -> (Gradient, Vec<GradientStop>) {
use style::values::specified::position::HorizontalPositionKeyword::*;
use style::values::specified::position::VerticalPositionKeyword::*;
let repeating = flags.contains(GradientFlags::REPEATING);
let angle = match direction {
LineDirection::Angle(angle) => angle.radians(),
LineDirection::Horizontal(x) => match x {
@ -310,8 +313,9 @@ pub fn radial(
shape: &EndingShape,
center: &Position,
_color_interpolation_method: &ColorInterpolationMethod,
repeating: bool,
flags: GradientFlags,
) -> (RadialGradient, Vec<GradientStop>) {
let repeating = flags.contains(GradientFlags::REPEATING);
let center = Point2D::new(
center.horizontal.to_used_value(size.width),
center.vertical.to_used_value(size.height),