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/LookAndFeel.h"
10 #include "mozilla/widget/LookAndFeelTypes.h"
15 class nsXPLookAndFeel
: public mozilla::LookAndFeel
{
17 using FullLookAndFeel
= mozilla::widget::FullLookAndFeel
;
18 using LookAndFeelFont
= mozilla::widget::LookAndFeelFont
;
19 using LookAndFeelTheme
= mozilla::widget::LookAndFeelTheme
;
21 virtual ~nsXPLookAndFeel();
23 static nsXPLookAndFeel
* GetInstance();
24 static void Shutdown();
28 // These functions will return a value specified by an override pref, if it
29 // exists, and otherwise will call into the NativeGetXxx function to get the
30 // platform-specific value.
32 // NS_ERROR_NOT_AVAILABLE is returned if there is neither an override pref or
33 // a platform-specific value.
34 nsresult
GetColorValue(ColorID
, ColorScheme
, UseStandins
, nscolor
& aResult
);
35 nsresult
GetIntValue(IntID aID
, int32_t& aResult
);
36 nsresult
GetFloatValue(FloatID aID
, float& aResult
);
37 // Same, but returns false if there is no platform-specific value.
38 // (There are no override prefs for font values.)
39 bool GetFontValue(FontID aID
, nsString
& aName
, gfxFontStyle
& aStyle
);
41 virtual nsresult
NativeGetInt(IntID aID
, int32_t& aResult
) = 0;
42 virtual nsresult
NativeGetFloat(FloatID aID
, float& aResult
) = 0;
43 virtual nsresult
NativeGetColor(ColorID
, ColorScheme
, nscolor
& aResult
) = 0;
44 virtual bool NativeGetFont(FontID aID
, nsString
& aName
,
45 gfxFontStyle
& aStyle
) = 0;
47 virtual void RefreshImpl();
49 virtual char16_t
GetPasswordCharacterImpl() { return char16_t('*'); }
51 virtual bool GetEchoPasswordImpl() { return false; }
53 virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
55 static bool LookAndFeelFontToStyle(const LookAndFeelFont
&, nsString
& aName
,
57 static LookAndFeelFont
StyleToLookAndFeelFont(const nsAString
& aName
,
60 virtual void SetDataImpl(FullLookAndFeel
&& aTables
) {}
62 virtual void NativeInit() = 0;
64 virtual void GetGtkContentTheme(LookAndFeelTheme
&) {}
67 nsXPLookAndFeel() = default;
69 static nscolor
GetStandinForNativeColor(ColorID
);
70 void RecordTelemetry();
71 virtual void RecordLookAndFeelSpecificTelemetry() {}
73 static void OnPrefChanged(const char* aPref
, void* aClosure
);
75 static bool sInitialized
;
77 static nsXPLookAndFeel
* sInstance
;
78 static bool sShutdown
;