Bug 1400317 - Create single source of truth for IsAppThemed r=jmathies

This Win32 API will need to be remoted for Win32k lockdown. As it falls under
the <uxtheme.h> system header, I believe it makes the most sense to centralize
it as "nsUXThemeData::IsAppThemed()", and then turn that into a remoted API.

Differential Revision: https://phabricator.services.mozilla.com/D80564
This commit is contained in:
Chris Martin 2020-06-26 13:16:11 +00:00
parent 268766d0e7
commit f26e59ad61
4 changed files with 11 additions and 7 deletions

View File

@ -227,7 +227,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
idx = COLOR_HIGHLIGHT;
break;
case ColorID::MozMenubarhovertext:
if (!IsAppThemed()) {
if (!nsUXThemeData::IsAppThemed()) {
idx = nsUXThemeData::AreFlatMenusEnabled() ? COLOR_HIGHLIGHTTEXT
: COLOR_MENUTEXT;
break;
@ -448,7 +448,7 @@ nsresult nsLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) {
aResult = 3;
break;
case IntID::WindowsClassic:
aResult = !IsAppThemed();
aResult = !nsUXThemeData::IsAppThemed();
break;
case IntID::TouchEnabled:
aResult = WinUtils::IsTouchDeviceSupportPresent();
@ -899,7 +899,7 @@ void nsLookAndFeel::EnsureInit() {
res = GetAccentColorText(mColorAccentText);
mHasColorAccentText = NS_SUCCEEDED(res);
if (IsAppThemed()) {
if (nsUXThemeData::IsAppThemed()) {
res = ::GetColorFromTheme(eUXMenu, MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR,
mColorMenuHoverText);
mHasColorMenuHoverText = NS_SUCCEEDED(res);

View File

@ -345,7 +345,7 @@ static CaptionButtonPadding buttonData[3] = {
static void AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) {
if (!aSize) return;
RECT offset;
if (!IsAppThemed())
if (!nsUXThemeData::IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];
@ -357,7 +357,7 @@ static void AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) {
// the area we draw into to compensate.
static void OffsetBackgroundRect(RECT& rect, CaptionButton button) {
RECT offset;
if (!IsAppThemed())
if (!nsUXThemeData::IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];

View File

@ -308,7 +308,7 @@ void nsUXThemeData::UpdateNativeThemeInfo() {
sIsHighContrastOn = false;
}
if (!IsAppThemed()) {
if (!nsUXThemeData::IsAppThemed()) {
sThemeId = LookAndFeel::eWindowsTheme_Classic;
return;
}
@ -400,3 +400,6 @@ bool nsUXThemeData::AreFlatMenusEnabled() {
return !!::SystemParametersInfo(SPI_GETFLATMENU, 0, &useFlat, 0) ? useFlat
: false;
}
// static
bool nsUXThemeData::IsAppThemed() { return !!::IsAppThemed(); }

View File

@ -127,5 +127,6 @@ class nsUXThemeData {
static bool IsHighContrastOn();
static bool AreFlatMenusEnabled();
static bool IsAppThemed();
};
#endif // __UXThemeData_h__