style: linear() easing function should not consider less than 2 linear stop arguments valid

Latest spec no longer handles `linear() == linear` and `linear(<single value>) == <single value>`.

Differential Revision: https://phabricator.services.mozilla.com/D169955
This commit is contained in:
David Shin 2023-02-17 17:13:21 +00:00 committed by Martin Robinson
parent d76fe81600
commit 017ab0cb24

View file

@ -136,10 +136,8 @@ impl TimingFunction {
if !linear_timing_function_enabled() {
return Err(input.new_custom_error(StyleParseErrorKind::ExperimentalProperty));
}
if input.is_exhausted() {
return Ok(GenericTimingFunction::LinearFunction(LinearStops::default()));
}
let mut result = vec![];
// Closely follows `parse_comma_separated`, but can generate multiple entries for one comma-separated entry.
loop {
input.parse_until_before(Delimiter::Comma, |i| {
let mut input_start = i.try_parse(|i| Percentage::parse(context, i)).ok();
@ -175,6 +173,9 @@ impl TimingFunction {
Ok(_) => unreachable!(),
}
}
if result.len() < 2 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(GenericTimingFunction::LinearFunction(LinearStops::new(
crate::OwnedSlice::from(result),