summaryrefslogtreecommitdiffstats
path: root/layout/style/PreferenceSheet.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /layout/style/PreferenceSheet.h
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--layout/style/PreferenceSheet.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/layout/style/PreferenceSheet.h b/layout/style/PreferenceSheet.h
new file mode 100644
index 0000000000..3b3c2f70b7
--- /dev/null
+++ b/layout/style/PreferenceSheet.h
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Some prefable colors for style system use */
+
+#ifndef mozilla_ColorPreferences_h
+#define mozilla_ColorPreferences_h
+
+#include "nsColor.h"
+#include "mozilla/ColorScheme.h"
+
+namespace mozilla {
+
+namespace dom {
+class Document;
+}
+
+struct PreferenceSheet {
+ struct Prefs {
+ struct Colors {
+ nscolor mLink = NS_RGB(0x00, 0x00, 0xEE);
+ nscolor mActiveLink = NS_RGB(0xEE, 0x00, 0x00);
+ nscolor mVisitedLink = NS_RGB(0x55, 0x1A, 0x8B);
+
+ nscolor mDefault = NS_RGB(0, 0, 0);
+ nscolor mDefaultBackground = NS_RGB(0xFF, 0xFF, 0xFF);
+
+ nscolor mFocusText = mDefault;
+ nscolor mFocusBackground = mDefaultBackground;
+ } mLightColors, mDarkColors;
+
+ const Colors& ColorsFor(ColorScheme aScheme) const {
+ return mMustUseLightColorSet || aScheme == ColorScheme::Light
+ ? mLightColors
+ : mDarkColors;
+ }
+
+ bool mIsChrome = false;
+ bool mUseAccessibilityTheme = false;
+ bool mUseDocumentColors = true;
+ bool mUsePrefColors = false;
+ bool mUseStandins = false;
+ bool mMustUseLightColorSet = false;
+
+ // Sometimes we can force a color scheme on a document, or honor the
+ // preferred color-scheme in more cases, depending on whether we're forcing
+ // colors or not.
+ enum class ColorSchemeChoice : uint8_t {
+ // We're not forcing colors, use standard algorithm based on specified
+ // style and meta tags and so on.
+ Standard,
+ // We can honor whatever the preferred color-scheme for the document is
+ // (the preferred color-scheme of the user, since we're forcing colors).
+ UserPreferred,
+ Light,
+ Dark,
+ };
+
+ ColorSchemeChoice mColorSchemeChoice = ColorSchemeChoice::Standard;
+
+ // Whether the non-native theme should use real system colors for widgets.
+ bool NonNativeThemeShouldBeHighContrast() const;
+
+ void Load(bool aIsChrome);
+ void LoadColors(bool aIsLight);
+ };
+
+ static void EnsureInitialized() {
+ if (sInitialized) {
+ return;
+ }
+ Initialize();
+ }
+
+ static void Refresh() {
+ sInitialized = false;
+ Initialize();
+ }
+
+ static bool AffectedByPref(const nsACString&);
+
+ static Prefs& ContentPrefs() {
+ MOZ_ASSERT(sInitialized);
+ return sContentPrefs;
+ }
+
+ static Prefs& ChromePrefs() {
+ MOZ_ASSERT(sInitialized);
+ return sChromePrefs;
+ }
+
+ static Prefs& PrintPrefs() {
+ MOZ_ASSERT(sInitialized);
+ return sPrintPrefs;
+ }
+
+ enum class PrefsKind {
+ Chrome,
+ Print,
+ Content,
+ };
+
+ static PrefsKind PrefsKindFor(const dom::Document&);
+
+ static bool ShouldUseChromePrefs(const dom::Document& aDocument) {
+ return PrefsKindFor(aDocument) == PrefsKind::Chrome;
+ }
+
+ static bool MayForceColors() { return !ContentPrefs().mUseDocumentColors; }
+
+ static const Prefs& PrefsFor(const dom::Document& aDocument) {
+ switch (PrefsKindFor(aDocument)) {
+ case PrefsKind::Chrome:
+ return ChromePrefs();
+ case PrefsKind::Print:
+ return PrintPrefs();
+ case PrefsKind::Content:
+ break;
+ }
+ return ContentPrefs();
+ }
+
+ private:
+ static bool sInitialized;
+ static Prefs sChromePrefs;
+ static Prefs sPrintPrefs;
+ static Prefs sContentPrefs;
+
+ static void Initialize();
+};
+
+} // namespace mozilla
+
+#endif