Changeset 213727 in webkit


Ignore:
Timestamp:
Mar 10, 2017 12:25:40 PM (7 years ago)
Author:
pvollan@apple.com
Message:

[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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r213723 r213727  
     12017-03-10  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Win] Scrollbars buttons have incorrect size in HiDPI.
     4        https://bugs.webkit.org/show_bug.cgi?id=169463
     5
     6        Reviewed by Alex Christensen.
     7
     8        There seems to be a bug in DrawThemeBackground when the device context is scaled.
     9        We can work around this by scaling the drawing rectangle instead.
     10 
     11        * platform/win/ScrollbarThemeWin.cpp:
     12        (WebCore::ScrollbarThemeWin::paintButton):
     13
    1142017-03-10  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp

    r196632 r213727  
    332332        alphaBlend = IsThemeBackgroundPartiallyTransparent(scrollbarTheme, SP_BUTTON, xpState);
    333333
    334     LocalWindowsContext windowsContext(context, rect, alphaBlend);
    335     RECT themeRect(rect);
    336     if (scrollbarTheme)
    337         DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), SP_BUTTON, xpState, &themeRect, 0);
    338     else
    339         ::DrawFrameControl(windowsContext.hdc(), &themeRect, DFC_SCROLL, classicState);
    340 
    341     if (!alphaBlend && !context.isInTransparencyLayer())
    342         DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), rect, 255);
     334    // There seems to be a bug in DrawThemeBackground when the device context is scaled.
     335    // We can work around this by scaling the drawing rectangle instead.
     336    auto scaleFactor = context.scaleFactor().width();
     337    auto scaledRect = rect;
     338    scaledRect.scale(scaleFactor);
     339    context.save();
     340    context.scale(FloatSize(1.0f / scaleFactor, 1.0f / scaleFactor));
     341
     342    {
     343        LocalWindowsContext windowsContext(context, scaledRect, alphaBlend);
     344        RECT themeRect(scaledRect);
     345        if (scrollbarTheme)
     346            DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), SP_BUTTON, xpState, &themeRect, 0);
     347        else
     348            ::DrawFrameControl(windowsContext.hdc(), &themeRect, DFC_SCROLL, classicState);
     349
     350        if (!alphaBlend && !context.isInTransparencyLayer())
     351            DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), scaledRect, 255);
     352    }
     353    context.restore();
    343354}
    344355
Note: See TracChangeset for help on using the changeset viewer.