Changeset 222247 in webkit


Ignore:
Timestamp:
Sep 19, 2017 8:46:46 PM (7 years ago)
Author:
Simon Fraser
Message:

tiled-drawing/tiled-backing-in-window.html fails on Retina displays
https://bugs.webkit.org/show_bug.cgi?id=177113

Reviewed by Tim Horton.

Source/WebKit:

Make m_customDeviceScaleFactor a std::optional<> instead of having the weird "0 is unset"
behavior.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::deviceScaleFactor const):
(WebKit::WebPageProxy::setCustomDeviceScaleFactor):

  • UIProcess/WebPageProxy.h:

Tools:

This test removes the view from the window, and then dumps the layer tree, at which point
some layers would report a contentsScale of 2 on Retina displays.

This occurs because WebKitTestRunner overrides the default device scale factor on NSWindow,
but windowless views fall back to [NSScreen mainScreen].backingScaleFactor (in WebViewImpl::intrinsicDeviceScaleFactor()).

Fix by having PlatformWebView::changeWindowScaleIfNeeded() call -_setOverrideDeviceScaleFactor: on the view.

  • WebKitTestRunner/mac/PlatformWebViewMac.mm:

(WTR::PlatformWebView::changeWindowScaleIfNeeded):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r222233 r222247  
     12017-09-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        tiled-drawing/tiled-backing-in-window.html fails on Retina displays
     4        https://bugs.webkit.org/show_bug.cgi?id=177113
     5
     6        Reviewed by Tim Horton.
     7
     8        Make m_customDeviceScaleFactor a std::optional<> instead of having the weird "0 is unset"
     9        behavior.
     10
     11        * UIProcess/WebPageProxy.cpp:
     12        (WebKit::WebPageProxy::deviceScaleFactor const):
     13        (WebKit::WebPageProxy::setCustomDeviceScaleFactor):
     14        * UIProcess/WebPageProxy.h:
     15
    1162017-09-19  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r222183 r222247  
    25622562float WebPageProxy::deviceScaleFactor() const
    25632563{
    2564     if (m_customDeviceScaleFactor)
    2565         return m_customDeviceScaleFactor;
    2566     return m_intrinsicDeviceScaleFactor;
     2564    return m_customDeviceScaleFactor.value_or(m_intrinsicDeviceScaleFactor);
    25672565}
    25682566
     
    25782576#endif
    25792577
    2580     if (m_customDeviceScaleFactor == customScaleFactor)
     2578    if (m_customDeviceScaleFactor && m_customDeviceScaleFactor.value() == customScaleFactor)
    25812579        return;
    25822580
    25832581    float oldScaleFactor = deviceScaleFactor();
    25842582
    2585     m_customDeviceScaleFactor = customScaleFactor;
     2583    // A value of 0 clears the customScaleFactor.
     2584    if (customScaleFactor)
     2585        m_customDeviceScaleFactor = customScaleFactor;
     2586    else
     2587        m_customDeviceScaleFactor = std::nullopt;
    25862588
    25872589    if (deviceScaleFactor() != oldScaleFactor)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r222059 r222247  
    17571757    double m_viewScaleFactor { 1 };
    17581758    float m_intrinsicDeviceScaleFactor { 1 };
    1759     float m_customDeviceScaleFactor { 0 };
     1759    std::optional<float> m_customDeviceScaleFactor;
    17601760    float m_topContentInset { 0 };
    17611761
  • trunk/Tools/ChangeLog

    r222245 r222247  
     12017-09-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        tiled-drawing/tiled-backing-in-window.html fails on Retina displays
     4        https://bugs.webkit.org/show_bug.cgi?id=177113
     5
     6        Reviewed by Tim Horton.
     7
     8        This test removes the view from the window, and then dumps the layer tree, at which point
     9        some layers would report a contentsScale of 2 on Retina displays.
     10
     11        This occurs because WebKitTestRunner overrides the default device scale factor on NSWindow,
     12        but windowless views fall back to [NSScreen mainScreen].backingScaleFactor (in WebViewImpl::intrinsicDeviceScaleFactor()).
     13
     14        Fix by having PlatformWebView::changeWindowScaleIfNeeded() call -_setOverrideDeviceScaleFactor: on the view.
     15
     16        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
     17        (WTR::PlatformWebView::changeWindowScaleIfNeeded):
     18
    1192017-09-19  Wenson Hsieh  <wenson_hsieh@apple.com>
    220
  • trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

    r216931 r222247  
    288288    if (currentScale == newScale)
    289289        return;
     290
    290291    [m_window _setWindowResolution:newScale displayIfChanged:YES];
     292#if WK_API_ENABLED
     293    [m_view _setOverrideDeviceScaleFactor:newScale];
     294#endif
     295
    291296    // Instead of re-constructing the current window, let's fake resize it to ensure that the scale change gets picked up.
    292297    forceWindowFramesChanged();
Note: See TracChangeset for help on using the changeset viewer.