style: Support rendering content: <gradient> images

We implemented support for list-style-image anyways.

Differential Revision: https://phabricator.services.mozilla.com/D172343
This commit is contained in:
Emilio Cobos Álvarez 2023-03-14 12:11:34 +00:00 committed by Martin Robinson
parent 0e5eca1f00
commit 11a04d9d93
3 changed files with 16 additions and 20 deletions

View file

@ -237,7 +237,7 @@ impl<Image> Content<Image> {
/// Items for the `content` property.
#[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem,
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem,
)]
#[repr(u8)]
pub enum GenericContentItem<I> {

View file

@ -17,7 +17,7 @@ use crate::values::specified::Integer;
use crate::values::CustomIdent;
use cssparser::{Parser, Token};
use selectors::parser::SelectorParseErrorKind;
use style_traits::{KeywordsCollectFn, ParseError, SpecifiedValueInfo, StyleParseErrorKind};
use style_traits::{ParseError, StyleParseErrorKind};
#[derive(PartialEq)]
enum CounterType {
@ -201,7 +201,7 @@ impl Parse for Content {
let mut has_alt_content = false;
loop {
{
if let Ok(image) = input.try_parse(|i| Image::parse_only_url(context, i)) {
if let Ok(image) = input.try_parse(|i| Image::parse_forbid_none(context, i)) {
content.push(generics::ContentItem::Image(image));
continue;
}
@ -279,20 +279,3 @@ impl Parse for Content {
Ok(generics::Content::Items(content.into()))
}
}
impl<Image> SpecifiedValueInfo for generics::GenericContentItem<Image> {
fn collect_completion_keywords(f: KeywordsCollectFn) {
f(&[
"url",
"image-set",
"counter",
"counters",
"attr",
"open-quote",
"close-quote",
"no-open-quote",
"no-close-quote",
"-moz-alt-content",
]);
}
}

View file

@ -291,6 +291,19 @@ impl Image {
)
}
/// Provides an alternate method for parsing, but forbidding `none`
pub fn parse_forbid_none<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Image, ParseError<'i>> {
Self::parse_with_cors_mode(
context,
input,
CorsMode::None,
ParseImageFlags::FORBID_NONE
)
}
/// Provides an alternate method for parsing, but only for urls.
pub fn parse_only_url<'i, 't>(
context: &ParserContext,