Bug 429176: :-moz-system-metric(windows-default-theme) should treat Royale and Zune the same as Luna, patch by Kai Liu <kliu.bugzilla.3c9f@mail.kailiu.com>, r+sr=roc, a=beltzner

This commit is contained in:
gavin@gavinsharp.com 2008-04-22 09:54:51 -07:00
parent c3fcee47d2
commit dcc4a0e331

View File

@ -512,28 +512,30 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
WCHAR themeFileName[MAX_PATH + 1] = {L'\0'};
HRESULT hresult = getCurrentThemeName(themeFileName, MAX_PATH,
NULL, 0, NULL, 0);
if (hresult == S_OK) {
const WCHAR * defaultThemeName = NULL;
switch (GetWindowsVersion()) {
case WINXP_VERSION:
case WIN2K3_VERSION:
defaultThemeName = L"luna.msstyles";
break;
case VISTA_VERSION:
defaultThemeName = L"aero.msstyles";
break;
// WIN2K and earlier will not have getCurrentThemeName defined, so
// they will never make it this far. Unless we want to save 6.0
// users a handful of clock cycles by skipping checks for the
// 5.x themes (or vice-versa), we can use a single loop for all
// the different Windows versions.
if (hresult == S_OK && GetWindowsVersion() <= VISTA_VERSION) {
LPCWSTR defThemes[] = {
L"luna.msstyles",
L"royale.msstyles",
L"zune.msstyles",
L"aero.msstyles"
};
default:
res = NS_ERROR_NOT_IMPLEMENTED;
break;
}
const int pathLen = lstrlenW(themeFileName),
defaultLen = lstrlenW(defaultThemeName);
if (pathLen > defaultLen &&
!wcsicmp(themeFileName + pathLen - defaultLen, defaultThemeName)) {
aMetric = 1;
LPWSTR curTheme = wcsrchr(themeFileName, L'\\');
curTheme = curTheme ? curTheme + 1 : themeFileName;
for (int i = 0; i < NS_ARRAY_LENGTH(defThemes); ++i) {
if (!lstrcmpiW(curTheme, defThemes[i])) {
aMetric = 1;
}
}
} else {
res = NS_ERROR_NOT_IMPLEMENTED;
}
} else
#endif