Skip to content

Commit aac89c5

Browse files
Loirooriolemilio
andauthored
Upgrade cssparser to version 0.36 (#262)
* Upgrade cssparser to version 0.36 Signed-off-by: Oriol Brufau <[email protected]> * Bug 1996318 - Add display-p3-linear color-space to css color(). r=firefox-style-system-reviewers,dshin,supply-chain-reviewers It's display-p3 without gamma encoding. cssparser change will obviously go upstream. Differential Revision: https://phabricator.services.mozilla.com/D270012 --------- Signed-off-by: Oriol Brufau <[email protected]> Co-authored-by: Emilio Cobos Álvarez <[email protected]>
1 parent a9f1997 commit aac89c5

File tree

9 files changed

+48
-9
lines changed

9 files changed

+48
-9
lines changed

malloc_size_of/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ servo = ["string_cache"]
1515

1616
[dependencies]
1717
app_units = "0.7"
18-
cssparser = "0.35"
18+
cssparser = "0.36"
1919
euclid = "0.22"
2020
selectors = { workspace = true }
2121
servo_arc = { workspace = true }

selectors/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ to_shmem = ["dep:to_shmem", "dep:to_shmem_derive"]
2121

2222
[dependencies]
2323
bitflags = "2"
24-
cssparser = "0.35"
24+
cssparser = "0.36"
2525
derive_more = { version = "2", features = ["add", "add_assign"] }
2626
rustc-hash = "2.1.1"
2727
log = "0.4"

style/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ arrayvec = "0.7"
5858
atomic_refcell = "0.1"
5959
bitflags = "2"
6060
byteorder = "1.0"
61-
cssparser = "0.35"
61+
cssparser = "0.36"
6262
derive_more = { version = "2", features = ["add", "add_assign", "deref", "deref_mut", "from"] }
6363
dom = { workspace = true }
6464
new_debug_unreachable = "1.0"

style/color/convert.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,28 @@ impl ColorSpaceConversion for DisplayP3 {
487487
}
488488
}
489489

490+
/// The Display-P3-linear color space. This is basically display-p3 without gamma encoding.
491+
pub struct DisplayP3Linear;
492+
impl ColorSpaceConversion for DisplayP3Linear {
493+
const WHITE_POINT: WhitePoint = DisplayP3::WHITE_POINT;
494+
495+
fn to_linear_light(from: &ColorComponents) -> ColorComponents {
496+
*from
497+
}
498+
499+
fn to_xyz(from: &ColorComponents) -> ColorComponents {
500+
DisplayP3::to_xyz(from)
501+
}
502+
503+
fn from_xyz(from: &ColorComponents) -> ColorComponents {
504+
DisplayP3::from_xyz(from)
505+
}
506+
507+
fn to_gamma_encoded(from: &ColorComponents) -> ColorComponents {
508+
*from
509+
}
510+
}
511+
490512
/// The a98-rgb color space.
491513
/// https://drafts.csswg.org/css-color-4/#predefined-a98-rgb
492514
pub struct A98Rgb;

style/color/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ pub enum ColorSpace {
103103
/// A color specified with the color(..) function and the "display-p3"
104104
/// color space, e.g. "color(display-p3 0.84 0.19 0.72)".
105105
DisplayP3,
106+
/// A color specified with the color(..) function and the "display-p3-linear"
107+
/// color space.
108+
DisplayP3Linear,
106109
/// A color specified with the color(..) function and the "a98-rgb" color
107110
/// space, e.g. "color(a98-rgb 0.44091 0.49971 0.37408)".
108111
A98Rgb,
@@ -143,6 +146,7 @@ impl ColorSpace {
143146
Self::Srgb
144147
| Self::SrgbLinear
145148
| Self::DisplayP3
149+
| Self::DisplayP3Linear
146150
| Self::A98Rgb
147151
| Self::ProphotoRgb
148152
| Self::Rec2020
@@ -506,6 +510,7 @@ impl AbsoluteColor {
506510
},
507511
ColorSpace::SrgbLinear
508512
| ColorSpace::DisplayP3
513+
| ColorSpace::DisplayP3Linear
509514
| ColorSpace::A98Rgb
510515
| ColorSpace::ProphotoRgb
511516
| ColorSpace::Rec2020 => match channel_keyword {
@@ -576,6 +581,7 @@ impl AbsoluteColor {
576581
Hwb => convert::to_xyz::<convert::Hwb>(&components),
577582
SrgbLinear => convert::to_xyz::<convert::SrgbLinear>(&components),
578583
DisplayP3 => convert::to_xyz::<convert::DisplayP3>(&components),
584+
DisplayP3Linear => convert::to_xyz::<convert::DisplayP3Linear>(&components),
579585
A98Rgb => convert::to_xyz::<convert::A98Rgb>(&components),
580586
ProphotoRgb => convert::to_xyz::<convert::ProphotoRgb>(&components),
581587
Rec2020 => convert::to_xyz::<convert::Rec2020>(&components),
@@ -593,6 +599,9 @@ impl AbsoluteColor {
593599
Hwb => convert::from_xyz::<convert::Hwb>(&xyz, white_point),
594600
SrgbLinear => convert::from_xyz::<convert::SrgbLinear>(&xyz, white_point),
595601
DisplayP3 => convert::from_xyz::<convert::DisplayP3>(&xyz, white_point),
602+
DisplayP3Linear => {
603+
convert::from_xyz::<convert::DisplayP3Linear>(&xyz, white_point)
604+
},
596605
A98Rgb => convert::from_xyz::<convert::A98Rgb>(&xyz, white_point),
597606
ProphotoRgb => convert::from_xyz::<convert::ProphotoRgb>(&xyz, white_point),
598607
Rec2020 => convert::from_xyz::<convert::Rec2020>(&xyz, white_point),
@@ -630,6 +639,7 @@ impl From<PredefinedColorSpace> for ColorSpace {
630639
PredefinedColorSpace::Srgb => ColorSpace::Srgb,
631640
PredefinedColorSpace::SrgbLinear => ColorSpace::SrgbLinear,
632641
PredefinedColorSpace::DisplayP3 => ColorSpace::DisplayP3,
642+
PredefinedColorSpace::DisplayP3Linear => ColorSpace::DisplayP3Linear,
633643
PredefinedColorSpace::A98Rgb => ColorSpace::A98Rgb,
634644
PredefinedColorSpace::ProphotoRgb => ColorSpace::ProphotoRgb,
635645
PredefinedColorSpace::Rec2020 => ColorSpace::Rec2020,

style/color/to_css.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,20 @@ impl ToCss for AbsoluteColor {
128128
},
129129
ColorSpace::SrgbLinear
130130
| ColorSpace::DisplayP3
131+
| ColorSpace::DisplayP3Linear
131132
| ColorSpace::A98Rgb
132133
| ColorSpace::ProphotoRgb
133134
| ColorSpace::Rec2020
134135
| ColorSpace::XyzD50
135136
| ColorSpace::XyzD65 => {
136137
// These color spaces are allowed.
137138
},
138-
_ => {
139+
ColorSpace::Hsl
140+
| ColorSpace::Hwb
141+
| ColorSpace::Lab
142+
| ColorSpace::Oklab
143+
| ColorSpace::Lch
144+
| ColorSpace::Oklch => {
139145
unreachable!("other color spaces do not support color() syntax")
140146
},
141147
};
@@ -269,6 +275,7 @@ impl AbsoluteColor {
269275
},
270276
ColorSpace::SrgbLinear
271277
| ColorSpace::DisplayP3
278+
| ColorSpace::DisplayP3Linear
272279
| ColorSpace::A98Rgb
273280
| ColorSpace::ProphotoRgb
274281
| ColorSpace::Rec2020

style/properties/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,10 @@ fn parse_non_custom_property_declaration_value_into<'i>(
745745
};
746746

747747
input.reset(&start);
748-
input.look_for_var_or_env_functions();
748+
input.look_for_arbitrary_substitution_functions(&["var", "env"]);
749749
let err = match parse_entirely_into(declarations, input) {
750750
Ok(()) => {
751-
input.seen_var_or_env_functions();
751+
input.seen_arbitrary_substitution_functions();
752752
return Ok(());
753753
},
754754
Err(e) => e,
@@ -770,7 +770,7 @@ fn parse_non_custom_property_declaration_value_into<'i>(
770770
}
771771
at_start = false;
772772
}
773-
if !input.seen_var_or_env_functions() || invalid {
773+
if !input.seen_arbitrary_substitution_functions() || invalid {
774774
return Err(err);
775775
}
776776
input.reset(start);

style_traits/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gecko = []
2020
[dependencies]
2121
app_units = "0.7"
2222
bitflags = "2"
23-
cssparser = "0.35"
23+
cssparser = "0.36"
2424
euclid = "0.22"
2525
malloc_size_of = { workspace = true}
2626
malloc_size_of_derive = "0.1"

to_shmem/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ string_cache = ["dep:string_cache"]
2323
thin-vec = ["dep:thin-vec"]
2424

2525
[dependencies]
26-
cssparser = { version = "0.35", optional = true }
26+
cssparser = { version = "0.36", optional = true }
2727
servo_arc = { workspace = true, optional = true }
2828
smallbitvec = { version = "2.3.0", optional = true }
2929
smallvec = { version = "1.13", optional = true }

0 commit comments

Comments
 (0)