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);
31 nscolor mFocusText
= mDefault
;
32 nscolor mFocusBackground
= mDefaultBackground
;
33 } mLightColors
, mDarkColors
;
35 const Colors
& ColorsFor(ColorScheme aScheme
) const {
36 return mMustUseLightColorSet
|| aScheme
== ColorScheme::Light
41 bool mIsChrome
= false;
42 bool mUseAccessibilityTheme
= false;
43 bool mUseDocumentColors
= true;
44 bool mUsePrefColors
= false;
45 bool mUseStandins
= false;
46 bool mMustUseLightColorSet
= false;
48 // Sometimes we can force a color scheme on a document, or honor the
49 // preferred color-scheme in more cases, depending on whether we're forcing
51 enum class ColorSchemeChoice
: uint8_t {
52 // We're not forcing colors, use standard algorithm based on specified
53 // style and meta tags and so on.
55 // We can honor whatever the preferred color-scheme for the document is
56 // (the preferred color-scheme of the user, since we're forcing colors).
62 ColorSchemeChoice mColorSchemeChoice
= ColorSchemeChoice::Standard
;
64 // Whether the non-native theme should use real system colors for widgets.
65 bool NonNativeThemeShouldBeHighContrast() const;
67 void Load(bool aIsChrome
);
68 void LoadColors(bool aIsLight
);
71 static void EnsureInitialized() {
78 static void Refresh() {
83 static bool AffectedByPref(const nsACString
&);
85 static Prefs
& ContentPrefs() {
86 MOZ_ASSERT(sInitialized
);
90 static Prefs
& ChromePrefs() {
91 MOZ_ASSERT(sInitialized
);
95 static Prefs
& PrintPrefs() {
96 MOZ_ASSERT(sInitialized
);
100 enum class PrefsKind
{
106 static PrefsKind
PrefsKindFor(const dom::Document
&);
108 static bool ShouldUseChromePrefs(const dom::Document
& aDocument
) {
109 return PrefsKindFor(aDocument
) == PrefsKind::Chrome
;
112 static bool MayForceColors() { return !ContentPrefs().mUseDocumentColors
; }
114 static const Prefs
& PrefsFor(const dom::Document
& aDocument
) {
115 switch (PrefsKindFor(aDocument
)) {
116 case PrefsKind::Chrome
:
117 return ChromePrefs();
118 case PrefsKind::Print
:
120 case PrefsKind::Content
:
123 return ContentPrefs();
127 static bool sInitialized
;
128 static Prefs sChromePrefs
;
129 static Prefs sPrintPrefs
;
130 static Prefs sContentPrefs
;
132 static void Initialize();
135 } // namespace mozilla