Bug 1900530 - Allow gradient defined by a single color stop. r=layout-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D233218
This commit is contained in:
Jonathan Kew
2025-01-06 19:50:26 +00:00
parent 46933ebefe
commit 24f94d5353
4 changed files with 13 additions and 11 deletions

View File

@@ -786,7 +786,7 @@ impl Gradient {
) -> Result<LengthPercentageItemList, ParseError<'i>> {
let items =
generic::GradientItem::parse_comma_separated(context, input, LengthPercentage::parse)?;
if items.len() < 2 {
if items.is_empty() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(items)
@@ -966,7 +966,7 @@ impl Gradient {
AngleOrPercentage::parse_with_unitless,
)?;
if items.len() < 2 {
if items.is_empty() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
@@ -1249,7 +1249,7 @@ impl<T> generic::GradientItem<Color, T> {
}
}
if !seen_stop || items.len() < 2 {
if !seen_stop || items.is_empty() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(items.into())