Don’t parse unspported values of content

This commit is contained in:
Simon Sapin 2020-07-23 17:33:50 +02:00
parent 82e274aec9
commit 4a4199c1d6
3 changed files with 13 additions and 5 deletions

View file

@ -4,7 +4,7 @@
//! Specified types for counter properties.
#[cfg(feature = "servo")]
#[cfg(feature = "servo-layout-2013")]
use crate::computed_values::list_style_type::T as ListStyleType;
use crate::parser::{Parse, ParserContext};
use crate::values::generics::counters as generics;
@ -17,6 +17,7 @@ use crate::values::specified::Attr;
use crate::values::specified::Integer;
use crate::values::CustomIdent;
use cssparser::{Parser, Token};
#[cfg(feature = "servo-layout-2013")]
use selectors::parser::SelectorParseErrorKind;
use style_traits::{ParseError, StyleParseErrorKind};
@ -88,7 +89,7 @@ pub type Content = generics::GenericContent<SpecifiedImageUrl>;
pub type ContentItem = generics::GenericContentItem<SpecifiedImageUrl>;
impl Content {
#[cfg(feature = "servo")]
#[cfg(feature = "servo-layout-2013")]
fn parse_counter_style(_: &ParserContext, input: &mut Parser) -> ListStyleType {
input
.try_parse(|input| {
@ -149,12 +150,14 @@ impl Parse for Content {
},
Ok(&Token::Function(ref name)) => {
let result = match_ignore_ascii_case! { &name,
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
"counter" => input.parse_nested_block(|input| {
let location = input.current_source_location();
let name = CustomIdent::from_ident(location, input.expect_ident()?, &[])?;
let style = Content::parse_counter_style(context, input);
Ok(generics::ContentItem::Counter(name, style))
}),
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
"counters" => input.parse_nested_block(|input| {
let location = input.current_source_location();
let name = CustomIdent::from_ident(location, input.expect_ident()?, &[])?;
@ -176,6 +179,7 @@ impl Parse for Content {
}?;
content.push(result);
},
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
Ok(&Token::Ident(ref ident)) => {
content.push(match_ignore_ascii_case! { &ident,
"open-quote" => generics::ContentItem::OpenQuote,