From 1b048382783a769e4dd0f7c3e88e893de7c732e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 27 May 2023 17:37:42 +0200 Subject: [PATCH] style: Use GTK menu radius on native context menus and panels Differential Revision: https://phabricator.services.mozilla.com/D129439 --- 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 7e8a1e37f7f..96328d9a51a 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -75,8 +75,13 @@ fn get_titlebar_radius(device: &Device) -> VariableValue { VariableValue::pixel(device.titlebar_radius()) } -static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 1] = [ +fn get_menu_radius(device: &Device) -> VariableValue { + VariableValue::pixel(device.menu_radius()) +} + +static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 2] = [ make_variable!(atom!("-moz-gtk-csd-titlebar-radius"), get_titlebar_radius), + make_variable!(atom!("-moz-gtk-menu-radius"), get_menu_radius), ]; impl CssEnvironment { diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index b41280d2112..6e82404de1d 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -447,6 +447,13 @@ impl Device { } } + /// Returns the gtk menu radius in CSS pixels. + pub fn menu_radius(&self) -> f32 { + unsafe { + bindings::Gecko_GetLookAndFeelInt(bindings::LookAndFeel_IntID::GtkMenuRadius as i32) as f32 + } + } + /// Return whether the document is a chrome document. #[inline] pub fn is_chrome_document(&self) -> bool {