Bug 925599 - Replace WinUtils::GetWindowsVersion() and GetWindowsServicePackVersion(). r=jimm

This commit is contained in:
Masatoshi Kimura 2013-11-22 12:35:42 +09:00
Родитель ad49423ee9
Коммит ed579a7fd3
18 изменённых файлов: 115 добавлений и 158 удалений

Просмотреть файл

@ -8,9 +8,7 @@
#include "DirectShowReader.h"
#include "MediaDecoderStateMachine.h"
#include "mozilla/Preferences.h"
#include "WinUtils.h"
using namespace mozilla::widget;
#include "mozilla/WindowsVersion.h"
namespace mozilla {
@ -47,8 +45,8 @@ DirectShowDecoder::GetSupportedCodecs(const nsACString& aType,
bool
DirectShowDecoder::IsEnabled()
{
return (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) &&
Preferences::GetBool("media.directshow.enabled");
return !IsVistaOrLater() &&
Preferences::GetBool("media.directshow.enabled");
}
DirectShowDecoder::DirectShowDecoder()

Просмотреть файл

@ -10,8 +10,7 @@
#include "mozilla/Preferences.h"
#ifdef XP_WIN
#include "WinUtils.h"
using namespace mozilla::widget;
#include "mozilla/WindowsVersion.h"
#endif
namespace mozilla {
@ -72,7 +71,7 @@ HavePlatformMPEGDecoders()
Preferences::GetBool("media.fragmented-mp4.use-blank-decoder") ||
#ifdef XP_WIN
// We have H.264/AAC platform decoders on Windows Vista and up.
WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ||
IsVistaOrLater() ||
#endif
// TODO: Other platforms...
false;

Просмотреть файл

@ -11,7 +11,6 @@
#include "VideoUtils.h"
#include "DXVA2Manager.h"
#include "nsThreadUtils.h"
#include "WinUtils.h"
#include "Layers.h"
#include "mozilla/layers/LayersTypes.h"
#include "prlog.h"
@ -35,7 +34,6 @@ WMFVideoDecoder::WMFVideoDecoder(bool aDXVAEnabled)
mVideoHeight(0),
mLastStreamOffset(0),
mDXVAEnabled(aDXVAEnabled),
mIsRunningOnVista(widget::WinUtils::GetWindowsVersion() == widget::WinUtils::WIN7_VERSION),
mUseHwAccel(false)
{
NS_ASSERTION(!NS_IsMainThread(), "Must be on main thread.");

Просмотреть файл

@ -68,7 +68,6 @@ private:
nsAutoPtr<DXVA2Manager> mDXVA2Manager;
const bool mDXVAEnabled;
const bool mIsRunningOnVista;
bool mUseHwAccel;
};

Просмотреть файл

@ -10,15 +10,13 @@
#include "WMFUtils.h"
#include "MediaDecoderStateMachine.h"
#include "mozilla/Preferences.h"
#include "WinUtils.h"
#include "mozilla/WindowsVersion.h"
#include "nsCharSeparatedTokenizer.h"
#ifdef MOZ_DIRECTSHOW
#include "DirectShowDecoder.h"
#endif
using namespace mozilla::widget;
namespace mozilla {
MediaDecoderStateMachine* WMFDecoder::CreateStateMachine()
@ -38,21 +36,15 @@ WMFDecoder::IsMP3Supported()
return false;
}
#endif
if (!MediaDecoder::IsWMFEnabled()) {
if (!MediaDecoder::IsWMFEnabled()) {
return false;
}
if (WinUtils::GetWindowsVersion() != WinUtils::WIN7_VERSION) {
if (!IsWin7OrLater()) {
return true;
}
// We're on Windows 7. MP3 support is disabled if no service pack
// MP3 support is disabled if we're on Windows 7 and no service pack
// is installed, as it's crashy on Win7 SP0.
UINT spMajorVer = 0, spMinorVer = 0;
if (!WinUtils::GetWindowsServicePackVersion(spMajorVer, spMinorVer)) {
// Um... We can't determine the service pack version... Just block
// MP3 as a precaution...
return false;
}
return spMajorVer != 0;
return IsWin7SP1OrLater();
}
static bool
@ -163,7 +155,7 @@ bool
WMFDecoder::IsEnabled()
{
// We only use WMF on Windows Vista and up
return WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
return IsVistaOrLater() &&
Preferences::GetBool("media.windows-media-foundation.enabled");
}

Просмотреть файл

@ -7,15 +7,13 @@
#include "WMFUtils.h"
#include <stdint.h>
#include "mozilla/RefPtr.h"
#include "mozilla/WindowsVersion.h"
#include "prlog.h"
#include "nsThreadUtils.h"
#include "WinUtils.h"
#include "nsWindowsHelpers.h"
#include "mozilla/CheckedInt.h"
#include "VideoUtils.h"
using namespace mozilla::widget;
#ifdef WMF_MUST_DEFINE_AAC_MFT_CLSID
// Some SDK versions don't define the AAC decoder CLSID.
// {32D186A7-218F-4C75-8876-DD77273A8999}
@ -510,7 +508,7 @@ MFStartup()
DECL_FUNCTION_PTR(MFStartup, ULONG, DWORD);
ENSURE_FUNCTION_PTR(MFStartup, Mfplat.dll)
if (WinUtils::GetWindowsVersion() == WinUtils::VISTA_VERSION)
if (!IsWin7OrLater())
return MFStartupPtr(MF_VISTA_VERSION, MFSTARTUP_FULL);
else
return MFStartupPtr(MF_WIN7_VERSION, MFSTARTUP_FULL);

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/Util.h"
#include "mozilla/WindowsVersion.h"
#include "KeyboardLayout.h"
#include "nsIMM32Handler.h"
@ -581,7 +582,7 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
// On WinXP and WinServer2003, we cannot compute the virtual keycode for
// extended keys due to the API limitation.
bool canComputeVirtualKeyCodeFromScanCode =
(!mIsExtended || WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION);
(!mIsExtended || IsVistaOrLater());
switch (mMsg.message) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
@ -809,8 +810,7 @@ NativeKey::GetScanCodeWithExtendedFlag() const
// a virtual keycode, we need to add 0xE000 to the scancode.
// On Win XP and Win Server 2003, this doesn't support. On them, we have
// no way to get virtual keycodes from scancode of extended keys.
if (!mIsExtended ||
WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!mIsExtended || !IsVistaOrLater()) {
return mScanCode;
}
return (0xE000 | mScanCode);
@ -892,11 +892,9 @@ NativeKey::ComputeVirtualKeyCodeFromScanCode() const
uint8_t
NativeKey::ComputeVirtualKeyCodeFromScanCodeEx() const
{
bool VistaOrLater =
(WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION);
// NOTE: WinXP doesn't support mapping scan code to virtual keycode of
// extended keys.
NS_ENSURE_TRUE(!mIsExtended || VistaOrLater, 0);
NS_ENSURE_TRUE(!mIsExtended || IsVistaOrLater(), 0);
return static_cast<uint8_t>(
::MapVirtualKeyEx(GetScanCodeWithExtendedFlag(), MAPVK_VSC_TO_VK_EX,
mKeyboardLayout));

Просмотреть файл

@ -23,6 +23,7 @@
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/WindowsVersion.h"
#include <psapi.h>
@ -948,7 +949,7 @@ MouseScrollHandler::SystemSettings::Init()
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
("MouseScroll::SystemSettings::Init(): ::SystemParametersInfo("
"SPI_GETWHEELSCROLLCHARS) failed, %s",
WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
IsVistaOrLater() ?
"this is unexpected on Vista or later" :
"but on XP or earlier, this is not a problem"));
mScrollChars = 1;

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsPIDOMWindow.h"
#include "nsAppDirectoryServiceDefs.h"
#include "mozilla/Preferences.h"
#include "mozilla/WindowsVersion.h"
#include <io.h>
#include <propvarutil.h>
#include <propkey.h>
@ -330,7 +331,7 @@ WinTaskbar::GetDefaultGroupId(nsAString & aDefaultGroupId) {
// (static) Called from AppShell
bool
WinTaskbar::RegisterAppUserModelID() {
if (WinUtils::GetWindowsVersion() < WinUtils::WIN7_VERSION)
if (!IsWin7OrLater())
return false;
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
@ -365,9 +366,7 @@ WinTaskbar::RegisterAppUserModelID() {
NS_IMETHODIMP
WinTaskbar::GetAvailable(bool *aAvailable) {
*aAvailable =
WinUtils::GetWindowsVersion() < WinUtils::WIN7_VERSION ?
false : true;
*aAvailable = IsWin7OrLater();
return NS_OK;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "KeyboardLayout.h"
#include "nsIDOMMouseEvent.h"
#include "mozilla/Preferences.h"
#include "mozilla/WindowsVersion.h"
#ifdef MOZ_LOGGING
#define FORCE_PR_LOG /* Allow logging in the release build */
@ -89,7 +90,7 @@ WinUtils::Initialize()
gWindowsLog = PR_NewLogModule("Widget");
}
#endif
if (!sDwmDll && WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (!sDwmDll && IsVistaOrLater()) {
sDwmDll = ::LoadLibraryW(kDwmLibraryName);
if (sDwmDll) {
@ -106,42 +107,6 @@ WinUtils::Initialize()
}
}
/* static */
WinUtils::WinVersion
WinUtils::GetWindowsVersion()
{
static int32_t version = 0;
if (version) {
return static_cast<WinVersion>(version);
}
OSVERSIONINFOEX osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
// This cast is safe and supposed to be here, don't worry
::GetVersionEx((OSVERSIONINFO*)&osInfo);
version =
(osInfo.dwMajorVersion & 0xff) << 8 | (osInfo.dwMinorVersion & 0xff);
return static_cast<WinVersion>(version);
}
/* static */
bool
WinUtils::GetWindowsServicePackVersion(UINT& aOutMajor, UINT& aOutMinor)
{
OSVERSIONINFOEX osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
// This cast is safe and supposed to be here, don't worry
if (!::GetVersionEx((OSVERSIONINFO*)&osInfo)) {
return false;
}
aOutMajor = osInfo.wServicePackMajor;
aOutMinor = osInfo.wServicePackMinor;
return true;
}
// static
void
WinUtils::LogW(const wchar_t *fmt, ...)

Просмотреть файл

@ -69,20 +69,6 @@ public:
class WinUtils {
public:
enum WinVersion {
WINXP_VERSION = 0x501,
WIN2K3_VERSION = 0x502,
VISTA_VERSION = 0x600,
WIN7_VERSION = 0x601,
WIN8_VERSION = 0x602,
WIN8_1_VERSION = 0x603
};
static WinVersion GetWindowsVersion();
// Retrieves the Service Pack version number.
// Returns true on success, false on failure.
static bool GetWindowsServicePackVersion(UINT& aOutMajor, UINT& aOutMinor);
/**
* Logging helpers that dump output to prlog module 'Widget', console, and
* OutputDebugString. Note these output in both debug and release builds.

Просмотреть файл

@ -32,6 +32,7 @@
#include "WinUtils.h"
#include "mozilla/LazyIdleThread.h"
#include "mozilla/WindowsVersion.h"
#include <algorithm>
@ -1115,7 +1116,7 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG )
int totalLen;
nsCString path;
if (!Preferences::GetBool(kShellIconPref, true) ||
WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
!IsVistaOrLater()) {
shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n";
const int formatLen = strlen(shortcutFormatStr) - 2; // don't include %s
totalLen = formatLen + asciiUrl.Length(); // don't include null character

Просмотреть файл

@ -10,6 +10,7 @@
#include <shlwapi.h>
#include <cderr.h>
#include "mozilla/WindowsVersion.h"
#include "nsReadableUtils.h"
#include "nsNetUtil.h"
#include "nsWindow.h"
@ -26,6 +27,7 @@
#include "WinUtils.h"
#include "nsPIDOMWindow.h"
using mozilla::IsVistaOrLater;
using namespace mozilla::widget;
PRUnichar *nsFilePicker::mLastUsedUnicodeDirectory;
@ -689,7 +691,7 @@ nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
// a hook procedure. The hook procedure fixes a problem on XP dialogs for
// file picker visibility. Vista and up automatically ensures the file
// picker is always visible.
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!IsVistaOrLater()) {
ofn.lpfnHook = FilePickerHook;
ofn.Flags |= OFN_ENABLEHOOK;
}
@ -748,7 +750,7 @@ nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
// the file picker to use the old style dialogs because hooks are not
// allowed in the new file picker UI. We need to eventually move to
// the new Common File Dialogs for Vista and up.
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!IsVistaOrLater()) {
ofn.lpfnHook = MultiFilePickerHook;
fileBuffer.forget();
result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN);
@ -1047,12 +1049,12 @@ nsFilePicker::ShowW(int16_t *aReturnVal)
// properties.
bool result = false, wasInitError = true;
if (mMode == modeGetFolder) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)
if (IsVistaOrLater())
result = ShowFolderPicker(initialDir, wasInitError);
if (!result && wasInitError)
result = ShowXPFolderPicker(initialDir);
} else {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)
if (IsVistaOrLater())
result = ShowFilePicker(initialDir, wasInitError);
if (!result && wasInitError)
result = ShowXPFilePicker(initialDir);
@ -1244,7 +1246,7 @@ nsFilePicker::AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter)
NS_IMETHODIMP
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
{
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
mComFilterList.Append(aTitle, aFilter);
} else {
AppendXPFilter(aTitle, aFilter);

Просмотреть файл

@ -11,12 +11,41 @@
#include "nsUXThemeConstants.h"
#include "gfxFont.h"
#include "gfxWindowsPlatform.h"
#include "WinUtils.h"
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsVersion.h"
#include "gfxFontConstants.h"
using namespace mozilla;
using namespace mozilla::widget;
using mozilla::LookAndFeel;
enum WinVersion {
WINXP_VERSION = 0x501,
WIN2K3_VERSION = 0x502,
VISTA_VERSION = 0x600,
WIN7_VERSION = 0x601,
WIN8_VERSION = 0x602,
WIN8_1_VERSION = 0x603
};
static WinVersion GetWindowsVersion()
{
static int32_t version = 0;
if (version) {
return static_cast<WinVersion>(version);
}
OSVERSIONINFOEX osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
// This cast is safe and supposed to be here, don't worry
#pragma warning(push)
#pragma warning(disable:4996)
::GetVersionEx((OSVERSIONINFO*)&osInfo);
#pragma warning(pop)
version =
(osInfo.dwMajorVersion & 0xff) << 8 | (osInfo.dwMinorVersion & 0xff);
return static_cast<WinVersion>(version);
}
static nsresult GetColorFromTheme(nsUXThemeClass cls,
int32_t aPart,
@ -168,8 +197,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_HIGHLIGHT;
break;
case eColorID__moz_menubarhovertext:
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ||
!IsAppThemed())
if (!IsVistaOrLater() || !IsAppThemed())
{
idx = nsUXThemeData::sFlatMenus ?
COLOR_HIGHLIGHTTEXT :
@ -178,8 +206,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
}
// Fall through
case eColorID__moz_menuhovertext:
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed())
if (IsVistaOrLater() && IsAppThemed())
{
res = ::GetColorFromTheme(eUXMenu,
MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor);
@ -255,8 +282,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_3DFACE;
break;
case eColorID__moz_win_mediatext:
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed()) {
if (IsVistaOrLater() && IsAppThemed()) {
res = ::GetColorFromTheme(eUXMediaToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@ -266,8 +292,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_WINDOWTEXT;
break;
case eColorID__moz_win_communicationstext:
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed())
if (IsVistaOrLater() && IsAppThemed())
{
res = ::GetColorFromTheme(eUXCommunicationsToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
@ -392,18 +417,18 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
case eIntID_OperatingSystemVersionIdentifier:
{
switch(WinUtils::GetWindowsVersion()) {
case WinUtils::WINXP_VERSION:
case WinUtils::WIN2K3_VERSION:
switch (GetWindowsVersion()) {
case WINXP_VERSION:
case WIN2K3_VERSION:
aResult = LookAndFeel::eOperatingSystemVersion_WindowsXP;
break;
case WinUtils::VISTA_VERSION:
case VISTA_VERSION:
aResult = LookAndFeel::eOperatingSystemVersion_WindowsVista;
break;
case WinUtils::WIN7_VERSION:
case WIN7_VERSION:
aResult = LookAndFeel::eOperatingSystemVersion_Windows7;
break;
case WinUtils::WIN8_VERSION:
case WIN8_VERSION:
aResult = LookAndFeel::eOperatingSystemVersion_Windows8;
break;
default:
@ -423,8 +448,7 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
break;
case eIntID_WindowsGlass:
// Aero Glass is only available prior to Windows 8 when DWM is used.
aResult = (nsUXThemeData::CheckForCompositor() &&
WinUtils::GetWindowsVersion() < WinUtils::WIN8_VERSION);
aResult = (nsUXThemeData::CheckForCompositor() && !IsWin8OrLater());
break;
case eIntID_AlertNotificationOrigin:
aResult = 0;

Просмотреть файл

@ -3,8 +3,8 @@
* 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/. */
#include <windows.h>
#include "nsNativeThemeWin.h"
#include "mozilla/WindowsVersion.h"
#include "nsRenderingContext.h"
#include "nsRect.h"
#include "nsSize.h"
@ -24,7 +24,6 @@
#include "nsWindow.h"
#include "nsIComboboxControlFrame.h"
#include "prinrval.h"
#include "WinUtils.h"
#include "gfxPlatform.h"
#include "gfxContext.h"
@ -37,7 +36,7 @@
#include "nsUXThemeConstants.h"
#include <algorithm>
using namespace mozilla::widget;
using mozilla::IsVistaOrLater;
#ifdef PR_LOGGING
extern PRLogModuleInfo* gWindowsLog;
@ -350,7 +349,7 @@ AddPaddingRect(nsIntSize* aSize, CaptionButton button) {
RECT offset;
if (!IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
else if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION)
else if (!IsVistaOrLater())
offset = buttonData[CAPTION_XPTHEME].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];
@ -365,7 +364,7 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) {
RECT offset;
if (!IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
else if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION)
else if (!IsVistaOrLater())
offset = buttonData[CAPTION_XPTHEME].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];
@ -429,12 +428,12 @@ static int32_t
GetProgressOverlayStyle(bool aIsVertical)
{
if (aIsVertical) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
return PP_MOVEOVERLAYVERT;
}
return PP_CHUNKVERT;
} else {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
return PP_MOVEOVERLAY;
}
return PP_CHUNK;
@ -449,7 +448,7 @@ GetProgressOverlayStyle(bool aIsVertical)
static int32_t
GetProgressOverlaySize(bool aIsVertical, bool aIsIndeterminate)
{
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
if (aIsVertical) {
return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize
: kProgressVerticalOverlaySize;
@ -657,7 +656,7 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
RECT adjWidgetRect, adjClipRect;
adjWidgetRect = *aWidgetRect;
adjClipRect = *aClipRect;
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!IsVistaOrLater()) {
// Adjust clipping out by one pixel. XP progress meters are inset,
// Vista+ are not.
InflateRect(&adjWidgetRect, 1, 1);
@ -677,7 +676,7 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates);
bool animate = indeterminate;
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
// Vista and up progress meter is fill style, rendered here. We render
// the pulse overlay in the follow up section below.
DrawThemeBackground(aTheme, aHdc, aPart, aState,
@ -698,7 +697,7 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
RECT overlayRect =
CalculateProgressOverlayRect(aFrame, &adjWidgetRect, vertical,
indeterminate, false);
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect,
&adjClipRect);
} else {
@ -716,7 +715,7 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
HANDLE
nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
{
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!IsVistaOrLater()) {
// On XP or earlier, render dropdowns as textfields;
// doing it the right way works fine with the MS themes,
// but breaks on a lot of custom themes (presumably because MS
@ -736,7 +735,7 @@ nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
return nsUXThemeData::GetTheme(eUXEdit);
case NS_THEME_TOOLTIP:
// XP/2K3 should force a classic treatment of tooltips
return WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ?
return !IsVistaOrLater() ?
nullptr : nsUXThemeData::GetTheme(eUXTooltip);
case NS_THEME_TOOLBOX:
return nsUXThemeData::GetTheme(eUXRebar);
@ -864,7 +863,7 @@ nsresult
nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
int32_t& aPart, int32_t& aState)
{
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
if (!IsVistaOrLater()) {
// See GetTheme
if (aWidgetType == NS_THEME_DROPDOWN)
aWidgetType = NS_THEME_TEXTFIELD;
@ -941,7 +940,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
case NS_THEME_TEXTFIELD_MULTILINE: {
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
/* Note: the NOSCROLL type has a rounded corner in each
* corner. The more specific HSCROLL, VSCROLL, HVSCROLL types
* have side and/or top/bottom edges rendered as straight
@ -1011,10 +1010,10 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
nsEventStates eventStates = GetContentState(parentFrame, aWidgetType);
if (aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
IsVerticalProgress(parentFrame)) {
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
aPart = IsVistaOrLater() ?
PP_FILLVERT : PP_CHUNKVERT;
} else {
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
aPart = IsVistaOrLater() ?
PP_FILL : PP_CHUNK;
}
@ -1078,7 +1077,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
aState += TS_ACTIVE;
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
aState += TS_HOVER;
else if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
else if (IsVistaOrLater() &&
parentState.HasState(NS_EVENT_STATE_HOVER))
aState = (aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE;
else
@ -1182,7 +1181,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_SMALL: {
aState = 0;
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
// On vista, they have a part
aPart = RP_BACKGROUND;
} else {
@ -1314,7 +1313,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
aFrame = parentFrame;
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
aPart = IsVistaOrLater() ?
CBP_DROPMARKER_VISTA : CBP_DROPMARKER;
// For HTML controls with author styling, we should fall
@ -1335,7 +1334,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
else
isOpen = IsOpenButton(aFrame);
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
if (isHTML || IsMenuListEditable(aFrame)) {
if (isOpen) {
/* Hover is propagated, but we need to know whether we're
@ -1838,7 +1837,7 @@ RENDER_AGAIN:
// On vista, choose our own colors and draw an XP style half focus rect
// for focused checkboxes and a full rect when active.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
if (IsVistaOrLater() &&
aWidgetType == NS_THEME_CHECKBOX) {
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
@ -2086,7 +2085,7 @@ nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext,
return true;
}
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
if (aWidgetType == NS_THEME_TEXTFIELD ||
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
aWidgetType == NS_THEME_DROPDOWN)
@ -2179,7 +2178,7 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext,
* a border only shows up if the widget is being hovered.
*/
#if 0
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
/* We explicitly draw dropdown buttons in HTML content 1px bigger
* up, right, and bottom so that they overlap the dropdown's border
* like they're supposed to.
@ -2303,7 +2302,7 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
*aIsOverridable = false;
// on Vista, GetThemePartAndState returns odd values for
// scale thumbs, so use a hardcoded size instead.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
if (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL ||
(aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) {
aResult->width = 12;
@ -2353,7 +2352,7 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cy;
// For XP, subtract 4 from system metrics dimensions.
if (WinUtils::GetWindowsVersion() == WinUtils::WINXP_VERSION) {
if (!IsVistaOrLater()) {
aResult->width -= 4;
aResult->height -= 4;
}
@ -2364,7 +2363,7 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cy;
if (WinUtils::GetWindowsVersion() == WinUtils::WINXP_VERSION) {
if (!IsVistaOrLater()) {
aResult->width -= 4;
aResult->height -= 4;
}
@ -2375,7 +2374,7 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
case NS_THEME_WINDOW_BUTTON_CLOSE:
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cy;
if (WinUtils::GetWindowsVersion() == WinUtils::WINXP_VERSION) {
if (!IsVistaOrLater()) {
aResult->width -= 4;
aResult->height -= 4;
}
@ -2488,7 +2487,7 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
}
// On Vista, the scrollbar buttons need to change state when the track has/doesn't have hover
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION &&
if (!IsVistaOrLater() &&
(aWidgetType == NS_THEME_SCROLLBAR_TRACK_VERTICAL ||
aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL)) {
*aShouldRepaint = false;
@ -2497,7 +2496,7 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
// We need to repaint the dropdown arrow in vista HTML combobox controls when
// the control is closed to get rid of the hover effect.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
if (IsVistaOrLater() &&
(aWidgetType == NS_THEME_DROPDOWN || aWidgetType == NS_THEME_DROPDOWN_BUTTON) &&
IsHTMLContent(aFrame))
{

Просмотреть файл

@ -20,6 +20,7 @@
#include "WinUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/TextEvents.h"
#include "mozilla/WindowsVersion.h"
#define INPUTSCOPE_INIT_GUID
#include "nsTextStore.h"
@ -3602,7 +3603,7 @@ nsTextStore::CurrentKeyboardLayoutHasIME()
// On Windows Vista or later, ImmIsIME() API always returns true.
// If we failed to obtain the profile manager, we cannot know if current
// keyboard layout has IME.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
PR_LOG(sTextStoreLog, PR_LOG_ERROR,
("TSF: nsTextStore::CurrentKeyboardLayoutHasIME() FAILED to query "
"ITfInputProcessorProfileMgr"));

Просмотреть файл

@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Util.h"
#include "mozilla/WindowsVersion.h"
#include "nsUXThemeData.h"
#include "nsDebug.h"
@ -144,7 +145,7 @@ nsUXThemeData::InitTitlebarInfo()
// Use system metrics for pre-vista, otherwise trigger a
// refresh on the next layout.
sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed =
(WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION);
!IsVistaOrLater();
}
// static
@ -281,8 +282,7 @@ void
nsUXThemeData::UpdateNativeThemeInfo()
{
// Trigger a refresh of themed button metrics if needed
sTitlebarInfoPopulatedThemed =
(WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION);
sTitlebarInfoPopulatedThemed = !IsVistaOrLater();
sIsDefaultWindowsTheme = false;
sThemeId = LookAndFeel::eWindowsTheme_Generic;

Просмотреть файл

@ -125,6 +125,7 @@
#include "nsIWidgetListener.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/WindowsVersion.h"
#ifdef MOZ_ENABLE_D3D9_LAYER
#include "LayerManagerD3D9.h"
@ -481,9 +482,7 @@ nsWindow::Create(nsIWidget *aParent,
parent = nullptr;
}
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
WinUtils::GetWindowsVersion() <= WinUtils::WIN7_VERSION &&
HasBogusPopupsDropShadowOnMultiMonitor()) {
if (IsVistaOrLater() && !IsWin8OrLater()) {
extendedStyle |= WS_EX_COMPOSITED;
}
@ -606,7 +605,7 @@ nsWindow::Create(nsIWidget *aParent,
// bugs over the years, disable it (sTrimOnMinimize=1) on Vista and up.
sTrimOnMinimize =
Preferences::GetBool("config.trim_on_minimize",
(WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)) ? 1 : 0;
IsVistaOrLater() ? 1 : 0);
sSwitchKeyboardLayout =
Preferences::GetBool("intl.keyboard.per_window_layout", false);
}
@ -1226,8 +1225,7 @@ bool nsWindow::IsVisible() const
// transparency. These routines are called on size and move operations.
void nsWindow::ClearThemeRegion()
{
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
!HasGlass() &&
if (IsVistaOrLater() && !HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
SetWindowRgn(mWnd, nullptr, false);
@ -1241,8 +1239,7 @@ void nsWindow::SetThemeRegion()
// so default constants are used for part and state. At some point we might need part and
// state values from nsNativeThemeWin's GetThemePartAndState, but currently windows that
// change shape based on state haven't come up.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
!HasGlass() &&
if (IsVistaOrLater() && !HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
HRGN hRgn = nullptr;
@ -3495,7 +3492,7 @@ nsWindow::OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
// Only Vista and later, Windows has the system setting of horizontal
// scrolling by the mouse wheel.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (IsVistaOrLater()) {
if (!::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &systemSpeed, 0)) {
return NS_ERROR_FAILURE;
}