Bug 1885565 - Part 2: Fix up parameter ordering and kDoc descriptions in NavigationBa...
[gecko.git] / widget / nsXPLookAndFeel.h
blob0f308f6935bc05b3f28655a582301591c63233b7
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 virtual TitlebarAction GetTitlebarAction(TitlebarEvent aEvent) {
61 return TitlebarAction::None;
64 static bool LookAndFeelFontToStyle(const LookAndFeelFont&, nsString& aName,
65 gfxFontStyle&);
66 static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName,
67 const gfxFontStyle&);
69 virtual void SetDataImpl(FullLookAndFeel&& aTables) {}
71 virtual void NativeInit() = 0;
73 virtual void GetThemeInfo(nsACString&) {}
75 protected:
76 nsXPLookAndFeel() = default;
78 static nscolor GetStandinForNativeColor(ColorID, ColorScheme);
80 // A platform-agnostic dark-color scheme, for platforms where we don't have
81 // "native" dark colors, like Windows and Android.
82 static mozilla::Maybe<nscolor> GenericDarkColor(ColorID);
83 mozilla::Maybe<nscolor> GetUncachedColor(ColorID, ColorScheme, UseStandins);
85 void RecordTelemetry();
86 virtual void RecordLookAndFeelSpecificTelemetry() {}
88 static void OnPrefChanged(const char* aPref, void* aClosure);
90 static bool sInitialized;
92 static nsXPLookAndFeel* sInstance;
93 static bool sShutdown;
96 #endif