Add support for symbols() function.

This commit is contained in:
Xidorn Quan 2017-05-27 20:06:05 +10:00
parent 9f4a78c2d0
commit 1df685dc40
3 changed files with 97 additions and 17 deletions

View file

@ -337,7 +337,7 @@ impl ToCss for System {
}
/// https://drafts.csswg.org/css-counter-styles/#typedef-symbol
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Symbol {
/// <string>
String(String),
@ -367,6 +367,17 @@ impl ToCss for Symbol {
}
}
impl Symbol {
/// Returns whether this symbol is allowed in symbols() function.
pub fn is_allowed_in_symbols(&self) -> bool {
match self {
// Identifier is not allowed.
&Symbol::Ident(_) => false,
_ => true,
}
}
}
/// https://drafts.csswg.org/css-counter-styles/#counter-style-negative
#[derive(Debug, Clone)]
pub struct Negative(pub Symbol, pub Option<Symbol>);
@ -495,7 +506,7 @@ impl ToCss for Fallback {
}
/// https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Symbols(pub Vec<Symbol>);
impl Parse for Symbols {