diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index 67d4d4f6981..8e0e3412d4b 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -46,7 +46,7 @@ pub struct SelectorParser<'a> { pub namespaces: &'a Namespaces, /// The extra URL data of the stylesheet, which is used to look up /// whether we are parsing a chrome:// URL style sheet. - pub url_data: Option<&'a UrlExtraData>, + pub url_data: &'a UrlExtraData, } impl<'a> SelectorParser<'a> { @@ -54,14 +54,15 @@ impl<'a> SelectorParser<'a> { /// account namespaces. /// /// This is used for some DOM APIs like `querySelector`. - pub fn parse_author_origin_no_namespace( - input: &str, - ) -> Result, ParseError> { + pub fn parse_author_origin_no_namespace<'i>( + input: &'i str, + url_data: &UrlExtraData, + ) -> Result, ParseError<'i>> { let namespaces = Namespaces::default(); let parser = SelectorParser { stylesheet_origin: Origin::Author, namespaces: &namespaces, - url_data: None, + url_data, }; let mut input = ParserInput::new(input); SelectorList::parse(&parser, &mut CssParser::new(&mut input)) @@ -75,7 +76,7 @@ impl<'a> SelectorParser<'a> { /// Whether we're parsing selectors in a stylesheet that has chrome /// privilege. pub fn chrome_rules_enabled(&self) -> bool { - self.url_data.map_or(false, |d| d.chrome_rules_enabled()) || + self.url_data.chrome_rules_enabled() || self.stylesheet_origin == Origin::User } } diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 7e3e4f9f86c..995ee801e40 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -710,7 +710,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> { let selector_parser = SelectorParser { stylesheet_origin: self.context.stylesheet_origin, namespaces: self.namespaces, - url_data: Some(self.context.url_data), + url_data: self.context.url_data, }; let selectors = SelectorList::parse(&selector_parser, input)?; if self.context.error_reporting_enabled() { diff --git a/components/style/stylesheets/supports_rule.rs b/components/style/stylesheets/supports_rule.rs index d0aaa0a03d8..23d79fd1cc2 100644 --- a/components/style/stylesheets/supports_rule.rs +++ b/components/style/stylesheets/supports_rule.rs @@ -335,7 +335,7 @@ impl RawSelector { let parser = SelectorParser { namespaces, stylesheet_origin: context.stylesheet_origin, - url_data: Some(context.url_data), + url_data: context.url_data, }; #[allow(unused_variables)]