Bug 1316717 - Use the system DPI scaling factor to calculate the icon size in GetGutterSize. r=jfkthame

We have to use the system scale here for consistency because GetThemePartSize and GetThemeMargins will always assume the system scale and callers of GetGutterSize will adjust the size using GetThemeDpiScaleFactor.

This patch will also fix an existing bug where native-themed elements are not scaled when layout.css.devPixelsPerPx has a non-default value on Windows 7.

MozReview-Commit-ID: ILHiOrkTPoT

--HG--
extra : rebase_source : 130dd313ed478d1fe8a9b88ce2705df985c817c3
This commit is contained in:
Masatoshi Kimura 2017-04-09 10:00:08 +09:00
Родитель d1b78f3864
Коммит e4f7bfae30
1 изменённых файлов: 4 добавлений и 5 удалений

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

@ -194,10 +194,8 @@ GetGutterSize(HANDLE theme, HDC hdc)
GetThemePartSize(theme, hdc, MENU_POPUPITEM, MPI_NORMAL, nullptr, TS_TRUE, &itemSize);
// Figure out how big the menuitem's icon will be (if present) at current DPI
double scaleFactor = nsIWidget::DefaultScaleOverride();
if (scaleFactor <= 0.0) {
scaleFactor = WinUtils::LogToPhysFactor(hdc);
}
// Needs the system scale for consistency with Windows Theme API.
double scaleFactor = WinUtils::SystemScaleFactor();
int iconDevicePixels = NSToIntRound(16 * scaleFactor);
SIZE iconSize = {
iconDevicePixels, iconDevicePixels
@ -1375,7 +1373,8 @@ AssumeThemePartAndStateAreTransparent(int32_t aPart, int32_t aState)
static inline double
GetThemeDpiScaleFactor(nsIFrame* aFrame)
{
if (WinUtils::IsPerMonitorDPIAware()) {
if (WinUtils::IsPerMonitorDPIAware() ||
nsIWidget::DefaultScaleOverride() > 0.0) {
nsIWidget* rootWidget = aFrame->PresContext()->GetRootWidget();
if (rootWidget) {
double systemScale = WinUtils::SystemScaleFactor();