diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 4a62541f3b3..23cd44e99cf 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -35,7 +35,7 @@ arrayvec = "0.5" atomic_refcell = "0.1" bitflags = "1.0" byteorder = "1.0" -cssparser = "0.27" +cssparser = "0.28" derive_more = "0.99" encoding_rs = { version = "0.8", optional = true } euclid = "0.22" diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs index 74900f96baf..8417497acba 100644 --- a/components/style/stylesheets/font_feature_values_rule.rs +++ b/components/style/stylesheets/font_feature_values_rule.rs @@ -20,7 +20,7 @@ use crate::values::serialize_atom_identifier; use crate::Atom; use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr}; use cssparser::{DeclarationListParser, DeclarationParser, Parser}; -use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, Token}; +use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, ParserState, Token}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; @@ -413,7 +413,7 @@ macro_rules! font_feature_values_blocks { fn parse_block<'t>( &mut self, prelude: BlockType, - _location: SourceLocation, + _: &ParserState, input: &mut Parser<'i, 't> ) -> Result> { debug_assert_eq!(self.context.rule_type(), CssRuleType::FontFeatureValues); diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs index 97394802320..a35d3d2d623 100644 --- a/components/style/stylesheets/keyframes_rule.rs +++ b/components/style/stylesheets/keyframes_rule.rs @@ -17,7 +17,7 @@ use crate::str::CssStringWriter; use crate::stylesheets::rule_parser::VendorPrefix; use crate::stylesheets::{CssRuleType, StylesheetContents}; use crate::values::{serialize_percentage, KeyframesName}; -use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, SourceLocation, Token}; +use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, ParserState, SourceLocation, Token}; use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser}; use servo_arc::Arc; use std::fmt::{self, Write}; @@ -533,7 +533,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> { fn parse_block<'t>( &mut self, selector: Self::Prelude, - source_location: SourceLocation, + start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result> { let context = ParserContext::new_with_rule_type( @@ -566,7 +566,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> { Ok(Arc::new(self.shared_lock.wrap(Keyframe { selector, block: Arc::new(self.shared_lock.wrap(block)), - source_location, + source_location: start.source_location(), }))) } } diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 0b01a5f7bdd..f0624cd9784 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -27,7 +27,7 @@ use crate::values::computed::font::FamilyName; use crate::values::{CssUrl, CustomIdent, KeyframesName}; use crate::{Namespace, Prefix}; use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser}; -use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourceLocation}; +use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, ParserState}; use selectors::SelectorList; use servo_arc::Arc; use style_traits::{ParseError, StyleParseErrorKind}; @@ -251,10 +251,10 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { fn parse_block<'t>( &mut self, prelude: AtRuleBlockPrelude, - location: SourceLocation, + start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result> { - AtRuleParser::parse_block(&mut self.nested(), prelude, location, input).map(|rule| { + AtRuleParser::parse_block(&mut self.nested(), prelude, start, input).map(|rule| { self.state = State::Body; rule }) @@ -264,8 +264,8 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { fn rule_without_block( &mut self, prelude: AtRuleNonBlockPrelude, - source_location: SourceLocation, - ) -> CssRule { + start: &ParserState, + ) -> Self::AtRule { match prelude { AtRuleNonBlockPrelude::Import(url, media) => { let loader = self @@ -274,7 +274,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { let import_rule = loader.request_stylesheet( url, - source_location, + start.source_location(), &self.context, &self.shared_lock, media, @@ -296,7 +296,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { CssRule::Namespace(Arc::new(self.shared_lock.wrap(NamespaceRule { prefix, url, - source_location, + source_location: start.source_location(), }))) }, } @@ -324,10 +324,10 @@ impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> { fn parse_block<'t>( &mut self, prelude: Self::Prelude, - location: SourceLocation, + start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result> { - QualifiedRuleParser::parse_block(&mut self.nested(), prelude, location, input).map( + QualifiedRuleParser::parse_block(&mut self.nested(), prelude, start, input).map( |result| { self.state = State::Body; result @@ -461,7 +461,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { fn parse_block<'t>( &mut self, prelude: AtRuleBlockPrelude, - source_location: SourceLocation, + start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result> { match prelude { @@ -473,7 +473,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { ); Ok(CssRule::FontFace(Arc::new(self.shared_lock.wrap( - parse_font_face_block(&context, input, source_location).into(), + parse_font_face_block(&context, input, start.source_location()).into(), )))) }, AtRuleBlockPrelude::FontFeatureValues(family_names) => { @@ -484,7 +484,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { ); Ok(CssRule::FontFeatureValues(Arc::new(self.shared_lock.wrap( - FontFeatureValuesRule::parse(&context, input, family_names, source_location), + FontFeatureValuesRule::parse(&context, input, family_names, start.source_location()), )))) }, AtRuleBlockPrelude::CounterStyle(name) => { @@ -495,14 +495,14 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { ); Ok(CssRule::CounterStyle(Arc::new(self.shared_lock.wrap( - parse_counter_style_body(name, &context, input, source_location)?.into(), + parse_counter_style_body(name, &context, input, start.source_location())?.into(), )))) }, AtRuleBlockPrelude::Media(media_queries) => { Ok(CssRule::Media(Arc::new(self.shared_lock.wrap(MediaRule { media_queries, rules: self.parse_nested_rules(input, CssRuleType::Media), - source_location, + source_location: start.source_location(), })))) }, AtRuleBlockPrelude::Supports(condition) => { @@ -518,7 +518,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { condition, rules: self.parse_nested_rules(input, CssRuleType::Supports), enabled, - source_location, + source_location: start.source_location(), }, )))) }, @@ -545,7 +545,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { name, keyframes: parse_keyframe_list(&context, input, self.shared_lock), vendor_prefix, - source_location, + source_location: start.source_location(), }, )))) }, @@ -559,7 +559,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { let declarations = parse_property_declaration_list(&context, input, None); Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule { block: Arc::new(self.shared_lock.wrap(declarations)), - source_location, + source_location: start.source_location(), })))) }, AtRuleBlockPrelude::Document(condition) => { @@ -570,7 +570,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> { DocumentRule { condition, rules: self.parse_nested_rules(input, CssRuleType::Document), - source_location, + source_location: start.source_location(), }, )))) }, @@ -598,7 +598,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> { fn parse_block<'t>( &mut self, selectors: Self::Prelude, - source_location: SourceLocation, + start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result> { let context = @@ -609,7 +609,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> { Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule { selectors, block, - source_location, + source_location: start.source_location(), })))) } }