mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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:
parent
0e5eca1f00
commit
11a04d9d93
3 changed files with 16 additions and 20 deletions
|
@ -237,7 +237,7 @@ impl<Image> Content<Image> {
|
||||||
|
|
||||||
/// Items for the `content` property.
|
/// Items for the `content` property.
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem,
|
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem,
|
||||||
)]
|
)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum GenericContentItem<I> {
|
pub enum GenericContentItem<I> {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::values::specified::Integer;
|
||||||
use crate::values::CustomIdent;
|
use crate::values::CustomIdent;
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
use style_traits::{KeywordsCollectFn, ParseError, SpecifiedValueInfo, StyleParseErrorKind};
|
use style_traits::{ParseError, StyleParseErrorKind};
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum CounterType {
|
enum CounterType {
|
||||||
|
@ -201,7 +201,7 @@ impl Parse for Content {
|
||||||
let mut has_alt_content = false;
|
let mut has_alt_content = false;
|
||||||
loop {
|
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));
|
content.push(generics::ContentItem::Image(image));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -279,20 +279,3 @@ impl Parse for Content {
|
||||||
Ok(generics::Content::Items(content.into()))
|
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",
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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.
|
/// Provides an alternate method for parsing, but only for urls.
|
||||||
pub fn parse_only_url<'i, 't>(
|
pub fn parse_only_url<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue