From 07e5ea696665076436ce45db6dfffabe8c767666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 27 May 2023 16:23:42 +0200 Subject: [PATCH] style: Expose titlebar radius as a chrome-only CSS environment variable Mostly plumbing. Differential Revision: https://phabricator.services.mozilla.com/D128680 --- components/style/custom_properties.rs | 7 ++++++- components/style/gecko/media_queries.rs | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index a6908bb4cfa..7e8a1e37f7f 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -71,7 +71,12 @@ static ENVIRONMENT_VARIABLES: [EnvironmentVariable; 4] = [ make_variable!(atom!("safe-area-inset-right"), get_safearea_inset_right), ]; -static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 0] = [ +fn get_titlebar_radius(device: &Device) -> VariableValue { + VariableValue::pixel(device.titlebar_radius()) +} + +static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 1] = [ + make_variable!(atom!("-moz-gtk-csd-titlebar-radius"), get_titlebar_radius), ]; impl CssEnvironment { diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 2966363a8eb..a560211d2f3 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -440,6 +440,13 @@ impl Device { } } + /// Returns the gtk titlebar radius in CSS pixels. + pub fn titlebar_radius(&self) -> f32 { + unsafe { + bindings::Gecko_GetLookAndFeelFloat(bindings::LookAndFeel_FloatID::TitlebarRadius as i32) + } + } + /// Return whether the document is a chrome document. #[inline] pub fn is_chrome_document(&self) -> bool {