diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-05-27 16:22:35 +0200 |
---|---|---|
committer | Oriol Brufau <obrufau@igalia.com> | 2023-05-31 00:50:31 +0200 |
commit | e74b41cafece287a1b14f39aaffa57d37f649a1e (patch) | |
tree | 9b3339dbd2709552a61bbf4c3f5caa71064f6bb3 /components/style/custom_properties.rs | |
parent | 685b2cd29a370367307ed024c2ca67179e2b4a8c (diff) | |
download | servo-e74b41cafece287a1b14f39aaffa57d37f649a1e.tar.gz servo-e74b41cafece287a1b14f39aaffa57d37f649a1e.zip |
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
Diffstat (limited to 'components/style/custom_properties.rs')
-rw-r--r-- | components/style/custom_properties.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index df3f9660dd4..a6908bb4cfa 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -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)) } } |