зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
0b22ec0196
Коммит
c676353b72
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче