style: Refactor some enabledness checks.

There are some common checks that could get some easy-to-use aliases.

Differential Revision: https://phabricator.services.mozilla.com/D25117
This commit is contained in:
Emilio Cobos Álvarez 2019-03-29 11:12:12 +00:00
parent 76c0ae565e
commit bd77cd64b9
4 changed files with 111 additions and 105 deletions

View file

@ -146,10 +146,23 @@ impl<'a> ParserContext<'a> {
error_reporter.report_error(self.url_data, location, error)
}
/// Whether we're in a user-agent stylesheet.
#[inline]
pub fn in_ua_sheet(&self) -> bool {
self.stylesheet_origin == Origin::UserAgent
}
/// Returns whether chrome-only rules should be parsed.
#[inline]
pub fn chrome_rules_enabled(&self) -> bool {
self.url_data.is_chrome() || self.stylesheet_origin == Origin::User
}
/// Whether we're in a user-agent stylesheet or chrome rules are enabled.
#[inline]
pub fn in_ua_or_chrome_sheet(&self) -> bool {
self.in_ua_sheet() || self.chrome_rules_enabled()
}
}
/// A trait to abstract parsing of a specified value given a `ParserContext` and