1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Some prefable colors for style system use */
9 #ifndef mozilla_ColorPreferences_h
10 #define mozilla_ColorPreferences_h
13 #include "mozilla/ColorScheme.h"
21 struct PreferenceSheet
{
24 nscolor mLink
= NS_RGB(0x00, 0x00, 0xEE);
25 nscolor mActiveLink
= NS_RGB(0xEE, 0x00, 0x00);
26 nscolor mVisitedLink
= NS_RGB(0x55, 0x1A, 0x8B);
28 nscolor mDefault
= NS_RGB(0, 0, 0);
29 nscolor mDefaultBackground
= NS_RGB(0xFF, 0xFF, 0xFF);
30 } mLightColors
, mDarkColors
;
32 const Colors
& ColorsFor(ColorScheme aScheme
) const {
33 return mMustUseLightColorSet
|| aScheme
== ColorScheme::Light
38 bool mIsChrome
= false;
39 bool mUseAccessibilityTheme
= false;
40 bool mUseDocumentColors
= true;
41 bool mUsePrefColors
= false;
42 bool mUseStandins
= false;
43 bool mMustUseLightColorSet
= false;
44 bool mMustUseLightSystemColors
= false;
46 ColorScheme mColorScheme
= ColorScheme::Light
;
48 // Whether the non-native theme should use real system colors for widgets.
49 bool NonNativeThemeShouldBeHighContrast() const;
51 void Load(bool aIsChrome
);
52 void LoadColors(bool aIsLight
);
55 static void EnsureInitialized() {
62 static void Refresh() {
67 static bool AffectedByPref(const nsACString
&);
69 enum class ChromeColorSchemeSetting
{ Light
, Dark
, System
};
70 static ChromeColorSchemeSetting
ColorSchemeSettingForChrome();
72 static ColorScheme
ColorSchemeForChrome() {
73 MOZ_ASSERT(sInitialized
);
74 return ChromePrefs().mColorScheme
;
77 static ColorScheme
PreferredColorSchemeForContent() {
78 MOZ_ASSERT(sInitialized
);
79 return ContentPrefs().mColorScheme
;
81 static ColorScheme
ThemeDerivedColorSchemeForContent();
83 static Prefs
& ContentPrefs() {
84 MOZ_ASSERT(sInitialized
);
88 static Prefs
& ChromePrefs() {
89 MOZ_ASSERT(sInitialized
);
93 static Prefs
& PrintPrefs() {
94 MOZ_ASSERT(sInitialized
);
98 enum class PrefsKind
{
104 static PrefsKind
PrefsKindFor(const dom::Document
&);
106 static bool ShouldUseChromePrefs(const dom::Document
& aDocument
) {
107 return PrefsKindFor(aDocument
) == PrefsKind::Chrome
;
110 static bool MayForceColors() { return !ContentPrefs().mUseDocumentColors
; }
112 static const Prefs
& PrefsFor(const dom::Document
& aDocument
) {
113 switch (PrefsKindFor(aDocument
)) {
114 case PrefsKind::Chrome
:
115 return ChromePrefs();
116 case PrefsKind::Print
:
118 case PrefsKind::Content
:
121 return ContentPrefs();
125 static bool sInitialized
;
126 static Prefs sChromePrefs
;
127 static Prefs sPrintPrefs
;
128 static Prefs sContentPrefs
;
130 static void Initialize();
133 } // namespace mozilla