mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
style: Add support for chrome-only environment variables
This bit is taken straight from D73454 (I reviewed it but I guess another pair of eyes is ok, it's really straight-forward). Co-authored-by: Nicklas Boman <smurfd@gmail.com> Differential Revision: https://phabricator.services.mozilla.com/D128679
This commit is contained in:
parent
685b2cd29a
commit
e74b41cafe
2 changed files with 16 additions and 1 deletions
|
@ -71,10 +71,19 @@ static ENVIRONMENT_VARIABLES: [EnvironmentVariable; 4] = [
|
|||
make_variable!(atom!("safe-area-inset-right"), get_safearea_inset_right),
|
||||
];
|
||||
|
||||
static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 0] = [
|
||||
];
|
||||
|
||||
impl CssEnvironment {
|
||||
#[inline]
|
||||
fn get(&self, name: &Atom, device: &Device) -> Option<VariableValue> {
|
||||
let var = ENVIRONMENT_VARIABLES.iter().find(|var| var.name == *name)?;
|
||||
if let Some(var) = ENVIRONMENT_VARIABLES.iter().find(|var| var.name == *name) {
|
||||
return Some((var.evaluator)(device));
|
||||
}
|
||||
if !device.is_chrome_document() {
|
||||
return None;
|
||||
}
|
||||
let var = CHROME_ENVIRONMENT_VARIABLES.iter().find(|var| var.name == *name)?;
|
||||
Some((var.evaluator)(device))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,4 +439,10 @@ impl Device {
|
|||
bindings::Gecko_IsSupportedImageMimeType(mime_type.as_ptr(), mime_type.len() as u32)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return whether the document is a chrome document.
|
||||
#[inline]
|
||||
pub fn is_chrome_document(&self) -> bool {
|
||||
self.pref_sheet_prefs().mIsChrome
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue