Bug 1856524 - [css-properties-values-api] Compute <length> and <length-percentage>. r=firefox-style-system-reviewers,emilio

Also added a TODO for bug 1856522 for accurately computing registered
custom properties containing font-relative units.

Differential Revision: https://phabricator.services.mozilla.com/D194024
This commit is contained in:
Zach Hoffman 2023-11-21 11:53:05 +00:00
Родитель 8e045b102b
Коммит b723d6a79a
9 изменённых файлов: 17 добавлений и 163 удалений

Просмотреть файл

@ -930,6 +930,9 @@ impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
if let Some(registration) = custom_registration {
let mut input = ParserInput::new(&unparsed_value.css);
let mut input = Parser::new(&mut input);
// TODO(bug 1856522): Substitute custom property references in font-*
// declarations before computing registered custom properties containing
// font-relative units.
if let Ok(value) = SpecifiedRegisteredValue::compute(
&mut input,
registration,

Просмотреть файл

@ -30,12 +30,10 @@ use style_traits::{
/// A single component of the computed value.
pub type ComputedValueComponent = GenericValueComponent<
// TODO(zrhoffman, bug 1856524): Use computed::Length
specified::Length,
computed::Length,
computed::Number,
computed::Percentage,
// TODO(zrhoffman, bug 1856524): Use computed::LengthPercentage
specified::LengthPercentage,
computed::LengthPercentage,
computed::Color,
computed::Image,
computed::url::ComputedUrl,
@ -143,11 +141,9 @@ impl ToComputedValue for SpecifiedValueComponent {
fn to_computed_value(&self, context: &computed::Context) -> Self::ComputedValue {
match self {
SpecifiedValueComponent::Length(length) => ComputedValueComponent::Length(
// TODO(zrhoffman, bug 1856524): Compute <length>, which may contain font-relative
// units
length.clone(),
),
SpecifiedValueComponent::Length(length) => {
ComputedValueComponent::Length(length.to_computed_value(context))
},
SpecifiedValueComponent::Number(number) => {
ComputedValueComponent::Number(number.to_computed_value(context))
},
@ -155,9 +151,9 @@ impl ToComputedValue for SpecifiedValueComponent {
ComputedValueComponent::Percentage(percentage.to_computed_value(context))
},
SpecifiedValueComponent::LengthPercentage(length_percentage) => {
// TODO(zrhoffman, bug 1856524): Compute <length-percentage>, which may contain
// font-relative units
ComputedValueComponent::LengthPercentage(length_percentage.clone())
ComputedValueComponent::LengthPercentage(
length_percentage.to_computed_value(context),
)
},
SpecifiedValueComponent::Color(color) => {
ComputedValueComponent::Color(color.to_computed_value(context))
@ -200,10 +196,9 @@ impl ToComputedValue for SpecifiedValueComponent {
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match computed {
ComputedValueComponent::Length(length) => SpecifiedValueComponent::Length(
// TODO(zrhoffman, bug 1856524): Use computed <length>
length.clone(),
),
ComputedValueComponent::Length(length) => {
SpecifiedValueComponent::Length(ToComputedValue::from_computed_value(length))
},
ComputedValueComponent::Number(number) => {
SpecifiedValueComponent::Number(ToComputedValue::from_computed_value(number))
},
@ -211,8 +206,9 @@ impl ToComputedValue for SpecifiedValueComponent {
ToComputedValue::from_computed_value(percentage),
),
ComputedValueComponent::LengthPercentage(length_percentage) => {
// TODO(zrhoffman, bug 1856524): Use computed <length-percentage>
SpecifiedValueComponent::LengthPercentage(length_percentage.clone())
SpecifiedValueComponent::LengthPercentage(ToComputedValue::from_computed_value(
length_percentage,
))
},
ComputedValueComponent::Color(color) => {
SpecifiedValueComponent::Color(ToComputedValue::from_computed_value(color))

Просмотреть файл

@ -1,4 +0,0 @@
[at-property-shadow.html]
[@property rules in shadow trees should have no effect]
expected: FAIL

Просмотреть файл

@ -1,72 +0,0 @@
[at-property-viewport-units.html]
[10vw is 40px]
expected: FAIL
[10vh is 20px]
expected: FAIL
[10vi is 40px]
expected: FAIL
[10vb is 20px]
expected: FAIL
[10vmin is 20px]
expected: FAIL
[10vmax is 40px]
expected: FAIL
[10svw is 40px]
expected: FAIL
[10svh is 20px]
expected: FAIL
[10svi is 40px]
expected: FAIL
[10svb is 20px]
expected: FAIL
[10svmin is 20px]
expected: FAIL
[10svmax is 40px]
expected: FAIL
[10lvw is 40px]
expected: FAIL
[10lvh is 20px]
expected: FAIL
[10lvi is 40px]
expected: FAIL
[10lvb is 20px]
expected: FAIL
[10lvmin is 20px]
expected: FAIL
[10lvmax is 40px]
expected: FAIL
[10dvw is 40px]
expected: FAIL
[10dvh is 20px]
expected: FAIL
[10dvi is 40px]
expected: FAIL
[10dvb is 20px]
expected: FAIL
[10dvmin is 20px]
expected: FAIL
[10dvmax is 40px]
expected: FAIL

Просмотреть файл

@ -1,3 +0,0 @@
[determine-registration.html]
[Computed value becomes token sequence when @property is removed]
expected: FAIL

Просмотреть файл

@ -1,9 +1,3 @@
[registered-properties-inheritance.html]
[Registered properties are correctly inherited (or not) depending on the inherits flag.]
expected: FAIL
[Font-relative units are absolutized before before inheritance]
expected: FAIL
[Calc expressions are resolved before inheritance]
expected: FAIL

Просмотреть файл

@ -11,30 +11,15 @@
[<length> values are computed correctly [14em\]]
expected: FAIL
[<length-percentage># values are computed correctly [3% , 10vmax , 22px\]]
expected: FAIL
[<length> values computed are correctly via var()-reference when font-size is inherited]
expected: FAIL
[<length># values are computed correctly [8em\]]
expected: FAIL
[<length-percentage>+ values are computed correctly [3% 10vmax 22px\]]
expected: FAIL
[<length>+ values are computed correctly [4em 9px\]]
expected: FAIL
[<length> values are computed correctly [13vw\]]
expected: FAIL
[<length-percentage># values are computed correctly [calc(50% + 1em), 4px\]]
expected: FAIL
[<length> values are computed correctly [15vmin\]]
expected: FAIL
[<length-percentage> values are computed correctly [calc(19em - 2%)\]]
expected: FAIL
@ -44,9 +29,6 @@
[<length> values computed are correctly via var()-reference]
expected: FAIL
[<length> values are computed correctly when font-size is inherited [14em\]]
expected: FAIL
[<length> values are computed correctly [calc(16px - 7em + 10vh)\]]
expected: FAIL
@ -59,23 +41,5 @@
[<transform-function> values are computed correctly [translateX(10em)\]]
expected: FAIL
[<length> values are computed correctly when font-size is inherited [calc(14em + 10px)\]]
expected: FAIL
[<length> values are computed correctly [25.4mm\]]
expected: FAIL
[<length> values are computed correctly [6pc\]]
expected: FAIL
[<length> values are computed correctly [1in\]]
expected: FAIL
[<length> values are computed correctly [72pt\]]
expected: FAIL
[<length> values are computed correctly [2.54cm\]]
expected: FAIL
[<length> values are computed correctly [10lh\]]
expected: FAIL

Просмотреть файл

@ -1,25 +1,4 @@
[registered-property-initial.html]
[Initial value for <length> correctly computed [calc(10px + 15px)\]]
expected: FAIL
[Initial non-inherited value can be substituted [calc(10px + 15px), --x\]]
expected: FAIL
[Initial value for <length> correctly computed [2.54cm\]]
expected: FAIL
[Initial value for <length> correctly computed [72pt\]]
expected: FAIL
[Initial value for <length> correctly computed [25.4mm\]]
expected: FAIL
[Initial value for <length> correctly computed [6pc\]]
expected: FAIL
[Initial value for <length> correctly computed [1in\]]
expected: FAIL
[Initial value for <url> correctly computed [url(a)\]]
expected: FAIL

Просмотреть файл

@ -1,7 +1,4 @@
[var-reference-registered-properties.html]
[var() references work with registered properties]
expected: FAIL
[Calc expressions are resolved when substituting]
expected: FAIL