mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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
|
@ -7,7 +7,7 @@
|
|||
#![deny(missing_docs)]
|
||||
|
||||
use context::QuirksMode;
|
||||
use cssparser::{DeclarationListParser, parse_important, ParserInput};
|
||||
use cssparser::{DeclarationListParser, parse_important, ParserInput, CompactCowStr};
|
||||
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter};
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
|
@ -932,7 +932,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
|||
type Declaration = Importance;
|
||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
|
||||
fn parse_value<'t>(&mut self, name: Cow<'i, str>, input: &mut Parser<'i, 't>)
|
||||
fn parse_value<'t>(&mut self, name: CompactCowStr<'i>, input: &mut Parser<'i, 't>)
|
||||
-> Result<Importance, ParseError<'i>> {
|
||||
let id = try!(PropertyId::parse(name));
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
|
|
|
@ -306,8 +306,8 @@ ${helpers.predefined_type("clip",
|
|||
fn parse_factor<'i, 't>(input: &mut Parser<'i, 't>) -> Result<::values::CSSFloat, ParseError<'i>> {
|
||||
use cssparser::Token;
|
||||
match input.next() {
|
||||
Ok(Token::Number(value)) if value.value.is_sign_positive() => Ok(value.value),
|
||||
Ok(Token::Percentage(value)) if value.unit_value.is_sign_positive() => Ok(value.unit_value),
|
||||
Ok(Token::Number { value, .. }) if value.is_sign_positive() => Ok(value),
|
||||
Ok(Token::Percentage { unit_value, .. }) if unit_value.is_sign_positive() => Ok(unit_value),
|
||||
Ok(t) => Err(BasicParseError::UnexpectedToken(t).into()),
|
||||
Err(e) => Err(e.into())
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
|||
|
||||
<%helpers:longhand name="quotes" animation_value_type="none"
|
||||
spec="https://drafts.csswg.org/css-content/#propdef-quotes">
|
||||
use std::borrow::Cow;
|
||||
use cssparser::serialize_string;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
@ -169,12 +169,12 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
|||
let mut first = true;
|
||||
for pair in &self.0 {
|
||||
if !first {
|
||||
try!(dest.write_str(" "));
|
||||
dest.write_str(" ")?;
|
||||
}
|
||||
first = false;
|
||||
try!(Token::QuotedString(Cow::from(&*pair.0)).to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(Token::QuotedString(Cow::from(&*pair.1)).to_css(dest));
|
||||
serialize_string(&*pair.0, dest)?;
|
||||
dest.write_str(" ")?;
|
||||
serialize_string(&*pair.1, dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use stylearc::{Arc, UniqueArc};
|
|||
use app_units::Au;
|
||||
#[cfg(feature = "servo")] use cssparser::RGBA;
|
||||
use cssparser::{Parser, TokenSerializationType, serialize_identifier};
|
||||
use cssparser::ParserInput;
|
||||
use cssparser::{ParserInput, CompactCowStr};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
|
||||
use computed_values;
|
||||
|
@ -491,7 +491,7 @@ impl CSSWideKeyword {
|
|||
|
||||
/// Takes the result of cssparser::Parser::expect_ident() and converts it
|
||||
/// to a CSSWideKeyword.
|
||||
pub fn from_ident<'i>(ident: &Cow<'i, str>) -> Option<Self> {
|
||||
pub fn from_ident<'i>(ident: &str) -> Option<Self> {
|
||||
match_ignore_ascii_case! { ident,
|
||||
// If modifying this set of keyword, also update values::CustomIdent::from_ident
|
||||
"initial" => Some(CSSWideKeyword::Initial),
|
||||
|
@ -986,7 +986,7 @@ impl PropertyId {
|
|||
/// Returns a given property from the string `s`.
|
||||
///
|
||||
/// Returns Err(()) for unknown non-custom properties
|
||||
pub fn parse<'i>(property_name: Cow<'i, str>) -> Result<Self, ParseError<'i>> {
|
||||
pub fn parse<'i>(property_name: CompactCowStr<'i>) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(name) = ::custom_properties::parse_name(&property_name) {
|
||||
return Ok(PropertyId::Custom(::custom_properties::Name::from(name)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue