mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
This commit is contained in:
parent
30d6d6024b
commit
eb98ae6e04
64 changed files with 541 additions and 512 deletions
|
@ -89,9 +89,9 @@ macro_rules! parse_quoted_or_unquoted_string {
|
|||
let start = input.position();
|
||||
input.parse_entirely(|input| {
|
||||
match input.next() {
|
||||
Ok(Token::QuotedString(value)) =>
|
||||
Ok($url_matching_function(value.into_owned())),
|
||||
Ok(t) => Err(BasicParseError::UnexpectedToken(t).into()),
|
||||
Ok(&Token::QuotedString(ref value)) =>
|
||||
Ok($url_matching_function(value.as_ref().to_owned())),
|
||||
Ok(t) => Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}).or_else(|_: ParseError| {
|
||||
|
@ -112,7 +112,7 @@ impl UrlMatchingFunction {
|
|||
parse_quoted_or_unquoted_string!(input, UrlMatchingFunction::Domain)
|
||||
} else if input.try(|input| input.expect_function_matching("regexp")).is_ok() {
|
||||
input.parse_nested_block(|input| {
|
||||
Ok(UrlMatchingFunction::RegExp(input.expect_string()?.into_owned()))
|
||||
Ok(UrlMatchingFunction::RegExp(input.expect_string()?.as_ref().to_owned()))
|
||||
})
|
||||
} else if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) {
|
||||
Ok(UrlMatchingFunction::Url(url))
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Keyframes: https://drafts.csswg.org/css-animations/#keyframes
|
||||
|
||||
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser, ParserInput, CompactCowStr};
|
||||
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser, ParserInput, CowRcStr};
|
||||
use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule, SourceLocation};
|
||||
use error_reporting::{NullReporter, ContextualParseError};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
|
@ -531,7 +531,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> {
|
|||
type Declaration = ();
|
||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
|
||||
fn parse_value<'t>(&mut self, name: CompactCowStr<'i>, input: &mut Parser<'i, 't>)
|
||||
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
|
||||
-> Result<(), ParseError<'i>> {
|
||||
let id = PropertyId::parse(&name)
|
||||
.map_err(|()| PropertyDeclarationParseError::UnknownProperty(name))?;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use {Namespace, Prefix};
|
||||
use counter_style::{parse_counter_style_body, parse_counter_style_name};
|
||||
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser};
|
||||
use cssparser::{CompactCowStr, SourceLocation, BasicParseError};
|
||||
use cssparser::{CowRcStr, SourceLocation, BasicParseError};
|
||||
use error_reporting::ContextualParseError;
|
||||
use font_face::parse_font_face_block;
|
||||
use media_queries::{parse_media_query_list, MediaList};
|
||||
|
@ -18,7 +18,6 @@ use selectors::SelectorList;
|
|||
use selectors::parser::SelectorParseError;
|
||||
use servo_arc::Arc;
|
||||
use shared_lock::{Locked, SharedRwLock};
|
||||
use std::borrow::Cow;
|
||||
use str::starts_with_ignore_ascii_case;
|
||||
use style_traits::{StyleParseError, ParseError};
|
||||
use stylesheets::{CssRule, CssRules, CssRuleType, Origin, StylesheetLoader};
|
||||
|
@ -142,7 +141,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
|
||||
fn parse_prelude<'t>(
|
||||
&mut self,
|
||||
name: CompactCowStr<'i>,
|
||||
name: CowRcStr<'i>,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<AtRuleType<AtRulePrelude, CssRule>, ParseError<'i>> {
|
||||
let location = get_location_with_offset(input.current_source_location(),
|
||||
|
@ -156,7 +155,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
}
|
||||
|
||||
self.state = State::Imports;
|
||||
let url_string = input.expect_url_or_string()?.into_owned();
|
||||
let url_string = input.expect_url_or_string()?.as_ref().to_owned();
|
||||
let specified_url = SpecifiedUrl::parse_from_string(url_string, &self.context)?;
|
||||
|
||||
let media = parse_media_query_list(&self.context, input);
|
||||
|
@ -183,14 +182,14 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
}
|
||||
self.state = State::Namespaces;
|
||||
|
||||
let prefix_result = input.try(|input| input.expect_ident());
|
||||
let prefix_result = input.try(|i| i.expect_ident_cloned());
|
||||
let maybe_namespace = match input.expect_url_or_string() {
|
||||
Ok(url_or_string) => url_or_string,
|
||||
Err(BasicParseError::UnexpectedToken(t)) =>
|
||||
return Err(StyleParseError::UnexpectedTokenWithinNamespace(t).into()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
let url = Namespace::from(Cow::from(maybe_namespace));
|
||||
let url = Namespace::from(maybe_namespace.as_ref());
|
||||
|
||||
let id = register_namespace(&url)
|
||||
.map_err(|()| StyleParseError::UnspecifiedError)?;
|
||||
|
@ -198,7 +197,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
let mut namespaces = self.namespaces.as_mut().unwrap();
|
||||
|
||||
let opt_prefix = if let Ok(prefix) = prefix_result {
|
||||
let prefix = Prefix::from(Cow::from(prefix));
|
||||
let prefix = Prefix::from(prefix.as_ref());
|
||||
namespaces
|
||||
.prefixes
|
||||
.insert(prefix.clone(), (url.clone(), id));
|
||||
|
@ -324,7 +323,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
|||
|
||||
fn parse_prelude<'t>(
|
||||
&mut self,
|
||||
name: CompactCowStr<'i>,
|
||||
name: CowRcStr<'i>,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<AtRuleType<AtRulePrelude, CssRule>, ParseError<'i>> {
|
||||
let location =
|
||||
|
|
|
@ -97,14 +97,14 @@ impl SupportsCondition {
|
|||
// End of input
|
||||
return Ok(in_parens)
|
||||
}
|
||||
Ok(Token::Ident(ident)) => {
|
||||
Ok(&Token::Ident(ref ident)) => {
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"and" => ("and", SupportsCondition::And as fn(_) -> _),
|
||||
"or" => ("or", SupportsCondition::Or as fn(_) -> _),
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(ident.clone()).into())
|
||||
}
|
||||
}
|
||||
Ok(t) => return Err(CssParseError::Basic(BasicParseError::UnexpectedToken(t)))
|
||||
Ok(t) => return Err(CssParseError::Basic(BasicParseError::UnexpectedToken(t.clone())))
|
||||
};
|
||||
|
||||
let mut conditions = Vec::with_capacity(2);
|
||||
|
@ -126,7 +126,8 @@ impl SupportsCondition {
|
|||
// but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases.
|
||||
while input.try(Parser::expect_whitespace).is_ok() {}
|
||||
let pos = input.position();
|
||||
match input.next()? {
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next()?.clone() {
|
||||
Token::ParenthesisBlock => {
|
||||
let nested = input.try(|input| {
|
||||
input.parse_nested_block(|i| parse_condition_or_declaration(i))
|
||||
|
@ -244,7 +245,7 @@ impl Declaration {
|
|||
let mut input = ParserInput::new(&self.0);
|
||||
let mut input = Parser::new(&mut input);
|
||||
input.parse_entirely(|input| {
|
||||
let prop = input.expect_ident().unwrap();
|
||||
let prop = input.expect_ident().unwrap().as_ref().to_owned();
|
||||
input.expect_colon().unwrap();
|
||||
let id = PropertyId::parse(&prop)
|
||||
.map_err(|_| StyleParseError::UnspecifiedError)?;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use app_units::Au;
|
||||
use context::QuirksMode;
|
||||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
||||
use cssparser::{CompactCowStr, ToCss as ParserToCss};
|
||||
use cssparser::{CowRcStr, ToCss as ParserToCss};
|
||||
use error_reporting::ContextualParseError;
|
||||
use euclid::TypedSize2D;
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
|
@ -280,7 +280,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for ViewportRuleParser<'a, 'b> {
|
|||
type Declaration = Vec<ViewportDescriptorDeclaration>;
|
||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
|
||||
fn parse_value<'t>(&mut self, name: CompactCowStr<'i>, input: &mut Parser<'i, 't>)
|
||||
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
|
||||
-> Result<Vec<ViewportDescriptorDeclaration>, ParseError<'i>> {
|
||||
macro_rules! declaration {
|
||||
($declaration:ident($parse:expr)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue