[Win] Scrollbars buttons have incorrect size in HiDPI.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Mar 2017 20:25:40 +0000 (20:25 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Mar 2017 20:25:40 +0000 (20:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169463

Reviewed by Alex Christensen.

There seems to be a bug in DrawThemeBackground when the device context is scaled.
We can work around this by scaling the drawing rectangle instead.

* platform/win/ScrollbarThemeWin.cpp:
(WebCore::ScrollbarThemeWin::paintButton):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213727 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/win/ScrollbarThemeWin.cpp

index b2fd2b7..5f0b2c0 100644 (file)
@@ -1,3 +1,16 @@
+2017-03-10  Per Arne Vollan  <pvollan@apple.com>
+
+        [Win] Scrollbars buttons have incorrect size in HiDPI.
+        https://bugs.webkit.org/show_bug.cgi?id=169463
+
+        Reviewed by Alex Christensen.
+
+        There seems to be a bug in DrawThemeBackground when the device context is scaled.
+        We can work around this by scaling the drawing rectangle instead.
+        * platform/win/ScrollbarThemeWin.cpp:
+        (WebCore::ScrollbarThemeWin::paintButton):
+
 2017-03-10  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Oprhan lines with visual overflow does not work properly.
index 5a70de5..550372f 100644 (file)
@@ -331,15 +331,26 @@ void ScrollbarThemeWin::paintButton(GraphicsContext& context, Scrollbar& scrollb
     if (scrollbarTheme)
         alphaBlend = IsThemeBackgroundPartiallyTransparent(scrollbarTheme, SP_BUTTON, xpState);
 
-    LocalWindowsContext windowsContext(context, rect, alphaBlend);
-    RECT themeRect(rect);
-    if (scrollbarTheme)
-        DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), SP_BUTTON, xpState, &themeRect, 0);
-    else
-        ::DrawFrameControl(windowsContext.hdc(), &themeRect, DFC_SCROLL, classicState);
-
-    if (!alphaBlend && !context.isInTransparencyLayer())
-        DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), rect, 255);
+    // There seems to be a bug in DrawThemeBackground when the device context is scaled.
+    // We can work around this by scaling the drawing rectangle instead.
+    auto scaleFactor = context.scaleFactor().width();
+    auto scaledRect = rect;
+    scaledRect.scale(scaleFactor);
+    context.save();
+    context.scale(FloatSize(1.0f / scaleFactor, 1.0f / scaleFactor));
+
+    {
+        LocalWindowsContext windowsContext(context, scaledRect, alphaBlend);
+        RECT themeRect(scaledRect);
+        if (scrollbarTheme)
+            DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), SP_BUTTON, xpState, &themeRect, 0);
+        else
+            ::DrawFrameControl(windowsContext.hdc(), &themeRect, DFC_SCROLL, classicState);
+
+        if (!alphaBlend && !context.isInTransparencyLayer())
+            DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), scaledRect, 255);
+    }
+    context.restore();
 }
 
 static IntRect gripperRect(int thickness, const IntRect& thumbRect)