mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Upgrade cssparser to 0.15
This commit is contained in:
parent
66c130d55a
commit
b83afdedc8
42 changed files with 234 additions and 217 deletions
|
@ -9,7 +9,7 @@
|
|||
#![deny(missing_docs)]
|
||||
|
||||
use Atom;
|
||||
pub use cssparser::{RGBA, Token, Parser, serialize_identifier, BasicParseError};
|
||||
pub use cssparser::{RGBA, Token, Parser, serialize_identifier, BasicParseError, CompactCowStr};
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use std::ascii::AsciiExt;
|
||||
|
@ -93,7 +93,7 @@ pub struct CustomIdent(pub Atom);
|
|||
|
||||
impl CustomIdent {
|
||||
/// Parse an already-tokenizer identifier
|
||||
pub fn from_ident<'i>(ident: Cow<'i, str>, excluding: &[&str]) -> Result<Self, ParseError<'i>> {
|
||||
pub fn from_ident<'i>(ident: CompactCowStr<'i>, excluding: &[&str]) -> Result<Self, ParseError<'i>> {
|
||||
let valid = match_ignore_ascii_case! { &ident,
|
||||
"initial" | "inherit" | "unset" | "default" => false,
|
||||
_ => true
|
||||
|
@ -104,7 +104,7 @@ impl CustomIdent {
|
|||
if excluding.iter().any(|s| ident.eq_ignore_ascii_case(s)) {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
} else {
|
||||
Ok(CustomIdent(ident.into()))
|
||||
Ok(CustomIdent(Atom::from(Cow::from(ident))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,9 +128,10 @@ pub enum KeyframesName {
|
|||
impl KeyframesName {
|
||||
/// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name
|
||||
pub fn from_ident(value: String) -> Self {
|
||||
match CustomIdent::from_ident((&*value).into(), &["none"]) {
|
||||
Ok(ident) => KeyframesName::Ident(ident),
|
||||
Err(_) => KeyframesName::QuotedString(value.into()),
|
||||
let custom_ident = CustomIdent::from_ident((&*value).into(), &["none"]).ok();
|
||||
match custom_ident {
|
||||
Some(ident) => KeyframesName::Ident(ident),
|
||||
None => KeyframesName::QuotedString(value.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,7 @@ impl Parse for KeyframesName {
|
|||
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
match input.next() {
|
||||
Ok(Token::Ident(s)) => Ok(KeyframesName::Ident(CustomIdent::from_ident(s, &["none"])?)),
|
||||
Ok(Token::QuotedString(s)) => Ok(KeyframesName::QuotedString(s.into())),
|
||||
Ok(Token::QuotedString(s)) => Ok(KeyframesName::QuotedString(Atom::from(Cow::from(s)))),
|
||||
Ok(t) => Err(BasicParseError::UnexpectedToken(t).into()),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue