Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / widget / nsXPLookAndFeel.h
blob0f7dca581949226550624bbeb33fb2c9da5b0aa4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef __nsXPLookAndFeel
7 #define __nsXPLookAndFeel
9 #include "mozilla/Maybe.h"
10 #include "mozilla/LookAndFeel.h"
11 #include "mozilla/widget/LookAndFeelTypes.h"
12 #include "nsTArray.h"
14 class nsLookAndFeel;
16 class nsXPLookAndFeel : public mozilla::LookAndFeel {
17 public:
18 using FullLookAndFeel = mozilla::widget::FullLookAndFeel;
19 using LookAndFeelFont = mozilla::widget::LookAndFeelFont;
21 virtual ~nsXPLookAndFeel();
23 static nsXPLookAndFeel* GetInstance();
24 static void Shutdown();
26 void Init();
28 // Gets the pref name for a given color, just for debugging purposes.
29 static const char* GetColorPrefName(ColorID);
31 // These functions will return a value specified by an override pref, if it
32 // exists, and otherwise will call into the NativeGetXxx function to get the
33 // platform-specific value.
35 // NS_ERROR_NOT_AVAILABLE is returned if there is neither an override pref or
36 // a platform-specific value.
37 nsresult GetColorValue(ColorID, ColorScheme, UseStandins, nscolor& aResult);
38 nsresult GetIntValue(IntID aID, int32_t& aResult);
39 nsresult GetFloatValue(FloatID aID, float& aResult);
40 // Same, but returns false if there is no platform-specific value.
41 // (There are no override prefs for font values.)
42 bool GetFontValue(FontID aID, nsString& aName, gfxFontStyle& aStyle);
44 virtual nsresult NativeGetInt(IntID aID, int32_t& aResult) = 0;
45 virtual nsresult NativeGetFloat(FloatID aID, float& aResult) = 0;
46 virtual nsresult NativeGetColor(ColorID, ColorScheme, nscolor& aResult) = 0;
47 virtual bool NativeGetFont(FontID aID, nsString& aName,
48 gfxFontStyle& aStyle) = 0;
50 virtual void RefreshImpl();
52 virtual char16_t GetPasswordCharacterImpl() { return char16_t('*'); }
54 virtual bool GetEchoPasswordImpl() { return false; }
56 virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
58 virtual bool GetDefaultDrawInTitlebar() { return true; }
60 static bool LookAndFeelFontToStyle(const LookAndFeelFont&, nsString& aName,
61 gfxFontStyle&);
62 static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName,
63 const gfxFontStyle&);
65 virtual void SetDataImpl(FullLookAndFeel&& aTables) {}
67 virtual void NativeInit() = 0;
69 virtual void GetThemeInfo(nsACString&) {}
71 protected:
72 nsXPLookAndFeel() = default;
74 static nscolor GetStandinForNativeColor(ColorID, ColorScheme);
76 // A platform-agnostic dark-color scheme, for platforms where we don't have
77 // "native" dark colors, like Windows and Android.
78 static mozilla::Maybe<nscolor> GenericDarkColor(ColorID);
79 mozilla::Maybe<nscolor> GetUncachedColor(ColorID, ColorScheme, UseStandins);
81 void RecordTelemetry();
82 virtual void RecordLookAndFeelSpecificTelemetry() {}
84 static void OnPrefChanged(const char* aPref, void* aClosure);
86 static bool sInitialized;
88 static nsXPLookAndFeel* sInstance;
89 static bool sShutdown;
92 #endif