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/. */ 6 7 /* Some prefable colors for style system use */ 8 9 #ifndef mozilla_ColorPreferences_h 10 #define mozilla_ColorPreferences_h 11 12 #include "nsColor.h" 13 14 namespace mozilla { 15 16 namespace dom { 17 class Document; 18 } 19 20 struct PreferenceSheet { 21 struct Prefs { 22 nscolor mLinkColor = NS_RGB(0x00, 0x00, 0xEE); 23 nscolor mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00); 24 nscolor mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B); 25 26 nscolor mDefaultColor = NS_RGB(0, 0, 0); 27 nscolor mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); 28 29 nscolor mLinkBackgroundColor = mDefaultBackgroundColor; 30 31 nscolor mFocusTextColor = mDefaultColor; 32 nscolor mFocusBackgroundColor = mDefaultBackgroundColor; 33 34 bool mIsChrome = false; 35 bool mUseAccessibilityTheme = false; 36 37 bool mUnderlineLinks = true; 38 bool mUseFocusColors = false; 39 bool mUseDocumentColors = true; 40 uint8_t mFocusRingWidth = 1; 41 uint8_t mFocusRingStyle = 1; 42 bool mFocusRingOnAnything = false; 43 44 // Whether the non-native theme should use system colors for widgets. 45 // We only do that if we have a high-contrast theme _and_ we are overriding 46 // the document colors. Otherwise it causes issues when pages only override 47 // some of the system colors, specially in dark themes mode. NonNativeThemeShouldUseSystemColorsPreferenceSheet::Prefs48 bool NonNativeThemeShouldUseSystemColors() const { 49 return mUseAccessibilityTheme && !mUseDocumentColors; 50 } 51 52 void Load(bool aIsChrome); 53 }; 54 EnsureInitializedPreferenceSheet55 static void EnsureInitialized() { 56 if (sInitialized) { 57 return; 58 } 59 Initialize(); 60 } 61 RefreshPreferenceSheet62 static void Refresh() { 63 sInitialized = false; 64 EnsureInitialized(); 65 } 66 ContentPrefsPreferenceSheet67 static Prefs& ContentPrefs() { 68 MOZ_ASSERT(sInitialized); 69 return sContentPrefs; 70 } 71 ChromePrefsPreferenceSheet72 static Prefs& ChromePrefs() { 73 MOZ_ASSERT(sInitialized); 74 return sChromePrefs; 75 } 76 77 static bool ShouldUseChromePrefs(const dom::Document&); PrefsForPreferenceSheet78 static const Prefs& PrefsFor(const dom::Document& aDocument) { 79 return ShouldUseChromePrefs(aDocument) ? ChromePrefs() : ContentPrefs(); 80 } 81 82 private: 83 static bool sInitialized; 84 static Prefs sContentPrefs; 85 static Prefs sChromePrefs; 86 87 static void Initialize(); 88 }; 89 90 } // namespace mozilla 91 92 #endif 93