mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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:
parent
76c0ae565e
commit
bd77cd64b9
4 changed files with 111 additions and 105 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue