mirror of
https://github.com/servo/servo.git
synced 2025-08-13 09:25:32 +01:00
Update Stylo to 2023-09-01 (#31609)
* Update Stylo to 2023-09-01 * Fixup for https://phabricator.services.mozilla.com/D184929 * Fixup for https://phabricator.services.mozilla.com/D184526 * Fixup for https://phabricator.services.mozilla.com/D184525 * Fixup for https://phabricator.services.mozilla.com/D185154 * Fixup for https://phabricator.services.mozilla.com/D184685 * Fixup for https://phabricator.services.mozilla.com/D185916 * Fixup for https://phabricator.services.mozilla.com/D185492 * Fixup for https://phabricator.services.mozilla.com/D186626 * Update test expectations
This commit is contained in:
parent
94c1f2c992
commit
c07484fcb6
67 changed files with 235 additions and 491 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use style::color::AbsoluteColor;
|
||||
use style::color::{AbsoluteColor, ColorSpace};
|
||||
use style::values::animated::{Animate, Procedure, ToAnimatedValue};
|
||||
|
||||
fn interpolate_color(from: AbsoluteColor, to: AbsoluteColor, progress: f64) -> AbsoluteColor {
|
||||
|
@ -14,28 +14,40 @@ fn interpolate_color(from: AbsoluteColor, to: AbsoluteColor, progress: f64) -> A
|
|||
)
|
||||
}
|
||||
|
||||
fn srgb_legacy_from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> AbsoluteColor {
|
||||
AbsoluteColor::new(ColorSpace::Srgb, red, green, blue, alpha).into_srgb_legacy()
|
||||
}
|
||||
|
||||
// Color
|
||||
#[test]
|
||||
fn test_rgba_color_interepolation_preserves_transparent() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::transparent(),
|
||||
AbsoluteColor::transparent(),
|
||||
0.5
|
||||
),
|
||||
AbsoluteColor::transparent()
|
||||
interpolate_color(AbsoluteColor::TRANSPARENT, AbsoluteColor::TRANSPARENT, 0.5),
|
||||
AbsoluteColor::TRANSPARENT
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgba_color_interepolation_alpha() {
|
||||
fn test_rgba_color_interepolation_alpha_1() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::srgb(0.6, 0.0, 0.0, 0.4),
|
||||
AbsoluteColor::srgb(0.0, 0.6, 0.0, 0.8),
|
||||
AbsoluteColor::srgb_legacy(150, 0, 0, 0.4),
|
||||
AbsoluteColor::srgb_legacy(0, 150, 0, 0.8),
|
||||
0.5
|
||||
),
|
||||
AbsoluteColor::srgb(0.2, 0.4, 0.0, 0.6)
|
||||
AbsoluteColor::srgb_legacy(50, 100, 0, 0.6)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgba_color_interepolation_alpha_2() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
srgb_legacy_from_floats(0.6, 0.0, 0.0, 0.4),
|
||||
srgb_legacy_from_floats(0.0, 0.6, 0.0, 0.8),
|
||||
0.5
|
||||
),
|
||||
srgb_legacy_from_floats(0.2, 0.4, 0.0, 0.6)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -43,13 +55,15 @@ fn test_rgba_color_interepolation_alpha() {
|
|||
fn test_rgba_color_interepolation_out_of_range_1() {
|
||||
// Some cubic-bezier functions produce values that are out of range [0, 1].
|
||||
// Unclamped cases.
|
||||
// Note `AbsoluteColor::srgb_legacy` doesn't accept out of range values,
|
||||
// so we only test with `srgb_legacy_from_floats`.
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::srgb(0.3, 0.0, 0.0, 0.4),
|
||||
AbsoluteColor::srgb(0.0, 1.0, 0.0, 0.6),
|
||||
srgb_legacy_from_floats(0.3, 0.0, 0.0, 0.4),
|
||||
srgb_legacy_from_floats(0.0, 1.0, 0.0, 0.6),
|
||||
-0.5
|
||||
),
|
||||
AbsoluteColor::srgb(0.6, -1.0, 0.0, 0.3)
|
||||
srgb_legacy_from_floats(0.6, -1.0, 0.0, 0.3)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -57,11 +71,11 @@ fn test_rgba_color_interepolation_out_of_range_1() {
|
|||
fn test_rgba_color_interepolation_out_of_range_2() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::srgb(1.0, 0.0, 0.0, 0.6),
|
||||
AbsoluteColor::srgb(0.0, 0.3, 0.0, 0.4),
|
||||
srgb_legacy_from_floats(1.0, 0.0, 0.0, 0.6),
|
||||
srgb_legacy_from_floats(0.0, 0.3, 0.0, 0.4),
|
||||
1.5
|
||||
),
|
||||
AbsoluteColor::srgb(-1.0, 0.6, 0.0, 0.3)
|
||||
srgb_legacy_from_floats(-1.0, 0.6, 0.0, 0.3)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -69,11 +83,11 @@ fn test_rgba_color_interepolation_out_of_range_2() {
|
|||
fn test_rgba_color_interepolation_out_of_range_clamped_1() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::srgb(1.0, 0.0, 0.0, 0.8),
|
||||
AbsoluteColor::srgb(0.0, 1.0, 0.0, 0.2),
|
||||
srgb_legacy_from_floats(1.0, 0.0, 0.0, 0.8),
|
||||
srgb_legacy_from_floats(0.0, 1.0, 0.0, 0.2),
|
||||
-0.5
|
||||
),
|
||||
AbsoluteColor::srgb(1.2, -0.1, 0.0, 1.0)
|
||||
srgb_legacy_from_floats(1.2, -0.1, 0.0, 1.0)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,10 +95,10 @@ fn test_rgba_color_interepolation_out_of_range_clamped_1() {
|
|||
fn test_rgba_color_interepolation_out_of_range_clamped_2() {
|
||||
assert_eq!(
|
||||
interpolate_color(
|
||||
AbsoluteColor::srgb(1.0, 0.0, 0.0, 0.8),
|
||||
AbsoluteColor::srgb(0.0, 1.0, 0.0, 0.2),
|
||||
srgb_legacy_from_floats(1.0, 0.0, 0.0, 0.8),
|
||||
srgb_legacy_from_floats(0.0, 1.0, 0.0, 0.2),
|
||||
1.5
|
||||
),
|
||||
AbsoluteColor::srgb(-0.4, 0.3, 0.0, 0.0)
|
||||
srgb_legacy_from_floats(-0.4, 0.3, 0.0, 0.0)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue