style: Remove -moz-toolbar-prefers-color-scheme

By making prefers-color-scheme return the ColorSchemeForChrome(), which
accounts for the Firefox theme.

Differential Revision: https://phabricator.services.mozilla.com/D128611
This commit is contained in:
Emilio Cobos Álvarez 2023-05-27 16:21:52 +02:00 committed by Oriol Brufau
parent 8c6af822b0
commit 685b2cd29a

View file

@ -406,45 +406,6 @@ fn eval_prefers_color_scheme(device: &Device, query_value: Option<PrefersColorSc
} }
} }
/// Values for the -moz-toolbar-prefers-color-scheme media feature.
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, PartialEq, ToCss)]
#[repr(u8)]
enum ToolbarPrefersColorScheme {
Dark,
Light,
System,
}
/// The color-scheme of the toolbar in the current Firefox theme. This is based
/// on a pref managed by the front-end.
fn eval_toolbar_prefers_color_scheme(d: &Device, query_value: Option<ToolbarPrefersColorScheme>) -> bool {
let toolbar_value = match static_prefs::pref!("browser.theme.toolbar-theme") {
0 => ToolbarPrefersColorScheme::Dark,
1 => ToolbarPrefersColorScheme::Light,
_ => ToolbarPrefersColorScheme::System,
};
let query_value = match query_value {
Some(v) => v,
None => return true,
};
if query_value == toolbar_value {
return true;
}
if toolbar_value != ToolbarPrefersColorScheme::System {
return false;
}
// System might match light and dark as well.
match query_value {
ToolbarPrefersColorScheme::Dark => eval_prefers_color_scheme(d, Some(PrefersColorScheme::Dark)),
ToolbarPrefersColorScheme::Light => eval_prefers_color_scheme(d, Some(PrefersColorScheme::Light)),
ToolbarPrefersColorScheme::System => true,
}
}
bitflags! { bitflags! {
/// https://drafts.csswg.org/mediaqueries-4/#mf-interaction /// https://drafts.csswg.org/mediaqueries-4/#mf-interaction
struct PointerCapabilities: u8 { struct PointerCapabilities: u8 {
@ -690,7 +651,7 @@ macro_rules! bool_pref_feature {
/// to support new types in these entries and (2) ensuring that either /// to support new types in these entries and (2) ensuring that either
/// nsPresContext::MediaFeatureValuesChanged is called when the value that /// nsPresContext::MediaFeatureValuesChanged is called when the value that
/// would be returned by the evaluator function could change. /// would be returned by the evaluator function could change.
pub static MEDIA_FEATURES: [MediaFeatureDescription; 61] = [ pub static MEDIA_FEATURES: [MediaFeatureDescription; 60] = [
feature!( feature!(
atom!("width"), atom!("width"),
AllowsRanges::Yes, AllowsRanges::Yes,
@ -900,12 +861,6 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 61] = [
Evaluator::BoolInteger(eval_moz_non_native_content_theme), Evaluator::BoolInteger(eval_moz_non_native_content_theme),
ParsingRequirements::CHROME_AND_UA_ONLY, ParsingRequirements::CHROME_AND_UA_ONLY,
), ),
feature!(
atom!("-moz-toolbar-prefers-color-scheme"),
AllowsRanges::No,
keyword_evaluator!(eval_toolbar_prefers_color_scheme, ToolbarPrefersColorScheme),
ParsingRequirements::CHROME_AND_UA_ONLY,
),
feature!( feature!(
atom!("-moz-windows-non-native-menus"), atom!("-moz-windows-non-native-menus"),
AllowsRanges::No, AllowsRanges::No,