no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / style / PreferenceSheet.h
blob707a32a7089cce8c36a41f088cbdad198753eeff
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
12 #include "nsColor.h"
13 #include "mozilla/ColorScheme.h"
15 namespace mozilla {
17 namespace dom {
18 class Document;
21 struct PreferenceSheet {
22 struct Prefs {
23 struct Colors {
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
34 ? mLightColors
35 : mDarkColors;
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() {
56 if (sInitialized) {
57 return;
59 Initialize();
62 static void Refresh() {
63 sInitialized = false;
64 Initialize();
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);
85 return sContentPrefs;
88 static Prefs& ChromePrefs() {
89 MOZ_ASSERT(sInitialized);
90 return sChromePrefs;
93 static Prefs& PrintPrefs() {
94 MOZ_ASSERT(sInitialized);
95 return sPrintPrefs;
98 enum class PrefsKind {
99 Chrome,
100 Print,
101 Content,
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:
117 return PrintPrefs();
118 case PrefsKind::Content:
119 break;
121 return ContentPrefs();
124 private:
125 static bool sInitialized;
126 static Prefs sChromePrefs;
127 static Prefs sPrintPrefs;
128 static Prefs sContentPrefs;
130 static void Initialize();
133 } // namespace mozilla
135 #endif