<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185982] trunk/Source/WebKit/win</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185982">185982</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-06-25 20:55:42 -0700 (Thu, 25 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Need implementation of layoutTestController.setBackingScaleFactor
https://bugs.webkit.org/show_bug.cgi?id=87919
&lt;rdar://problem/11563242&gt;

Reviewed by Dean Jackson.

Connect the test infrastructure for High DPI tests to Windows. This
involved adding a new accessor to the IWebViewPrivate interface, and
providing a rudimentary implemenation of DPI support on Windows.

* Interfaces/IWebViewPrivate.idl: Add new API to set/get scaling
factor.
* WebView.cpp:
(WebView::initWithFrame): Initialize the device scale factor.
(WebView::setHostWindow): Ditto.
(WebView::windowAncestryDidChange): Ditto.
(WebView::deviceScaleFactor): Added. Check current window for scaling
factor. If no windows exist, check main screen.
(WebView::setCustomBackingScaleFactor): Added.
(WebView::backingScaleFactor): Added.
* WebView.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinInterfacesIWebViewPrivateidl">trunk/Source/WebKit/win/Interfaces/IWebViewPrivate.idl</a></li>
<li><a href="#trunkSourceWebKitwinWebViewcpp">trunk/Source/WebKit/win/WebView.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebViewh">trunk/Source/WebKit/win/WebView.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (185981 => 185982)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2015-06-26 03:13:25 UTC (rev 185981)
+++ trunk/Source/WebKit/win/ChangeLog        2015-06-26 03:55:42 UTC (rev 185982)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-06-25  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Need implementation of layoutTestController.setBackingScaleFactor
+        https://bugs.webkit.org/show_bug.cgi?id=87919
+        &lt;rdar://problem/11563242&gt;
+
+        Reviewed by Dean Jackson.
+
+        Connect the test infrastructure for High DPI tests to Windows. This
+        involved adding a new accessor to the IWebViewPrivate interface, and
+        providing a rudimentary implemenation of DPI support on Windows.
+
+        * Interfaces/IWebViewPrivate.idl: Add new API to set/get scaling
+        factor.
+        * WebView.cpp:
+        (WebView::initWithFrame): Initialize the device scale factor.
+        (WebView::setHostWindow): Ditto.
+        (WebView::windowAncestryDidChange): Ditto.
+        (WebView::deviceScaleFactor): Added. Check current window for scaling
+        factor. If no windows exist, check main screen.
+        (WebView::setCustomBackingScaleFactor): Added.
+        (WebView::backingScaleFactor): Added.
+        * WebView.h:
+
</ins><span class="cx"> 2015-06-24  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move PluginMainThreadScheduler to WebKit/win
</span></span></pre></div>
<a id="trunkSourceWebKitwinInterfacesIWebViewPrivateidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/Interfaces/IWebViewPrivate.idl (185981 => 185982)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Interfaces/IWebViewPrivate.idl        2015-06-26 03:13:25 UTC (rev 185981)
+++ trunk/Source/WebKit/win/Interfaces/IWebViewPrivate.idl        2015-06-26 03:55:42 UTC (rev 185982)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2015 Apple Inc.  All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -297,4 +297,7 @@
</span><span class="cx">     HRESULT scaleWebView([in] double scale, [in] POINT origin);
</span><span class="cx"> 
</span><span class="cx">     HRESULT dispatchPendingLoadRequests();
</span><ins>+
+    HRESULT setCustomBackingScaleFactor([in] double);
+    HRESULT backingScaleFactor([out] double*);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebView.cpp (185981 => 185982)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebView.cpp        2015-06-26 03:13:25 UTC (rev 185981)
+++ trunk/Source/WebKit/win/WebView.cpp        2015-06-26 03:55:42 UTC (rev 185982)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006-2014 Apple, Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006-2015 Apple, Inc.  All rights reserved.
</ins><span class="cx">  * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
</span><span class="cx">  * Copyright (C) 2011 Brent Fulgham. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -2249,7 +2249,7 @@
</span><span class="cx">     ASSERT(webView);
</span><span class="cx"> 
</span><span class="cx">     // Windows Media Player has a modal message loop that will deliver messages
</span><del>-    // to us at inappropriate times and we will crash if we handle them when
</del><ins>+    // to us at inappropriate times and we will crash if we handle them when:
</ins><span class="cx">     // they are delivered. We repost paint messages so that we eventually get
</span><span class="cx">     // a chance to paint once the modal loop has exited, but other messages
</span><span class="cx">     // aren't safe to repost, so we just drop them.
</span><span class="lines">@@ -2866,6 +2866,8 @@
</span><span class="cx">     notifyCenter-&gt;addObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast&lt;IWebPreferences*&gt;(m_preferences.get()));
</span><span class="cx">     m_preferences-&gt;postPreferencesChangesNotification();
</span><span class="cx"> 
</span><ins>+    m_page-&gt;setDeviceScaleFactor(deviceScaleFactor());
+
</ins><span class="cx">     setSmartInsertDeleteEnabled(TRUE);
</span><span class="cx">     return hr;
</span><span class="cx"> }
</span><span class="lines">@@ -3528,6 +3530,9 @@
</span><span class="cx"> 
</span><span class="cx">     windowAncestryDidChange();
</span><span class="cx"> 
</span><ins>+    if (m_page)
+        m_page-&gt;setDeviceScaleFactor(deviceScaleFactor());
+
</ins><span class="cx">     return S_OK;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -6005,6 +6010,9 @@
</span><span class="cx">     if (m_topLevelParent)
</span><span class="cx">         WindowMessageBroadcaster::addListener(m_topLevelParent, this);
</span><span class="cx"> 
</span><ins>+    if (m_page)
+        m_page-&gt;setDeviceScaleFactor(deviceScaleFactor());
+
</ins><span class="cx">     updateActiveState();
</span><span class="cx"> 
</span><span class="cx">     return S_OK;
</span><span class="lines">@@ -7132,3 +7140,47 @@
</span><span class="cx">     resourceLoadScheduler()-&gt;servePendingRequests();
</span><span class="cx">     return S_OK;
</span><span class="cx"> }
</span><ins>+
+static float scaleFactorFromWindow(HWND window)
+{
+    HWndDC dc(window);
+    return ::GetDeviceCaps(dc, LOGPIXELSX) / 96.0f;
+}
+
+float WebView::deviceScaleFactor() const
+{
+    if (m_customDeviceScaleFactor)
+        return m_customDeviceScaleFactor;
+
+    // FIXME(146335): Should check for Windows 8.1 High DPI Features here first.
+
+    if (m_viewWindow)
+        return scaleFactorFromWindow(m_viewWindow);
+
+    if (m_hostWindow)
+        return scaleFactorFromWindow(m_hostWindow);
+
+    return scaleFactorFromWindow(0);
+}
+
+HRESULT WebView::setCustomBackingScaleFactor(double customScaleFactor)
+{
+    double oldScaleFactor = deviceScaleFactor();
+
+    m_customDeviceScaleFactor = customScaleFactor;
+
+    if (oldScaleFactor != deviceScaleFactor())
+        m_page-&gt;setDeviceScaleFactor(deviceScaleFactor());
+
+    return S_OK;
+}
+
+HRESULT WebView::backingScaleFactor(double* factor)
+{
+    if (!factor)
+        return E_POINTER;
+
+    *factor = deviceScaleFactor();
+
+    return S_OK;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebView.h (185981 => 185982)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebView.h        2015-06-26 03:13:25 UTC (rev 185981)
+++ trunk/Source/WebKit/win/WebView.h        2015-06-26 03:55:42 UTC (rev 185982)
</span><span class="lines">@@ -840,6 +840,9 @@
</span><span class="cx">     virtual HRESULT STDMETHODCALLTYPE setUsesLayeredWindow(BOOL);
</span><span class="cx">     virtual HRESULT STDMETHODCALLTYPE usesLayeredWindow(BOOL*);
</span><span class="cx"> 
</span><ins>+    virtual HRESULT STDMETHODCALLTYPE setCustomBackingScaleFactor(double);
+    virtual HRESULT STDMETHODCALLTYPE backingScaleFactor(double*);
+
</ins><span class="cx">     // WebView
</span><span class="cx">     bool shouldUseEmbeddedView(const WTF::String&amp; mimeType) const;
</span><span class="cx"> 
</span><span class="lines">@@ -1023,6 +1026,8 @@
</span><span class="cx">     HRESULT STDMETHODCALLTYPE scaleWebView(double scale, POINT origin);
</span><span class="cx">     HRESULT STDMETHODCALLTYPE dispatchPendingLoadRequests();
</span><span class="cx"> 
</span><ins>+    float deviceScaleFactor() const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     static bool registerWebViewWindowClass();
</span><span class="cx">     static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
</span><span class="lines">@@ -1096,6 +1101,7 @@
</span><span class="cx">     WTF::String m_userAgentCustom;
</span><span class="cx">     WTF::String m_userAgentStandard;
</span><span class="cx">     float m_zoomMultiplier;
</span><ins>+    float m_customDeviceScaleFactor { 0 };
</ins><span class="cx">     bool m_zoomsTextOnly;
</span><span class="cx">     WTF::String m_overrideEncoding;
</span><span class="cx">     WTF::String m_applicationName;
</span></span></pre>
</div>
</div>

</body>
</html>