2019-03-07 00:34:30 +03:00
|
|
|
/* -*- 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"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PreferenceSheet {
|
|
|
|
struct Prefs {
|
2021-07-25 00:10:44 +03:00
|
|
|
struct {
|
|
|
|
nscolor mLink = NS_RGB(0x00, 0x00, 0xEE);
|
|
|
|
nscolor mActiveLink = NS_RGB(0xEE, 0x00, 0x00);
|
|
|
|
nscolor mVisitedLink = NS_RGB(0x55, 0x1A, 0x8B);
|
2019-03-07 00:34:30 +03:00
|
|
|
|
2021-07-25 00:10:44 +03:00
|
|
|
nscolor mDefault = NS_RGB(0, 0, 0);
|
|
|
|
nscolor mDefaultBackground = NS_RGB(0xFF, 0xFF, 0xFF);
|
2019-03-07 00:34:30 +03:00
|
|
|
|
2021-07-25 00:10:44 +03:00
|
|
|
nscolor mFocusText = mDefault;
|
|
|
|
nscolor mFocusBackground = mDefaultBackground;
|
|
|
|
} mColors;
|
2019-03-07 00:34:30 +03:00
|
|
|
|
2019-03-07 00:36:12 +03:00
|
|
|
bool mIsChrome = false;
|
|
|
|
bool mUseAccessibilityTheme = false;
|
|
|
|
|
2019-11-15 16:39:08 +03:00
|
|
|
bool mUseDocumentColors = true;
|
2019-03-07 00:34:30 +03:00
|
|
|
|
2021-03-16 19:46:05 +03:00
|
|
|
// Whether the non-native theme should use system colors for widgets.
|
|
|
|
// We only do that if we have a high-contrast theme _and_ we are overriding
|
|
|
|
// the document colors. Otherwise it causes issues when pages only override
|
|
|
|
// some of the system colors, specially in dark themes mode.
|
|
|
|
bool NonNativeThemeShouldUseSystemColors() const {
|
|
|
|
return mUseAccessibilityTheme && !mUseDocumentColors;
|
|
|
|
}
|
|
|
|
|
2019-03-07 00:34:30 +03:00
|
|
|
void Load(bool aIsChrome);
|
|
|
|
};
|
|
|
|
|
|
|
|
static void EnsureInitialized() {
|
|
|
|
if (sInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Refresh() {
|
|
|
|
sInitialized = false;
|
|
|
|
EnsureInitialized();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Prefs& ContentPrefs() {
|
|
|
|
MOZ_ASSERT(sInitialized);
|
|
|
|
return sContentPrefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Prefs& ChromePrefs() {
|
|
|
|
MOZ_ASSERT(sInitialized);
|
|
|
|
return sChromePrefs;
|
|
|
|
}
|
|
|
|
|
2021-07-25 00:10:44 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-07 00:34:30 +03:00
|
|
|
static const Prefs& PrefsFor(const dom::Document& aDocument) {
|
2021-07-25 00:10:44 +03:00
|
|
|
switch (PrefsKindFor(aDocument)) {
|
|
|
|
case PrefsKind::Chrome:
|
|
|
|
return ChromePrefs();
|
|
|
|
case PrefsKind::Print:
|
|
|
|
return PrintPrefs();
|
|
|
|
case PrefsKind::Content:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ContentPrefs();
|
2019-03-07 00:34:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sInitialized;
|
|
|
|
static Prefs sChromePrefs;
|
2021-07-25 00:10:44 +03:00
|
|
|
static Prefs sPrintPrefs;
|
|
|
|
static Prefs sContentPrefs;
|
2019-03-07 00:34:30 +03:00
|
|
|
|
|
|
|
static void Initialize();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|