summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authorcpu <cpu@chromium.org>2014-10-24 14:32:51 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-24 21:33:11 +0000
commit9ca0741945b03141056db969f87b163f2d9e138f (patch)
treef0b1ba0326892d1f5c6ea072efd8a05eb5d36152 /base/win
parent82e46120237bc023559ac7ebddb29e21b6530170 (diff)
downloadchromium_src-9ca0741945b03141056db969f87b163f2d9e138f.zip
chromium_src-9ca0741945b03141056db969f87b163f2d9e138f.tar.gz
chromium_src-9ca0741945b03141056db969f87b163f2d9e138f.tar.bz2
Use the Windows XP version of NONCLIENTMETRICS
We are not using the extra member that Vista+ defines. BUG=426573 Review URL: https://codereview.chromium.org/661883005 Cr-Commit-Position: refs/heads/master@{#301194}
Diffstat (limited to 'base/win')
-rw-r--r--base/win/win_util.cc19
-rw-r--r--base/win/win_util.h22
-rw-r--r--base/win/win_util_unittest.cc2
3 files changed, 29 insertions, 14 deletions
diff --git a/base/win/win_util.cc b/base/win/win_util.cc
index a53f30a..f46242d3 100644
--- a/base/win/win_util.cc
+++ b/base/win/win_util.cc
@@ -119,19 +119,14 @@ namespace win {
static bool g_crash_on_process_detach = false;
-#define NONCLIENTMETRICS_SIZE_PRE_VISTA \
- SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
-
-void GetNonClientMetrics(NONCLIENTMETRICS* metrics) {
+void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) {
DCHECK(metrics);
-
- static const UINT SIZEOF_NONCLIENTMETRICS =
- (base::win::GetVersion() >= base::win::VERSION_VISTA) ?
- sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA;
- metrics->cbSize = SIZEOF_NONCLIENTMETRICS;
- const bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
- SIZEOF_NONCLIENTMETRICS, metrics,
- 0);
+ metrics->cbSize = sizeof(*metrics);
+ const bool success = !!SystemParametersInfo(
+ SPI_GETNONCLIENTMETRICS,
+ metrics->cbSize,
+ reinterpret_cast<NONCLIENTMETRICS*>(metrics),
+ 0);
DCHECK(success);
}
diff --git a/base/win/win_util.h b/base/win/win_util.h
index 9439597..8513f62 100644
--- a/base/win/win_util.h
+++ b/base/win/win_util.h
@@ -33,10 +33,30 @@ struct IPropertyStore;
struct _tagpropertykey;
typedef _tagpropertykey PROPERTYKEY;
+// This is the same as NONCLIENTMETRICS except that the
+// unused member |iPaddedBorderWidth| has been removed.
+struct NONCLIENTMETRICS_XP {
+ UINT cbSize;
+ int iBorderWidth;
+ int iScrollWidth;
+ int iScrollHeight;
+ int iCaptionWidth;
+ int iCaptionHeight;
+ LOGFONTW lfCaptionFont;
+ int iSmCaptionWidth;
+ int iSmCaptionHeight;
+ LOGFONTW lfSmCaptionFont;
+ int iMenuWidth;
+ int iMenuHeight;
+ LOGFONTW lfMenuFont;
+ LOGFONTW lfStatusFont;
+ LOGFONTW lfMessageFont;
+};
+
namespace base {
namespace win {
-BASE_EXPORT void GetNonClientMetrics(NONCLIENTMETRICS* metrics);
+BASE_EXPORT void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics);
// Returns the string representing the current user sid.
BASE_EXPORT bool GetUserSidString(std::wstring* user_sid);
diff --git a/base/win/win_util_unittest.cc b/base/win/win_util_unittest.cc
index 11536a9..8300c16 100644
--- a/base/win/win_util_unittest.cc
+++ b/base/win/win_util_unittest.cc
@@ -47,7 +47,7 @@ TEST(BaseWinUtilTest, TestGetUserSidString) {
}
TEST(BaseWinUtilTest, TestGetNonClientMetrics) {
- NONCLIENTMETRICS metrics = {0};
+ NONCLIENTMETRICS_XP metrics = {0};
GetNonClientMetrics(&metrics);
EXPECT_TRUE(metrics.cbSize > 0);
EXPECT_TRUE(metrics.iScrollWidth > 0);