Upgrade cssparser to 0.15

This commit is contained in:
Simon Sapin 2017-06-15 21:58:40 +02:00
parent 66c130d55a
commit b83afdedc8
42 changed files with 234 additions and 217 deletions

View file

@ -16,7 +16,7 @@ gecko = []
[dependencies]
app_units = "0.5"
bitflags = "0.7"
cssparser = "0.15"
cssparser = "0.16"
euclid = "0.15"
heapsize = {version = "0.4", optional = true}
heapsize_derive = {version = "0.1", optional = true}

View file

@ -22,8 +22,8 @@ extern crate euclid;
extern crate selectors;
#[cfg(feature = "servo")] #[macro_use] extern crate serde;
use cssparser::CompactCowStr;
use selectors::parser::SelectorParseError;
use std::borrow::Cow;
/// Opaque type stored in type-unsafe work queues for parallel layout.
/// Must be transmutable to and from `TNode`.
@ -95,11 +95,11 @@ pub enum StyleParseError<'i> {
/// A property declaration value had input remaining after successfully parsing.
PropertyDeclarationValueNotExhausted,
/// An unexpected dimension token was encountered.
UnexpectedDimension(Cow<'i, str>),
UnexpectedDimension(CompactCowStr<'i>),
/// A media query using a ranged expression with no value was encountered.
RangedExpressionWithNoValue,
/// A function was encountered that was not expected.
UnexpectedFunction(Cow<'i, str>),
UnexpectedFunction(CompactCowStr<'i>),
/// @namespace must be before any rule but @charset and @import
UnexpectedNamespaceRule,
/// @import must be before any rule but @charset
@ -107,7 +107,7 @@ pub enum StyleParseError<'i> {
/// Unexpected @charset rule encountered.
UnexpectedCharsetRule,
/// Unsupported @ rule
UnsupportedAtRule(Cow<'i, str>),
UnsupportedAtRule(CompactCowStr<'i>),
/// A placeholder for many sources of errors that require more specific variants.
UnspecifiedError,
}

View file

@ -149,12 +149,15 @@ impl Zoom {
// argument, and pass ParsingMode owned by the ParserContext to
// is_ok() instead of using PARSING_MODE_DEFAULT directly.
// In order to do so, we might want to move these stuff into style::stylesheets::viewport_rule.
Token::Percentage(ref value) if NonNegative.is_ok(PARSING_MODE_DEFAULT, value.unit_value) =>
Ok(Zoom::Percentage(value.unit_value)),
Token::Number(ref value) if NonNegative.is_ok(PARSING_MODE_DEFAULT, value.value) =>
Ok(Zoom::Number(value.value)),
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") =>
Ok(Zoom::Auto),
Token::Percentage { unit_value, .. } if NonNegative.is_ok(PARSING_MODE_DEFAULT, unit_value) => {
Ok(Zoom::Percentage(unit_value))
}
Token::Number { value, .. } if NonNegative.is_ok(PARSING_MODE_DEFAULT, value) => {
Ok(Zoom::Number(value))
}
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => {
Ok(Zoom::Auto)
}
t => Err(CssParseError::Basic(BasicParseError::UnexpectedToken(t)))
}
}