<!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>[167168] trunk/Source</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/167168">167168</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-04-11 16:20:27 -0700 (Fri, 11 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add HighDPI support for non-accelerated compositing contents
https://bugs.webkit.org/show_bug.cgi?id=131562

Patch by Owen Taylor &lt;otaylor@redhat.com&gt; on 2014-04-11
Reviewed by Martin Robinson.

Source/WebCore:

No new tests. This will be tested once we have the proper dependencies in the WebKit testing
JHBuild.

* platform/cairo/WidgetBackingStore.h:
(WebCore::WidgetBackingStore::WidgetBackingStore): Accept a device scale argument.
* platform/cairo/WidgetBackingStoreCairo.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale.
* platform/cairo/WidgetBackingStoreCairo.h: Accept a device scale argument.
* platform/graphics/cairo/CairoUtilities.cpp: Add a new helper to set the device scale if Cairo built against is new enough.
* platform/graphics/cairo/CairoUtilities.h:
* platform/gtk/GtkVersioning.h: Add the HAVE_GTK_SCALE_FACTOR macro.
* platform/gtk/WidgetBackingStoreGtkX11.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale.
* platform/gtk/WidgetBackingStoreGtkX11.h: Accept a device scale argument.

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(scaleFactorChanged): Added this callback to pass scale changes to the page proxy.
(webkitWebViewBaseCreateWebPage): Attach the callback to the notify signal.
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::createBackingStoreForGTK): Pass the scale factor to the WebCore backing store.
(WebKit::BackingStore::incorporateUpdate): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformcairoWidgetBackingStoreh">trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcairoWidgetBackingStoreCairocpp">trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformcairoWidgetBackingStoreCairoh">trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoCairoUtilitiescpp">trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoCairoUtilitiesh">trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11cpp">trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11h">trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp">trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/ChangeLog        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-04-11  Owen Taylor  &lt;otaylor@redhat.com&gt;
+
+        [GTK] Add HighDPI support for non-accelerated compositing contents
+        https://bugs.webkit.org/show_bug.cgi?id=131562
+
+        Reviewed by Martin Robinson.
+
+        No new tests. This will be tested once we have the proper dependencies in the WebKit testing
+        JHBuild.
+
+        * platform/cairo/WidgetBackingStore.h:
+        (WebCore::WidgetBackingStore::WidgetBackingStore): Accept a device scale argument.
+        * platform/cairo/WidgetBackingStoreCairo.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale.
+        * platform/cairo/WidgetBackingStoreCairo.h: Accept a device scale argument.
+        * platform/graphics/cairo/CairoUtilities.cpp: Add a new helper to set the device scale if Cairo built against is new enough.
+        * platform/graphics/cairo/CairoUtilities.h:
+        * platform/gtk/GtkVersioning.h: Add the HAVE_GTK_SCALE_FACTOR macro.
+        * platform/gtk/WidgetBackingStoreGtkX11.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale.
+        * platform/gtk/WidgetBackingStoreGtkX11.h: Accept a device scale argument.
+
</ins><span class="cx"> 2014-04-11  Jon Honeycutt  &lt;jhoneycutt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Assertion failure changing select element size during focus event
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcairoWidgetBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -49,11 +49,17 @@
</span><span class="cx">     virtual cairo_surface_t* cairoSurface() = 0;
</span><span class="cx">     virtual void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset) = 0;
</span><span class="cx">     const IntSize&amp; size() { return m_size; }
</span><del>-    WidgetBackingStore(const IntSize&amp; size) : m_size(size) { }
</del><ins>+
+    WidgetBackingStore(const IntSize&amp; size, float deviceScaleFactor)
+        : m_size(size)
+        , m_deviceScaleFactor(deviceScaleFactor)
+    { }
+
</ins><span class="cx">     virtual ~WidgetBackingStore() { }
</span><span class="cx"> 
</span><del>-private:
</del><ins>+protected:
</ins><span class="cx">     IntSize m_size;
</span><ins>+    float m_deviceScaleFactor;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcairoWidgetBackingStoreCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -26,8 +26,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static PassRefPtr&lt;cairo_surface_t&gt; createSurfaceForBackingStore(PlatformWidget widget, const IntSize&amp; size)
</del><ins>+static PassRefPtr&lt;cairo_surface_t&gt; createSurfaceForBackingStore(PlatformWidget widget, IntSize size, float deviceScaleFactor)
</ins><span class="cx"> {
</span><ins>+    size.scale(deviceScaleFactor);
+
</ins><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     return adoptRef(gdk_window_create_similar_surface(gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR_ALPHA, size.width(), size.height()));
</span><span class="cx"> #else
</span><span class="lines">@@ -36,20 +38,20 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassOwnPtr&lt;WidgetBackingStore&gt; WidgetBackingStoreCairo::create(PlatformWidget widget, const IntSize&amp; size)
</del><ins>+PassOwnPtr&lt;WidgetBackingStore&gt; WidgetBackingStoreCairo::create(PlatformWidget widget, const IntSize&amp; size, float deviceScaleFactor)
</ins><span class="cx"> {
</span><del>-    return adoptPtr(new WidgetBackingStoreCairo(widget, size));
</del><ins>+    return adoptPtr(new WidgetBackingStoreCairo(widget, size, deviceScaleFactor));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // We keep two copies of the surface here, which will double the memory usage, but increase
</span><span class="cx"> // scrolling performance since we do not have to keep reallocating a memory region during
</span><span class="cx"> // quick scrolling requests.
</span><del>-WidgetBackingStoreCairo::WidgetBackingStoreCairo(PlatformWidget widget, const IntSize&amp; size)
-    : WidgetBackingStore(size)
-    , m_surface(createSurfaceForBackingStore(widget, size))
-    , m_scrollSurface(createSurfaceForBackingStore(widget, size))
-
</del><ins>+WidgetBackingStoreCairo::WidgetBackingStoreCairo(PlatformWidget widget, const IntSize&amp; size, float deviceScaleFactor)
+    : WidgetBackingStore(size, deviceScaleFactor)
+    , m_surface(createSurfaceForBackingStore(widget, size, deviceScaleFactor))
+    , m_scrollSurface(createSurfaceForBackingStore(widget, size, deviceScaleFactor))
</ins><span class="cx"> {
</span><ins>+    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WidgetBackingStoreCairo::~WidgetBackingStoreCairo()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcairoWidgetBackingStoreCairoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -27,8 +27,8 @@
</span><span class="cx"> class WidgetBackingStoreCairo : public WidgetBackingStore {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    static PassOwnPtr&lt;WidgetBackingStore&gt; create(PlatformWidget, const IntSize&amp;);
-    WidgetBackingStoreCairo(PlatformWidget, const IntSize&amp;);
</del><ins>+    static PassOwnPtr&lt;WidgetBackingStore&gt; create(PlatformWidget, const IntSize&amp;, float deviceScaleFactor);
+    WidgetBackingStoreCairo(PlatformWidget, const IntSize&amp;, float deviceScaleFactor);
</ins><span class="cx">     ~WidgetBackingStoreCairo();
</span><span class="cx">     cairo_surface_t* cairoSurface();
</span><span class="cx">     void scroll(const IntRect&amp;, const IntSize&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoCairoUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;Path.h&quot;
</span><span class="cx"> #include &quot;PlatformPathCairo.h&quot;
</span><span class="cx"> #include &quot;RefPtrCairo.h&quot;
</span><ins>+#include &lt;wtf/Assertions.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><span class="lines">@@ -259,4 +260,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void cairoSurfaceSetDeviceScale(cairo_surface_t* surface, double xScale, double yScale)
+{
+    // This function was added pretty much simultaneous to when 1.13 was branched.
+#if HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE)
+    cairo_surface_set_device_scale(surface, xScale, yScale);
+#else
+    UNUSED_PARAM(surface);
+    ASSERT_UNUSED(xScale, 1 == xScale);
+    ASSERT_UNUSED(yScale, 1 == yScale);
+#endif
+}
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoCairoUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -31,6 +31,9 @@
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="cx"> 
</span><ins>+// This function was added pretty much simultaneous to when 1.13 was branched.
+#define HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE CAIRO_VERSION_MAJOR &gt; 1 || (CAIRO_VERSION_MAJOR == 1 &amp;&amp; CAIRO_VERSION_MINOR &gt;= 13)
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> class AffineTransform;
</span><span class="cx"> class Color;
</span><span class="lines">@@ -56,6 +59,7 @@
</span><span class="cx"> void copyRectFromOneSurfaceToAnother(cairo_surface_t* from, cairo_surface_t* to, const IntSize&amp; offset, const IntRect&amp;, const IntSize&amp; = IntSize(), cairo_operator_t = CAIRO_OPERATOR_OVER);
</span><span class="cx"> 
</span><span class="cx"> IntSize cairoSurfaceSize(cairo_surface_t*);
</span><ins>+void cairoSurfaceSetDeviceScale(cairo_surface_t*, double xScale, double yScale);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WidgetBackingStoreGtkX11.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CairoUtilities.h&quot;
</ins><span class="cx"> #include &quot;GtkVersioning.h&quot;
</span><span class="cx"> #include &quot;RefPtrCairo.h&quot;
</span><span class="cx"> #include &lt;cairo-xlib.h&gt;
</span><span class="lines">@@ -27,23 +28,28 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-PassOwnPtr&lt;WidgetBackingStore&gt; WidgetBackingStoreGtkX11::create(GtkWidget* widget, const IntSize&amp; size)
</del><ins>+PassOwnPtr&lt;WidgetBackingStore&gt; WidgetBackingStoreGtkX11::create(GtkWidget* widget, const IntSize&amp; size, float deviceScaleFactor)
</ins><span class="cx"> {
</span><del>-    return adoptPtr(new WidgetBackingStoreGtkX11(widget, size));
</del><ins>+    return adoptPtr(new WidgetBackingStoreGtkX11(widget, size, deviceScaleFactor));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize&amp; size)
-    : WidgetBackingStore(size)
</del><ins>+WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize&amp; size, float deviceScaleFactor)
+    : WidgetBackingStore(size, deviceScaleFactor)
</ins><span class="cx"> {
</span><ins>+    IntSize scaledSize = size;
+    scaledSize.scale(deviceScaleFactor);
+
</ins><span class="cx">     GdkVisual* visual = gtk_widget_get_visual(widget);
</span><span class="cx">     GdkScreen* screen = gdk_visual_get_screen(visual);
</span><span class="cx">     m_display = GDK_SCREEN_XDISPLAY(screen);
</span><span class="cx">     m_pixmap = XCreatePixmap(m_display, GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
</span><del>-        size.width(), size.height(), gdk_visual_get_depth(visual));
</del><ins>+        scaledSize.width(), scaledSize.height(), gdk_visual_get_depth(visual));
</ins><span class="cx">     m_gc = XCreateGC(m_display, m_pixmap, 0, 0);
</span><span class="cx"> 
</span><span class="cx">     m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap,
</span><del>-        GDK_VISUAL_XVISUAL(visual), size.width(), size.height()));
</del><ins>+        GDK_VISUAL_XVISUAL(visual), scaledSize.width(), scaledSize.height()));
+
+    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WidgetBackingStoreGtkX11::~WidgetBackingStoreGtkX11()
</span><span class="lines">@@ -67,9 +73,14 @@
</span><span class="cx">     if (targetRect.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    targetRect.scale(m_deviceScaleFactor);
+
+    IntSize scaledScrollOffset = scrollOffset;
+    scaledScrollOffset.scale(m_deviceScaleFactor);
+
</ins><span class="cx">     cairo_surface_flush(m_surface.get());
</span><span class="cx">     XCopyArea(m_display, m_pixmap, m_pixmap, m_gc, 
</span><del>-        targetRect.x() - scrollOffset.width(), targetRect.y() - scrollOffset.height(),
</del><ins>+        targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
</ins><span class="cx">         targetRect.width(), targetRect.height(),
</span><span class="cx">         targetRect.x(), targetRect.y());
</span><span class="cx">     cairo_surface_mark_dirty_rectangle(m_surface.get(),
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -29,8 +29,8 @@
</span><span class="cx"> class WidgetBackingStoreGtkX11 : public WidgetBackingStore {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    static PassOwnPtr&lt;WidgetBackingStore&gt; create(GtkWidget*, const IntSize&amp;);
-    WidgetBackingStoreGtkX11(GtkWidget*, const IntSize&amp;);
</del><ins>+    static PassOwnPtr&lt;WidgetBackingStore&gt; create(GtkWidget*, const IntSize&amp;, float deviceScaleFactor);
+    WidgetBackingStoreGtkX11(GtkWidget*, const IntSize&amp;, float deviceScaleFactor);
</ins><span class="cx">     ~WidgetBackingStoreGtkX11();
</span><span class="cx">     cairo_surface_t* cairoSurface();
</span><span class="cx">     void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-04-11  Owen Taylor  &lt;otaylor@redhat.com&gt;
+
+        [GTK] Add HighDPI support for non-accelerated compositing contents
+        https://bugs.webkit.org/show_bug.cgi?id=131562
+
+        Reviewed by Martin Robinson.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (scaleFactorChanged): Added this callback to pass scale changes to the page proxy.
+        (webkitWebViewBaseCreateWebPage): Attach the callback to the notify signal.
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::createBackingStoreForGTK): Pass the scale factor to the WebCore backing store.
+        (WebKit::BackingStore::incorporateUpdate): Ditto.
+
</ins><span class="cx"> 2014-04-10  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] Dispatch to main thread's run loop to handle cookie requests.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> #include &quot;WebPreferences.h&quot;
</span><span class="cx"> #include &quot;WebViewBaseInputMethodFilter.h&quot;
</span><ins>+#include &lt;WebCore/CairoUtilities.h&gt;
</ins><span class="cx"> #include &lt;WebCore/ClipboardUtilitiesGtk.h&gt;
</span><span class="cx"> #include &lt;WebCore/DataObjectGtk.h&gt;
</span><span class="cx"> #include &lt;WebCore/DragData.h&gt;
</span><span class="lines">@@ -78,6 +79,10 @@
</span><span class="cx"> #include &lt;WebCore/RedirectedXCompositeWindow.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+// gtk_widget_get_scale_factor() appeared in GTK 3.10, but we also need
+// to make sure we have cairo new enough to support cairo_surface_set_device_scale
+#define HAVE_GTK_SCALE_FACTOR HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE &amp;&amp; GTK_CHECK_VERSION(3, 10, 0)
+
</ins><span class="cx"> using namespace WebKit;
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -961,6 +966,15 @@
</span><span class="cx">     priv-&gt;pageProxy-&gt;pageGroup().preferences().setAcceleratedCompositingEnabled(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if HAVE(GTK_SCALE_FACTOR)
+static void scaleFactorChanged(GObject* object, GParamSpec*)
+{
+    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(object)-&gt;priv;
+    ASSERT(priv-&gt;pageProxy);
+    priv-&gt;pageProxy-&gt;setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(object)));
+}
+#endif // HAVE(GTK_SCALE_FACTOR)
+
</ins><span class="cx"> void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebContext* context, WebPageGroup* pageGroup, WebPageProxy* relatedPage)
</span><span class="cx"> {
</span><span class="cx">     WebKitWebViewBasePrivate* priv = webkitWebViewBase-&gt;priv;
</span><span class="lines">@@ -976,6 +990,12 @@
</span><span class="cx">         priv-&gt;pageProxy-&gt;setAcceleratedCompositingWindowId(priv-&gt;redirectedWindow-&gt;windowId());
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(GTK_SCALE_FACTOR)
+    // We attach this here, because changes in scale factor are passed directly to the page proxy.
+    priv-&gt;pageProxy-&gt;setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
+    g_signal_connect(object, &quot;notify::scale-factor&quot;, G_CALLBACK(scaleFactorChanged), NULL);
+#endif
+
</ins><span class="cx">     webkitWebViewBaseUpdatePreferences(webkitWebViewBase);
</span><span class="cx"> 
</span><span class="cx">     // This must happen here instead of the instance initializer, because the input method
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp (167167 => 167168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2014-04-11 23:09:39 UTC (rev 167167)
+++ trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2014-04-11 23:20:27 UTC (rev 167168)
</span><span class="lines">@@ -48,14 +48,14 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><del>-static OwnPtr&lt;WidgetBackingStore&gt; createBackingStoreForGTK(GtkWidget* widget, const IntSize&amp; size)
</del><ins>+static OwnPtr&lt;WidgetBackingStore&gt; createBackingStoreForGTK(GtkWidget* widget, const IntSize&amp; size, float deviceScaleFactor)
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
</span><span class="cx">     GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
</span><span class="cx">     if (GDK_IS_X11_DISPLAY(display))
</span><del>-        return WebCore::WidgetBackingStoreGtkX11::create(widget, size);
</del><ins>+        return WebCore::WidgetBackingStoreGtkX11::create(widget, size, deviceScaleFactor);
</ins><span class="cx"> #endif
</span><del>-    return WebCore::WidgetBackingStoreCairo::create(widget, size);
</del><ins>+    return WebCore::WidgetBackingStoreCairo::create(widget, size, deviceScaleFactor);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -73,9 +73,9 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_backingStore)
</span><span class="cx"> #if PLATFORM(EFL)
</span><del>-        m_backingStore = WidgetBackingStoreCairo::create(EwkView::toEvasObject(toAPI(m_webPageProxy)), size());
</del><ins>+        m_backingStore = WidgetBackingStoreCairo::create(EwkView::toEvasObject(toAPI(m_webPageProxy)), size(), deviceScaleFactor());
</ins><span class="cx"> #else
</span><del>-        m_backingStore = createBackingStoreForGTK(m_webPageProxy-&gt;viewWidget(), size());
</del><ins>+        m_backingStore = createBackingStoreForGTK(m_webPageProxy-&gt;viewWidget(), size(), deviceScaleFactor());
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">         IntRect updateRect = updateInfo.updateRects[i];
</span><span class="cx">         IntRect srcRect = updateRect;
</span><span class="cx">         srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
</span><del>-        bitmap-&gt;paint(graphicsContext, updateRect.location(), srcRect);
</del><ins>+        bitmap-&gt;paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>