Bug 1509931 - Add support for chrome-only environment variables. r=stransky

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:
Emilio Cobos Álvarez 2021-10-18 16:22:13 +00:00
Родитель 0b22ec0196
Коммит c676353b72
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -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))
}
}

Просмотреть файл

@ -367,4 +367,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
}
}