зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1735078 - Clean up some unused LookAndFeel code on Windows. r=mhowell
Differential Revision: https://phabricator.services.mozilla.com/D128025
This commit is contained in:
Родитель
d62c73236f
Коммит
067255ed45
|
@ -202,10 +202,6 @@ class LookAndFeel {
|
||||||
* If this metric != 0, support window dragging on the menubar.
|
* If this metric != 0, support window dragging on the menubar.
|
||||||
*/
|
*/
|
||||||
MenuBarDrag,
|
MenuBarDrag,
|
||||||
/**
|
|
||||||
* Return the appropriate WindowsThemeIdentifier for the current theme.
|
|
||||||
*/
|
|
||||||
WindowsThemeIdentifier,
|
|
||||||
/**
|
/**
|
||||||
* Return an appropriate os version identifier.
|
* Return an appropriate os version identifier.
|
||||||
*/
|
*/
|
||||||
|
@ -358,21 +354,6 @@ class LookAndFeel {
|
||||||
return GetInt(IntID::UseOverlayScrollbars);
|
return GetInt(IntID::UseOverlayScrollbars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Windows themes we currently detect.
|
|
||||||
*/
|
|
||||||
enum WindowsTheme {
|
|
||||||
eWindowsTheme_Generic = 0, // unrecognized theme
|
|
||||||
eWindowsTheme_Classic,
|
|
||||||
eWindowsTheme_Aero,
|
|
||||||
eWindowsTheme_LunaBlue,
|
|
||||||
eWindowsTheme_LunaOlive,
|
|
||||||
eWindowsTheme_LunaSilver,
|
|
||||||
eWindowsTheme_Royale,
|
|
||||||
eWindowsTheme_Zune,
|
|
||||||
eWindowsTheme_AeroLite
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operating system versions.
|
* Operating system versions.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -361,7 +361,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IntID::WindowsDefaultTheme:
|
case IntID::WindowsDefaultTheme:
|
||||||
case IntID::WindowsThemeIdentifier:
|
|
||||||
case IntID::OperatingSystemVersionIdentifier:
|
case IntID::OperatingSystemVersionIdentifier:
|
||||||
aResult = 0;
|
aResult = 0;
|
||||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
|
@ -480,7 +480,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||||
case IntID::DWMCompositor:
|
case IntID::DWMCompositor:
|
||||||
case IntID::WindowsClassic:
|
case IntID::WindowsClassic:
|
||||||
case IntID::WindowsDefaultTheme:
|
case IntID::WindowsDefaultTheme:
|
||||||
case IntID::WindowsThemeIdentifier:
|
|
||||||
case IntID::OperatingSystemVersionIdentifier:
|
case IntID::OperatingSystemVersionIdentifier:
|
||||||
aResult = 0;
|
aResult = 0;
|
||||||
res = NS_ERROR_NOT_IMPLEMENTED;
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
|
@ -764,7 +764,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||||
case IntID::DWMCompositor:
|
case IntID::DWMCompositor:
|
||||||
case IntID::WindowsClassic:
|
case IntID::WindowsClassic:
|
||||||
case IntID::WindowsDefaultTheme:
|
case IntID::WindowsDefaultTheme:
|
||||||
case IntID::WindowsThemeIdentifier:
|
|
||||||
case IntID::OperatingSystemVersionIdentifier:
|
case IntID::OperatingSystemVersionIdentifier:
|
||||||
aResult = 0;
|
aResult = 0;
|
||||||
res = NS_ERROR_NOT_IMPLEMENTED;
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
|
@ -227,7 +227,6 @@ nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||||
case IntID::MenuBarDrag:
|
case IntID::MenuBarDrag:
|
||||||
aResult = 0;
|
aResult = 0;
|
||||||
break;
|
break;
|
||||||
case IntID::WindowsThemeIdentifier:
|
|
||||||
case IntID::OperatingSystemVersionIdentifier:
|
case IntID::OperatingSystemVersionIdentifier:
|
||||||
aResult = 0;
|
aResult = 0;
|
||||||
res = NS_ERROR_NOT_IMPLEMENTED;
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
|
@ -150,7 +150,6 @@ static const char sIntPrefs[][43] = {
|
||||||
"ui.IMESelectedConvertedTextUnderlineStyle",
|
"ui.IMESelectedConvertedTextUnderlineStyle",
|
||||||
"ui.SpellCheckerUnderlineStyle",
|
"ui.SpellCheckerUnderlineStyle",
|
||||||
"ui.menuBarDrag",
|
"ui.menuBarDrag",
|
||||||
"ui.windowsThemeIdentifier",
|
|
||||||
"ui.operatingSystemVersionIdentifier",
|
"ui.operatingSystemVersionIdentifier",
|
||||||
"ui.scrollbarButtonAutoRepeatBehavior",
|
"ui.scrollbarButtonAutoRepeatBehavior",
|
||||||
"ui.tooltipDelay",
|
"ui.tooltipDelay",
|
||||||
|
|
|
@ -457,9 +457,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||||
case IntID::WindowsDefaultTheme:
|
case IntID::WindowsDefaultTheme:
|
||||||
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
||||||
break;
|
break;
|
||||||
case IntID::WindowsThemeIdentifier:
|
|
||||||
aResult = nsUXThemeData::GetNativeThemeId();
|
|
||||||
break;
|
|
||||||
case IntID::OperatingSystemVersionIdentifier: {
|
case IntID::OperatingSystemVersionIdentifier: {
|
||||||
aResult = int32_t(GetOperatingSystemVersion());
|
aResult = int32_t(GetOperatingSystemVersion());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -29,6 +29,21 @@ bool nsUXThemeData::sCommandButtonBoxMetricsInitialized = false;
|
||||||
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
|
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
|
||||||
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
|
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows themes we currently detect.
|
||||||
|
*/
|
||||||
|
enum class WindowsTheme {
|
||||||
|
Generic = 0, // unrecognized theme
|
||||||
|
Classic,
|
||||||
|
Aero,
|
||||||
|
Luna,
|
||||||
|
Royale,
|
||||||
|
Zune,
|
||||||
|
AeroLite
|
||||||
|
};
|
||||||
|
|
||||||
|
static WindowsTheme sThemeId = WindowsTheme::Generic;
|
||||||
|
|
||||||
nsUXThemeData::ThemeHandle::~ThemeHandle() { Close(); }
|
nsUXThemeData::ThemeHandle::~ThemeHandle() { Close(); }
|
||||||
|
|
||||||
void nsUXThemeData::ThemeHandle::OpenOnce(HWND aWindow, LPCWSTR aClassList) {
|
void nsUXThemeData::ThemeHandle::OpenOnce(HWND aWindow, LPCWSTR aClassList) {
|
||||||
|
@ -50,7 +65,7 @@ void nsUXThemeData::ThemeHandle::Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsUXThemeData::ThemeHandle::operator HANDLE() {
|
nsUXThemeData::ThemeHandle::operator HANDLE() {
|
||||||
return mHandle.isSome() ? mHandle.value() : nullptr;
|
return mHandle.valueOr(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsUXThemeData::Invalidate() {
|
void nsUXThemeData::Invalidate() {
|
||||||
|
@ -219,8 +234,8 @@ void nsUXThemeData::UpdateTitlebarInfo(HWND aWnd) {
|
||||||
// We try to avoid activating this window, but on Aero basic (aero without
|
// We try to avoid activating this window, but on Aero basic (aero without
|
||||||
// compositor) and aero lite (special theme for win server 2012/2013) we may
|
// compositor) and aero lite (special theme for win server 2012/2013) we may
|
||||||
// get the wrong information if the window isn't activated, so we have to:
|
// get the wrong information if the window isn't activated, so we have to:
|
||||||
if (sThemeId == LookAndFeel::eWindowsTheme_AeroLite ||
|
if (sThemeId == WindowsTheme::AeroLite ||
|
||||||
(sThemeId == LookAndFeel::eWindowsTheme_Aero &&
|
(sThemeId == WindowsTheme::Aero &&
|
||||||
!gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled())) {
|
!gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled())) {
|
||||||
showType = SW_SHOW;
|
showType = SW_SHOW;
|
||||||
}
|
}
|
||||||
|
@ -265,30 +280,18 @@ void nsUXThemeData::UpdateTitlebarInfo(HWND aWnd) {
|
||||||
// theme color (silver, olive, blue)
|
// theme color (silver, olive, blue)
|
||||||
// system colors
|
// system colors
|
||||||
|
|
||||||
struct THEMELIST {
|
const struct {
|
||||||
LPCWSTR name;
|
LPCWSTR name;
|
||||||
int type;
|
WindowsTheme type;
|
||||||
};
|
} kKnownThemes[] = {{L"aero.msstyles", WindowsTheme::Aero},
|
||||||
|
{L"aerolite.msstyles", WindowsTheme::AeroLite},
|
||||||
const THEMELIST knownThemes[] = {{L"aero.msstyles", WINTHEME_AERO},
|
{L"luna.msstyles", WindowsTheme::Luna},
|
||||||
{L"aerolite.msstyles", WINTHEME_AERO_LITE},
|
{L"zune.msstyles", WindowsTheme::Zune},
|
||||||
{L"luna.msstyles", WINTHEME_LUNA},
|
{L"royale.msstyles", WindowsTheme::Royale}};
|
||||||
{L"zune.msstyles", WINTHEME_ZUNE},
|
|
||||||
{L"royale.msstyles", WINTHEME_ROYALE}};
|
|
||||||
|
|
||||||
const THEMELIST knownColors[] = {{L"normalcolor", WINTHEMECOLOR_NORMAL},
|
|
||||||
{L"homestead", WINTHEMECOLOR_HOMESTEAD},
|
|
||||||
{L"metallic", WINTHEMECOLOR_METALLIC}};
|
|
||||||
|
|
||||||
LookAndFeel::WindowsTheme nsUXThemeData::sThemeId =
|
|
||||||
LookAndFeel::eWindowsTheme_Generic;
|
|
||||||
|
|
||||||
bool nsUXThemeData::sIsDefaultWindowsTheme = false;
|
bool nsUXThemeData::sIsDefaultWindowsTheme = false;
|
||||||
bool nsUXThemeData::sIsHighContrastOn = false;
|
bool nsUXThemeData::sIsHighContrastOn = false;
|
||||||
|
|
||||||
// static
|
|
||||||
LookAndFeel::WindowsTheme nsUXThemeData::GetNativeThemeId() { return sThemeId; }
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool nsUXThemeData::IsDefaultWindowTheme() { return sIsDefaultWindowsTheme; }
|
bool nsUXThemeData::IsDefaultWindowTheme() { return sIsDefaultWindowsTheme; }
|
||||||
|
|
||||||
|
@ -300,7 +303,7 @@ void nsUXThemeData::UpdateNativeThemeInfo() {
|
||||||
sTitlebarInfoPopulatedThemed = false;
|
sTitlebarInfoPopulatedThemed = false;
|
||||||
|
|
||||||
sIsDefaultWindowsTheme = false;
|
sIsDefaultWindowsTheme = false;
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Generic;
|
sThemeId = WindowsTheme::Generic;
|
||||||
|
|
||||||
HIGHCONTRAST highContrastInfo;
|
HIGHCONTRAST highContrastInfo;
|
||||||
highContrastInfo.cbSize = sizeof(HIGHCONTRAST);
|
highContrastInfo.cbSize = sizeof(HIGHCONTRAST);
|
||||||
|
@ -311,7 +314,7 @@ void nsUXThemeData::UpdateNativeThemeInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nsUXThemeData::IsAppThemed()) {
|
if (!nsUXThemeData::IsAppThemed()) {
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Classic;
|
sThemeId = WindowsTheme::Classic;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,77 +322,34 @@ void nsUXThemeData::UpdateNativeThemeInfo() {
|
||||||
WCHAR themeColor[MAX_PATH + 1];
|
WCHAR themeColor[MAX_PATH + 1];
|
||||||
if (FAILED(GetCurrentThemeName(themeFileName, MAX_PATH, themeColor, MAX_PATH,
|
if (FAILED(GetCurrentThemeName(themeFileName, MAX_PATH, themeColor, MAX_PATH,
|
||||||
nullptr, 0))) {
|
nullptr, 0))) {
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Classic;
|
sThemeId = WindowsTheme::Classic;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPCWSTR themeName = wcsrchr(themeFileName, L'\\');
|
LPCWSTR themeName = wcsrchr(themeFileName, L'\\');
|
||||||
themeName = themeName ? themeName + 1 : themeFileName;
|
themeName = themeName ? themeName + 1 : themeFileName;
|
||||||
|
|
||||||
WindowsTheme theme = WINTHEME_UNRECOGNIZED;
|
sThemeId = [&] {
|
||||||
for (size_t i = 0; i < ArrayLength(knownThemes); ++i) {
|
for (const auto& theme : kKnownThemes) {
|
||||||
if (!lstrcmpiW(themeName, knownThemes[i].name)) {
|
if (!lstrcmpiW(themeName, theme.name)) {
|
||||||
theme = (WindowsTheme)knownThemes[i].type;
|
return theme.type;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return WindowsTheme::Generic;
|
||||||
if (theme == WINTHEME_UNRECOGNIZED) return;
|
}();
|
||||||
|
|
||||||
// We're using the default theme if we're using any of Aero, Aero Lite, or
|
// We're using the default theme if we're using any of Aero, Aero Lite, or
|
||||||
// luna. However, on Win8, GetCurrentThemeName (see above) returns
|
// luna. However, on Win8, GetCurrentThemeName (see above) returns
|
||||||
// AeroLite.msstyles for the 4 builtin highcontrast themes as well. Those
|
// AeroLite.msstyles for the 4 builtin highcontrast themes as well. Those
|
||||||
// themes "don't count" as default themes, so we specifically check for high
|
// themes "don't count" as default themes, so we specifically check for high
|
||||||
// contrast mode in that situation.
|
// contrast mode in that situation.
|
||||||
if (!(IsWin8OrLater() && sIsHighContrastOn) &&
|
sIsDefaultWindowsTheme = [&] {
|
||||||
(theme == WINTHEME_AERO || theme == WINTHEME_AERO_LITE ||
|
if (sIsHighContrastOn && IsWin8OrLater()) {
|
||||||
theme == WINTHEME_LUNA)) {
|
return false;
|
||||||
sIsDefaultWindowsTheme = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theme != WINTHEME_LUNA) {
|
|
||||||
switch (theme) {
|
|
||||||
case WINTHEME_AERO:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Aero;
|
|
||||||
return;
|
|
||||||
case WINTHEME_AERO_LITE:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_AeroLite;
|
|
||||||
return;
|
|
||||||
case WINTHEME_ZUNE:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Zune;
|
|
||||||
return;
|
|
||||||
case WINTHEME_ROYALE:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_Royale;
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
NS_WARNING("unhandled theme type.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate the luna color scheme
|
|
||||||
WindowsThemeColor color = WINTHEMECOLOR_UNRECOGNIZED;
|
|
||||||
for (size_t i = 0; i < ArrayLength(knownColors); ++i) {
|
|
||||||
if (!lstrcmpiW(themeColor, knownColors[i].name)) {
|
|
||||||
color = (WindowsThemeColor)knownColors[i].type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (color) {
|
|
||||||
case WINTHEMECOLOR_NORMAL:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_LunaBlue;
|
|
||||||
return;
|
|
||||||
case WINTHEMECOLOR_HOMESTEAD:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_LunaOlive;
|
|
||||||
return;
|
|
||||||
case WINTHEMECOLOR_METALLIC:
|
|
||||||
sThemeId = LookAndFeel::eWindowsTheme_LunaSilver;
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
NS_WARNING("unhandled theme color.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return sThemeId == WindowsTheme::Aero ||
|
||||||
|
sThemeId == WindowsTheme::AeroLite || sThemeId == WindowsTheme::Luna;
|
||||||
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -41,22 +41,6 @@ enum nsUXThemeClass {
|
||||||
eUXNumClasses
|
eUXNumClasses
|
||||||
};
|
};
|
||||||
|
|
||||||
// Native windows style constants
|
|
||||||
enum WindowsTheme {
|
|
||||||
WINTHEME_UNRECOGNIZED = 0,
|
|
||||||
WINTHEME_CLASSIC = 1, // no theme
|
|
||||||
WINTHEME_AERO = 2,
|
|
||||||
WINTHEME_LUNA = 3,
|
|
||||||
WINTHEME_ROYALE = 4,
|
|
||||||
WINTHEME_ZUNE = 5,
|
|
||||||
WINTHEME_AERO_LITE = 6
|
|
||||||
};
|
|
||||||
enum WindowsThemeColor {
|
|
||||||
WINTHEMECOLOR_UNRECOGNIZED = 0,
|
|
||||||
WINTHEMECOLOR_NORMAL = 1,
|
|
||||||
WINTHEMECOLOR_HOMESTEAD = 2,
|
|
||||||
WINTHEMECOLOR_METALLIC = 3
|
|
||||||
};
|
|
||||||
enum CmdButtonIdx {
|
enum CmdButtonIdx {
|
||||||
CMDBUTTONIDX_MINIMIZE = 0,
|
CMDBUTTONIDX_MINIMIZE = 0,
|
||||||
CMDBUTTONIDX_RESTORE,
|
CMDBUTTONIDX_RESTORE,
|
||||||
|
@ -103,7 +87,6 @@ class nsUXThemeData {
|
||||||
public:
|
public:
|
||||||
static bool sTitlebarInfoPopulatedAero;
|
static bool sTitlebarInfoPopulatedAero;
|
||||||
static bool sTitlebarInfoPopulatedThemed;
|
static bool sTitlebarInfoPopulatedThemed;
|
||||||
static mozilla::LookAndFeel::WindowsTheme sThemeId;
|
|
||||||
static bool sIsDefaultWindowsTheme;
|
static bool sIsDefaultWindowsTheme;
|
||||||
static bool sIsHighContrastOn;
|
static bool sIsHighContrastOn;
|
||||||
|
|
||||||
|
@ -123,7 +106,6 @@ class nsUXThemeData {
|
||||||
return sCommandButtonBoxMetrics;
|
return sCommandButtonBoxMetrics;
|
||||||
}
|
}
|
||||||
static void UpdateNativeThemeInfo();
|
static void UpdateNativeThemeInfo();
|
||||||
static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId();
|
|
||||||
static bool IsDefaultWindowTheme();
|
static bool IsDefaultWindowTheme();
|
||||||
static bool IsHighContrastOn();
|
static bool IsHighContrastOn();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче