mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-03 04:52:54 +00:00
Bug 1736218 - Expose theme-derived color-scheme to privileged code. r=Gijs
This will be needed to determine whether following the Firefox theme would produce light or dark colors. Differential Revision: https://phabricator.services.mozilla.com/D140221
This commit is contained in:
parent
ce7c3e2195
commit
e7bfa879da
@ -1684,6 +1684,13 @@ nsXULAppInfo::GetChromeColorSchemeIsDark(bool* aResult) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::GetContentThemeDerivedColorSchemeIsDark(bool* aResult) {
|
||||
*aResult =
|
||||
LookAndFeel::ThemeDerivedColorSchemeForContent() == ColorScheme::Dark;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::GetDrawInTitlebar(bool* aResult) {
|
||||
*aResult = LookAndFeel::DrawInTitlebar();
|
||||
|
@ -390,6 +390,7 @@ class LookAndFeel {
|
||||
|
||||
enum class ChromeColorSchemeSetting { Light, Dark, System };
|
||||
static ChromeColorSchemeSetting ColorSchemeSettingForChrome();
|
||||
static ColorScheme ThemeDerivedColorSchemeForContent();
|
||||
|
||||
static ColorScheme ColorSchemeForChrome() {
|
||||
MOZ_ASSERT(sColorSchemeInitialized);
|
||||
|
@ -1159,6 +1159,17 @@ auto LookAndFeel::ColorSchemeSettingForChrome() -> ChromeColorSchemeSetting {
|
||||
}
|
||||
}
|
||||
|
||||
ColorScheme LookAndFeel::ThemeDerivedColorSchemeForContent() {
|
||||
switch (StaticPrefs::browser_theme_content_theme()) {
|
||||
case 0: // Dark
|
||||
return ColorScheme::Dark;
|
||||
case 1: // Light
|
||||
return ColorScheme::Light;
|
||||
default:
|
||||
return ColorSchemeForChrome();
|
||||
}
|
||||
}
|
||||
|
||||
void LookAndFeel::RecomputeColorSchemes() {
|
||||
sColorSchemeInitialized = true;
|
||||
|
||||
@ -1186,14 +1197,7 @@ void LookAndFeel::RecomputeColorSchemes() {
|
||||
break; // Use the browser theme.
|
||||
}
|
||||
|
||||
switch (StaticPrefs::browser_theme_content_theme()) {
|
||||
case 0: // Dark
|
||||
return ColorScheme::Dark;
|
||||
case 1: // Light
|
||||
return ColorScheme::Light;
|
||||
default:
|
||||
return ColorSchemeForChrome();
|
||||
}
|
||||
return ThemeDerivedColorSchemeForContent();
|
||||
}();
|
||||
}
|
||||
|
||||
|
@ -348,6 +348,9 @@ interface nsIXULRuntime : nsISupports
|
||||
/** Whether the chrome color-scheme is dark */
|
||||
readonly attribute boolean chromeColorSchemeIsDark;
|
||||
|
||||
/** Whether the content color-scheme derived from the app theme is dark */
|
||||
readonly attribute boolean contentThemeDerivedColorSchemeIsDark;
|
||||
|
||||
/** Whether we should draw over the titlebar */
|
||||
readonly attribute boolean drawInTitlebar;
|
||||
|
||||
@ -396,4 +399,4 @@ nsIXULRuntime::ContentWin32kLockdownState GetWin32kLockdownState();
|
||||
|
||||
}
|
||||
|
||||
%}
|
||||
%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user