diff options
Diffstat (limited to 'components/style/parser.rs')
-rw-r--r-- | components/style/parser.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/components/style/parser.rs b/components/style/parser.rs index a4b7d816203..db5b8f1e7f9 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -9,6 +9,7 @@ use cssparser::{Parser, SourceLocation, UnicodeRange}; use error_reporting::{ContextualParseError, ParseErrorReporter}; use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator}; use stylesheets::{CssRuleType, Namespaces, Origin, UrlExtraData}; +use use_counters::UseCounters; /// Asserts that all ParsingMode flags have a matching ParsingMode value in gecko. #[cfg(feature = "gecko")] @@ -53,6 +54,8 @@ pub struct ParserContext<'a> { error_reporter: Option<&'a ParseErrorReporter>, /// The currently active namespaces. pub namespaces: Option<&'a Namespaces>, + /// The use counters we want to record while parsing style rules, if any. + pub use_counters: Option<&'a UseCounters>, } impl<'a> ParserContext<'a> { @@ -65,8 +68,9 @@ impl<'a> ParserContext<'a> { parsing_mode: ParsingMode, quirks_mode: QuirksMode, error_reporter: Option<&'a ParseErrorReporter>, + use_counters: Option<&'a UseCounters>, ) -> Self { - ParserContext { + Self { stylesheet_origin, url_data, rule_type, @@ -74,6 +78,7 @@ impl<'a> ParserContext<'a> { quirks_mode, error_reporter, namespaces: None, + use_counters, } } @@ -85,6 +90,7 @@ impl<'a> ParserContext<'a> { parsing_mode: ParsingMode, quirks_mode: QuirksMode, error_reporter: Option<&'a ParseErrorReporter>, + use_counters: Option<&'a UseCounters>, ) -> Self { Self::new( Origin::Author, @@ -93,17 +99,19 @@ impl<'a> ParserContext<'a> { parsing_mode, quirks_mode, error_reporter, + use_counters, ) } - /// Create a parser context based on a previous context, but with a modified rule type. + /// Create a parser context based on a previous context, but with a modified + /// rule type. #[inline] pub fn new_with_rule_type( context: &'a ParserContext, rule_type: CssRuleType, namespaces: &'a Namespaces, ) -> ParserContext<'a> { - ParserContext { + Self { stylesheet_origin: context.stylesheet_origin, url_data: context.url_data, rule_type: Some(rule_type), @@ -111,6 +119,7 @@ impl<'a> ParserContext<'a> { quirks_mode: context.quirks_mode, namespaces: Some(namespaces), error_reporter: context.error_reporter, + use_counters: context.use_counters, } } |