Update cssparser to 0.18

https://github.com/servo/rust-cssparser/pull/171
This commit is contained in:
Simon Sapin 2017-07-20 21:03:53 +02:00
parent 30d6d6024b
commit eb98ae6e04
64 changed files with 541 additions and 512 deletions

View file

@ -13,7 +13,6 @@ use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseError;
#[cfg(feature = "servo")]
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::cmp::Ordering;
use std::f32::consts::PI;
use std::fmt;
@ -169,9 +168,9 @@ impl Image {
fn parse_element<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Atom, ParseError<'i>> {
input.try(|i| i.expect_function_matching("-moz-element"))?;
input.parse_nested_block(|i| {
match i.next()? {
Token::IDHash(id) => Ok(Atom::from(Cow::from(id))),
t => Err(BasicParseError::UnexpectedToken(t).into()),
match *i.next()? {
Token::IDHash(ref id) => Ok(Atom::from(id.as_ref())),
ref t => Err(BasicParseError::UnexpectedToken(t.clone()).into()),
}
})
}
@ -184,7 +183,8 @@ impl Parse for Gradient {
Radial,
}
let func = input.expect_function()?;
// FIXME: remove clone() when lifetimes are non-lexical
let func = input.expect_function()?.clone();
let result = match_ignore_ascii_case! { &func,
"linear-gradient" => {
Some((Shape::Linear, false, CompatMode::Modern))
@ -234,7 +234,7 @@ impl Parse for Gradient {
let (shape, repeating, mut compat_mode) = match result {
Some(result) => result,
None => return Err(StyleParseError::UnexpectedFunction(func).into()),
None => return Err(StyleParseError::UnexpectedFunction(func.clone()).into()),
};
let (kind, items) = input.parse_nested_block(|i| {
@ -389,7 +389,7 @@ impl Gradient {
}
}
let ident = input.expect_ident()?;
let ident = input.expect_ident_cloned()?;
input.expect_comma()?;
let (kind, reverse_stops) = match_ignore_ascii_case! { &ident,
@ -439,7 +439,7 @@ impl Gradient {
let mut items = input.try(|i| {
i.expect_comma()?;
i.parse_comma_separated(|i| {
let function = i.expect_function()?;
let function = i.expect_function()?.clone();
let (color, mut p) = i.parse_nested_block(|i| {
let p = match_ignore_ascii_case! { &function,
"color-stop" => {
@ -879,7 +879,7 @@ impl Parse for PaintWorklet {
input.parse_nested_block(|i| {
let name = i.expect_ident()?;
Ok(PaintWorklet {
name: Atom::from(Cow::from(name)),
name: Atom::from(name.as_ref()),
})
})
}
@ -890,7 +890,7 @@ impl Parse for MozImageRect {
input.try(|i| i.expect_function_matching("-moz-image-rect"))?;
input.parse_nested_block(|i| {
let string = i.expect_url_or_string()?;
let url = SpecifiedUrl::parse_from_string(string.into_owned(), context)?;
let url = SpecifiedUrl::parse_from_string(string.as_ref().to_owned(), context)?;
i.expect_comma()?;
let top = NumberOrPercentage::parse_non_negative(context, i)?;
i.expect_comma()?;