summaryrefslogtreecommitdiffstats
path: root/layout/style/PreferenceSheet.h
blob: 5ae16c50e4fe3de92417d82f1ddec00f33676346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* -*- 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 {
    nscolor mLinkColor = NS_RGB(0x00, 0x00, 0xEE);
    nscolor mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00);
    nscolor mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B);

    nscolor mDefaultColor = NS_RGB(0, 0, 0);
    nscolor mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);

    nscolor mLinkBackgroundColor = mDefaultBackgroundColor;

    nscolor mFocusTextColor = mDefaultColor;
    nscolor mFocusBackgroundColor = mDefaultBackgroundColor;

    bool mIsChrome = false;
    bool mUseAccessibilityTheme = false;

    bool mUnderlineLinks = true;
    bool mUseFocusColors = false;
    bool mUseDocumentColors = true;
    uint8_t mFocusRingWidth = 1;
    uint8_t mFocusRingStyle = 1;
    bool mFocusRingOnAnything = false;

    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;
  }

  static bool ShouldUseChromePrefs(const dom::Document&);
  static const Prefs& PrefsFor(const dom::Document& aDocument) {
    return ShouldUseChromePrefs(aDocument) ? ChromePrefs() : ContentPrefs();
  }

 private:
  static bool sInitialized;
  static Prefs sContentPrefs;
  static Prefs sChromePrefs;

  static void Initialize();
};

}  // namespace mozilla

#endif