2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-03-31 02:32:18 +04:00
|
|
|
|
|
|
|
#ifndef __nsXPLookAndFeel
|
|
|
|
#define __nsXPLookAndFeel
|
|
|
|
|
2021-09-29 13:20:56 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2011-09-09 06:27:12 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2020-11-12 02:26:51 +03:00
|
|
|
#include "mozilla/widget/LookAndFeelTypes.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "nsTArray.h"
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
class nsLookAndFeel;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
2000-03-31 02:32:18 +04:00
|
|
|
public:
|
2021-03-25 01:57:36 +03:00
|
|
|
using FullLookAndFeel = mozilla::widget::FullLookAndFeel;
|
|
|
|
using LookAndFeelFont = mozilla::widget::LookAndFeelFont;
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
virtual ~nsXPLookAndFeel();
|
|
|
|
|
2017-04-04 17:22:00 +03:00
|
|
|
static nsXPLookAndFeel* GetInstance();
|
2011-09-09 06:27:11 +04:00
|
|
|
static void Shutdown();
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
void Init();
|
|
|
|
|
2021-06-16 17:13:43 +03:00
|
|
|
// Gets the pref name for a given color, just for debugging purposes.
|
|
|
|
static const char* GetColorPrefName(ColorID);
|
|
|
|
|
2020-11-21 02:52:47 +03:00
|
|
|
// These functions will return a value specified by an override pref, if it
|
|
|
|
// exists, and otherwise will call into the NativeGetXxx function to get the
|
|
|
|
// platform-specific value.
|
2000-03-31 02:32:18 +04:00
|
|
|
//
|
2020-11-21 02:52:47 +03:00
|
|
|
// NS_ERROR_NOT_AVAILABLE is returned if there is neither an override pref or
|
|
|
|
// a platform-specific value.
|
2021-04-02 19:34:35 +03:00
|
|
|
nsresult GetColorValue(ColorID, ColorScheme, UseStandins, nscolor& aResult);
|
2020-11-21 02:52:47 +03:00
|
|
|
nsresult GetIntValue(IntID aID, int32_t& aResult);
|
|
|
|
nsresult GetFloatValue(FloatID aID, float& aResult);
|
|
|
|
// Same, but returns false if there is no platform-specific value.
|
|
|
|
// (There are no override prefs for font values.)
|
2021-03-25 01:57:36 +03:00
|
|
|
bool GetFontValue(FontID aID, nsString& aName, gfxFontStyle& aStyle);
|
2020-11-21 02:52:47 +03:00
|
|
|
|
|
|
|
virtual nsresult NativeGetInt(IntID aID, int32_t& aResult) = 0;
|
|
|
|
virtual nsresult NativeGetFloat(FloatID aID, float& aResult) = 0;
|
2021-04-03 01:17:55 +03:00
|
|
|
virtual nsresult NativeGetColor(ColorID, ColorScheme, nscolor& aResult) = 0;
|
2020-11-21 02:52:47 +03:00
|
|
|
virtual bool NativeGetFont(FontID aID, nsString& aName,
|
|
|
|
gfxFontStyle& aStyle) = 0;
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
virtual void RefreshImpl();
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
virtual char16_t GetPasswordCharacterImpl() { return char16_t('*'); }
|
2011-09-09 06:27:13 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool GetEchoPasswordImpl() { return false; }
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
|
2012-07-13 06:26:20 +04:00
|
|
|
|
2021-10-21 12:07:12 +03:00
|
|
|
virtual bool GetDefaultDrawInTitlebar() { return true; }
|
|
|
|
|
2021-03-25 01:57:36 +03:00
|
|
|
static bool LookAndFeelFontToStyle(const LookAndFeelFont&, nsString& aName,
|
|
|
|
gfxFontStyle&);
|
|
|
|
static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName,
|
|
|
|
const gfxFontStyle&);
|
2020-11-12 02:26:51 +03:00
|
|
|
|
2020-12-16 07:17:36 +03:00
|
|
|
virtual void SetDataImpl(FullLookAndFeel&& aTables) {}
|
2015-04-22 17:58:15 +03:00
|
|
|
|
2017-08-03 23:16:31 +03:00
|
|
|
virtual void NativeInit() = 0;
|
|
|
|
|
2021-07-20 23:09:09 +03:00
|
|
|
virtual void GetThemeInfo(nsACString&) {}
|
2020-12-16 07:41:05 +03:00
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
protected:
|
2020-01-14 08:50:53 +03:00
|
|
|
nsXPLookAndFeel() = default;
|
2011-09-09 06:27:13 +04:00
|
|
|
|
2021-09-29 13:20:56 +03:00
|
|
|
static nscolor GetStandinForNativeColor(ColorID, ColorScheme);
|
|
|
|
|
|
|
|
// A platform-agnostic dark-color scheme, for platforms where we don't have
|
|
|
|
// "native" dark colors, like Windows and Android.
|
|
|
|
static mozilla::Maybe<nscolor> GenericDarkColor(ColorID);
|
Bug 1776162 - Improve LookAndFeel color caching. r=mstange
To be honest, I'm a bit baffled that bug 1773795 caused a performance
regression, but I think it's because the standins codepath is not really
cached, so system colors that are "spoofed" always go through the
massive switch, which could potentially be expensive.
To fix, this, rejigger a bit the caches so that we key on both
color-scheme and use-standins. Also, while at it, make the set of colors
we spoof a single bitflag check, rather than relying on the compiler to
do something potentially smart with it.
I had to shuffle the order of colors around so that the expression to
initialize the bitfield is constexpr (doesn't go over 1 << 64), but
other than that this patch should be relatively straight-forward.
Differential Revision: https://phabricator.services.mozilla.com/D150100
2022-06-24 01:38:02 +03:00
|
|
|
mozilla::Maybe<nscolor> GetUncachedColor(ColorID, ColorScheme, UseStandins);
|
2021-09-29 13:20:56 +03:00
|
|
|
|
2019-12-20 22:05:12 +03:00
|
|
|
void RecordTelemetry();
|
2020-10-15 07:50:48 +03:00
|
|
|
virtual void RecordLookAndFeelSpecificTelemetry() {}
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
static void OnPrefChanged(const char* aPref, void* aClosure);
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sInitialized;
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2017-04-04 17:22:00 +03:00
|
|
|
static nsXPLookAndFeel* sInstance;
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sShutdown;
|
2011-09-09 06:27:11 +04:00
|
|
|
};
|
2000-03-31 02:32:18 +04:00
|
|
|
|
|
|
|
#endif
|