Bug 719983 - Replace uses of nsUXThemeData::sIsVistaOrLater with WinUtils version routines. r=neil

This commit is contained in:
Jim Mathies 2012-02-08 10:00:47 -06:00
Родитель b40c031d6c
Коммит e5d8eb2fdb
5 изменённых файлов: 46 добавлений и 38 удалений

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

@ -46,6 +46,9 @@
#include "nsStyleConsts.h"
#include "nsUXThemeData.h"
#include "nsUXThemeConstants.h"
#include "WinUtils.h"
using namespace mozilla::widget;
static nsresult GetColorFromTheme(nsUXThemeClass cls,
PRInt32 aPart,
@ -183,8 +186,8 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_HIGHLIGHT;
break;
case eColorID__moz_menubarhovertext:
if (!nsUXThemeData::sIsVistaOrLater || !IsAppThemed())
{
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ||
!IsAppThemed()) {
idx = nsUXThemeData::sFlatMenus ?
COLOR_HIGHLIGHTTEXT :
COLOR_MENUTEXT;
@ -192,8 +195,8 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
}
// Fall through
case eColorID__moz_menuhovertext:
if (IsAppThemed() && nsUXThemeData::sIsVistaOrLater)
{
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed()) {
res = ::GetColorFromTheme(eUXMenu,
MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@ -268,7 +271,8 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_3DFACE;
break;
case eColorID__moz_win_mediatext:
if (IsAppThemed() && nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed()) {
res = ::GetColorFromTheme(eUXMediaToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@ -278,8 +282,8 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_WINDOWTEXT;
break;
case eColorID__moz_win_communicationstext:
if (IsAppThemed() && nsUXThemeData::sIsVistaOrLater)
{
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
IsAppThemed()) {
res = ::GetColorFromTheme(eUXCommunicationsToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))

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

@ -412,7 +412,7 @@ static void OffsetBackgroundRect(RECT& rect, CaptionButton button) {
HANDLE
nsNativeThemeWin::GetTheme(PRUint8 aWidgetType)
{
if (!nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
// 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
@ -431,8 +431,9 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidgetType)
case NS_THEME_TEXTFIELD_MULTILINE:
return nsUXThemeData::GetTheme(eUXEdit);
case NS_THEME_TOOLTIP:
// BUG #161600: XP/2K3 should force a classic treatment of tooltips
return nsUXThemeData::sIsVistaOrLater ? nsUXThemeData::GetTheme(eUXTooltip) : NULL;
// XP/2K3 should force a classic treatment of tooltips
return WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ?
NULL : nsUXThemeData::GetTheme(eUXTooltip);
case NS_THEME_TOOLBOX:
return nsUXThemeData::GetTheme(eUXRebar);
case NS_THEME_WIN_MEDIA_TOOLBOX:
@ -557,7 +558,7 @@ nsresult
nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
PRInt32& aPart, PRInt32& aState)
{
if (!nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION) {
// See GetTheme
if (aWidgetType == NS_THEME_DROPDOWN)
aWidgetType = NS_THEME_TEXTFIELD;
@ -634,7 +635,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
case NS_THEME_TEXTFIELD_MULTILINE: {
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
/* 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
@ -701,9 +702,11 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
// we have to return aPart = -1.
aPart = -1;
} else if (IsVerticalProgress(stateFrame)) {
aPart = nsUXThemeData::sIsVistaOrLater ? PP_FILLVERT : PP_CHUNKVERT;
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
PP_FILLVERT : PP_CHUNKVERT;
} else {
aPart = nsUXThemeData::sIsVistaOrLater ? PP_FILL : PP_CHUNK;
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
PP_FILL : PP_CHUNK;
}
aState = TS_NORMAL;
@ -776,7 +779,8 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
aState += TS_ACTIVE;
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
aState += TS_HOVER;
else if (nsUXThemeData::sIsVistaOrLater && parentState.HasState(NS_EVENT_STATE_HOVER))
else if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
parentState.HasState(NS_EVENT_STATE_HOVER))
aState = (aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE;
else
aState += TS_NORMAL;
@ -864,7 +868,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_SMALL: {
aState = 0;
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
// On vista, they have a part
aPart = RP_BACKGROUND;
} else {
@ -996,7 +1000,8 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
aFrame = parentFrame;
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
aPart = nsUXThemeData::sIsVistaOrLater ? CBP_DROPMARKER_VISTA : CBP_DROPMARKER;
aPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
CBP_DROPMARKER_VISTA : CBP_DROPMARKER;
// For HTML controls with author styling, we should fall
// back to the old dropmarker style to avoid clashes with
@ -1016,7 +1021,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
else
isOpen = IsOpenButton(aFrame);
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (isHTML || IsMenuListEditable(aFrame)) {
if (isOpen) {
/* Hover is propagated, but we need to know whether we're
@ -1484,7 +1489,8 @@ 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 (nsUXThemeData::sIsVistaOrLater && aWidgetType == NS_THEME_CHECKBOX) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
aWidgetType == NS_THEME_CHECKBOX) {
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = RGB(255,255,255);
@ -1593,7 +1599,8 @@ RENDER_AGAIN:
bool indeterminate = IsIndeterminateProgress(stateFrame, eventStates);
bool vertical = IsVerticalProgress(stateFrame);
if (indeterminate || nsUXThemeData::sIsVistaOrLater) {
if (indeterminate ||
WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 30)) {
NS_WARNING("unable to animate progress widget!");
}
@ -1605,7 +1612,7 @@ RENDER_AGAIN:
* indeterminate progress bars.
*/
PRInt32 overlaySize;
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (vertical) {
overlaySize = indeterminate ? kProgressVerticalIndeterminateOverlaySize
: kProgressVerticalOverlaySize;
@ -1649,13 +1656,14 @@ RENDER_AGAIN:
PRInt32 overlayPart;
if (vertical) {
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
overlayPart = indeterminate ? PP_MOVEOVERLAY : PP_MOVEOVERLAYVERT;
} else {
overlayPart = PP_CHUNKVERT;
}
} else {
overlayPart = nsUXThemeData::sIsVistaOrLater ? PP_MOVEOVERLAY : PP_CHUNK;
overlayPart = WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION ?
PP_MOVEOVERLAY : PP_CHUNK;
}
DrawThemeBackground(theme, hdc, overlayPart, state, &overlayRect,
@ -1817,7 +1825,7 @@ nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext,
return true;
}
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (aWidgetType == NS_THEME_TEXTFIELD ||
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
aWidgetType == NS_THEME_DROPDOWN)
@ -1910,7 +1918,7 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext,
* a border only shows up if the widget is being hovered.
*/
#if 0
if (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
/* 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.
@ -2033,7 +2041,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 (nsUXThemeData::sIsVistaOrLater) {
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL) {
aResult->width = 12;
aResult->height = 20;
@ -2208,7 +2216,7 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
}
// On Vista, the scrollbar buttons need to change state when the track has/doesn't have hover
if (!nsUXThemeData::sIsVistaOrLater &&
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION &&
(aWidgetType == NS_THEME_SCROLLBAR_TRACK_VERTICAL ||
aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL)) {
*aShouldRepaint = false;
@ -2217,7 +2225,7 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, PRUint8 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 (nsUXThemeData::sIsVistaOrLater &&
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
(aWidgetType == NS_THEME_DROPDOWN || aWidgetType == NS_THEME_DROPDOWN_BUTTON) &&
IsHTMLContent(aFrame))
{

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

@ -69,8 +69,6 @@ nsUXThemeData::sDwmDLL = NULL;
bool
nsUXThemeData::sFlatMenus = false;
bool
nsUXThemeData::sIsVistaOrLater = false;
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
@ -104,9 +102,6 @@ nsUXThemeData::Initialize()
::ZeroMemory(sThemes, sizeof(sThemes));
NS_ASSERTION(!sThemeDLL, "nsUXThemeData being initialized twice!");
WinUtils::WinVersion version = WinUtils::GetWindowsVersion();
sIsVistaOrLater = version >= WinUtils::VISTA_VERSION;
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
if (GetDwmDLL()) {
dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDLL, "DwmExtendFrameIntoClientArea");
@ -157,7 +152,7 @@ nsUXThemeData::GetThemeDLL() {
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
HMODULE
nsUXThemeData::GetDwmDLL() {
if (!sDwmDLL && sIsVistaOrLater)
if (!sDwmDLL && WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)
sDwmDLL = ::LoadLibraryW(kDwmLibraryName);
return sDwmDLL;
}

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

@ -128,7 +128,6 @@ public:
static const PRUnichar kDwmLibraryName[];
#endif
static bool sFlatMenus;
static bool sIsVistaOrLater;
static bool sTitlebarInfoPopulatedAero;
static bool sTitlebarInfoPopulatedThemed;
static SIZE sCommandButtons[4];

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

@ -1274,7 +1274,8 @@ NS_METHOD nsWindow::IsVisible(bool & bState)
// transparency. These routines are called on size and move operations.
void nsWindow::ClearThemeRegion()
{
if (nsUXThemeData::sIsVistaOrLater && !HasGlass() &&
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
SetWindowRgn(mWnd, NULL, false);
@ -1288,7 +1289,8 @@ 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 (nsUXThemeData::sIsVistaOrLater && !HasGlass() &&
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
HRGN hRgn = nsnull;
@ -6358,7 +6360,7 @@ nsWindow::InitMouseWheelScrollData()
if (!::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
&sMouseWheelScrollChars, 0)) {
NS_ASSERTION(!nsUXThemeData::sIsVistaOrLater,
NS_ASSERTION(WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION,
"Failed to get SPI_GETWHEELSCROLLCHARS");
sMouseWheelScrollChars = 1;
} else if (sMouseWheelScrollChars > WHEEL_DELTA) {