style: Allow resource:// stylesheets to use chrome-only rules.

We'll use it to use @-moz-document from plaintext.css.

Differential Revision: https://phabricator.services.mozilla.com/D101516
This commit is contained in:
Emilio Cobos Álvarez 2021-01-17 15:07:49 +00:00
parent f16305d25a
commit df7ea837d8
3 changed files with 5 additions and 5 deletions

View file

@ -140,7 +140,7 @@ impl<'a> ParserContext<'a> {
/// Returns whether chrome-only rules should be parsed. /// Returns whether chrome-only rules should be parsed.
#[inline] #[inline]
pub fn chrome_rules_enabled(&self) -> bool { pub fn chrome_rules_enabled(&self) -> bool {
self.url_data.is_chrome() || self.stylesheet_origin == Origin::User self.url_data.chrome_rules_enabled() || self.stylesheet_origin == Origin::User
} }
/// Whether we're in a user-agent stylesheet or chrome rules are enabled. /// Whether we're in a user-agent stylesheet or chrome rules are enabled.

View file

@ -75,7 +75,7 @@ impl<'a> SelectorParser<'a> {
/// Whether we're parsing selectors in a stylesheet that has chrome /// Whether we're parsing selectors in a stylesheet that has chrome
/// privilege. /// privilege.
pub fn chrome_rules_enabled(&self) -> bool { pub fn chrome_rules_enabled(&self) -> bool {
self.url_data.map_or(false, |d| d.is_chrome()) || self.stylesheet_origin == Origin::User self.url_data.map_or(false, |d| d.chrome_rules_enabled()) || self.stylesheet_origin == Origin::User
} }
} }

View file

@ -154,8 +154,8 @@ impl UrlExtraData {
/// True if this URL scheme is chrome. /// True if this URL scheme is chrome.
#[inline] #[inline]
pub fn is_chrome(&self) -> bool { pub fn chrome_rules_enabled(&self) -> bool {
self.as_ref().mIsChrome self.as_ref().mChromeRulesEnabled
} }
/// Create a reference to this `UrlExtraData` from a reference to pointer. /// Create a reference to this `UrlExtraData` from a reference to pointer.
@ -213,7 +213,7 @@ impl fmt::Debug for UrlExtraData {
formatter formatter
.debug_struct("URLExtraData") .debug_struct("URLExtraData")
.field("is_chrome", &self.is_chrome()) .field("chrome_rules_enabled", &self.chrome_rules_enabled())
.field( .field(
"base", "base",
&DebugURI(self.as_ref().mBaseURI.raw::<structs::nsIURI>()), &DebugURI(self.as_ref().mBaseURI.raw::<structs::nsIURI>()),