mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
style: -moz-toolbar-prefers-color-scheme for dark theme detection
This adds a new @media query -moz-toolbar-prefers-color-scheme which works like prefers-color-scheme but is set based on the browser theme rather than the OS theme. The background colour of the toolbar is used to determine the theme dark/light preference. This will be used for in-content common.css pages and other UI elements that include that stylesheet in the browser-chrome through shadow DOM. The end result is that about: pages, infobars, and modals will now "match" the browser theme (just light/dark mode, not LWT theming support). Differential Revision: https://phabricator.services.mozilla.com/D111486
This commit is contained in:
parent
29bca57333
commit
d12cb17d73
1 changed files with 22 additions and 1 deletions
|
@ -406,6 +406,21 @@ fn eval_prefers_color_scheme(device: &Device, query_value: Option<PrefersColorSc
|
|||
}
|
||||
}
|
||||
|
||||
/// 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(_: &Device, query_value: Option<PrefersColorScheme>) -> bool {
|
||||
let prefers_color_scheme = if static_prefs::pref!("browser.theme.dark-toolbar-theme") {
|
||||
PrefersColorScheme::Dark
|
||||
} else {
|
||||
PrefersColorScheme::Light
|
||||
};
|
||||
|
||||
match query_value {
|
||||
Some(v) => prefers_color_scheme == v,
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// https://drafts.csswg.org/mediaqueries-4/#mf-interaction
|
||||
struct PointerCapabilities: u8 {
|
||||
|
@ -624,7 +639,7 @@ macro_rules! bool_pref_feature {
|
|||
/// to support new types in these entries and (2) ensuring that either
|
||||
/// nsPresContext::MediaFeatureValuesChanged is called when the value that
|
||||
/// would be returned by the evaluator function could change.
|
||||
pub static MEDIA_FEATURES: [MediaFeatureDescription; 61] = [
|
||||
pub static MEDIA_FEATURES: [MediaFeatureDescription; 62] = [
|
||||
feature!(
|
||||
atom!("width"),
|
||||
AllowsRanges::Yes,
|
||||
|
@ -834,6 +849,12 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 61] = [
|
|||
Evaluator::BoolInteger(eval_moz_non_native_content_theme),
|
||||
ParsingRequirements::CHROME_AND_UA_ONLY,
|
||||
),
|
||||
feature!(
|
||||
atom!("-moz-toolbar-prefers-color-scheme"),
|
||||
AllowsRanges::No,
|
||||
keyword_evaluator!(eval_toolbar_prefers_color_scheme, PrefersColorScheme),
|
||||
ParsingRequirements::CHROME_AND_UA_ONLY,
|
||||
),
|
||||
|
||||
lnf_int_feature!(atom!("-moz-scrollbar-start-backward"), ScrollArrowStyle, get_scrollbar_start_backward),
|
||||
lnf_int_feature!(atom!("-moz-scrollbar-start-forward"), ScrollArrowStyle, get_scrollbar_start_forward),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue