<!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>[211363] trunk</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/211363">211363</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-30 05:50:37 -0800 (Mon, 30 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add API to handle the accelerated compositing policy
https://bugs.webkit.org/show_bug.cgi?id=167509

Reviewed by Michael Catanzaro.

Source/WebKit2:

Now that we have brought back the on demand mode, we should allow applications to choose the policy, without
having to deal with environment variables. Settings also allows to set different policy depending on the web
view, so for example evolution could disable AC for the composer, but leave the on demand mode for the email
viewer. This patch adds a single new setting hardware-acceleration-policy to handle both
acceleratedCompositingEnabled and forceCompositingMode preferences using an enum with values
WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS and
WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER.

* UIProcess/API/gtk/WebKitSettings.cpp:
(webKitSettingsSetProperty): Add setter for hardware-acceleration-policy property.
(webKitSettingsGetProperty): Add getter for hardware-acceleration-policy property.
(webkit_settings_class_init): Add hardware-acceleration-policy property.
(webkit_settings_get_hardware_acceleration_policy): Return policy according to the preferences.
(webkit_settings_set_hardware_acceleration_policy): set preferences according to the given policy.
* UIProcess/API/gtk/WebKitSettings.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::updatePreferences):

Tools:

Handle new setting in MiniBrowser. The settings dialog doesn't support enum settings so it needs to be handled
as a special case. Also add test cases to the get/set API.

* MiniBrowser/gtk/BrowserSettingsDialog.c:
(hardwareAccelerationPolicyToString):
(stringToHardwareAccelerationPolicy):
(cellRendererChanged):
(browserSettingsDialogConstructed):
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp:
(testWebKitSettings):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitSettingscpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitSettingsh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageDrawingAreaImplcpp">trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsergtkBrowserSettingsDialogc">trunk/Tools/MiniBrowser/gtk/BrowserSettingsDialog.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitSettingscpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-01-30  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add API to handle the accelerated compositing policy
+        https://bugs.webkit.org/show_bug.cgi?id=167509
+
+        Reviewed by Michael Catanzaro.
+
+        Now that we have brought back the on demand mode, we should allow applications to choose the policy, without
+        having to deal with environment variables. Settings also allows to set different policy depending on the web
+        view, so for example evolution could disable AC for the composer, but leave the on demand mode for the email
+        viewer. This patch adds a single new setting hardware-acceleration-policy to handle both
+        acceleratedCompositingEnabled and forceCompositingMode preferences using an enum with values
+        WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS and
+        WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER.
+
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webKitSettingsSetProperty): Add setter for hardware-acceleration-policy property.
+        (webKitSettingsGetProperty): Add getter for hardware-acceleration-policy property.
+        (webkit_settings_class_init): Add hardware-acceleration-policy property.
+        (webkit_settings_get_hardware_acceleration_policy): Return policy according to the preferences.
+        (webkit_settings_set_hardware_acceleration_policy): set preferences according to the given policy.
+        * UIProcess/API/gtk/WebKitSettings.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::updatePreferences):
+
</ins><span class="cx"> 2017-01-29  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Threaded Compositor] Crash on WebCore::GLContext::version()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;WebKitSettings.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ExperimentalFeatures.h&quot;
</span><ins>+#include &quot;WebKitEnumTypes.h&quot;
</ins><span class="cx"> #include &quot;WebKitPrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitSettingsPrivate.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="lines">@@ -145,7 +146,8 @@
</span><span class="cx">     PROP_ENABLE_SPATIAL_NAVIGATION,
</span><span class="cx">     PROP_ENABLE_MEDIASOURCE,
</span><span class="cx">     PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS,
</span><del>-    PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS
</del><ins>+    PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS,
+    PROP_HARDWARE_ACCELERATION_POLICY,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static void webKitSettingsConstructed(GObject* object)
</span><span class="lines">@@ -323,6 +325,9 @@
</span><span class="cx">     case PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS:
</span><span class="cx">         webkit_settings_set_allow_universal_access_from_file_urls(settings, g_value_get_boolean(value));
</span><span class="cx">         break;
</span><ins>+    case PROP_HARDWARE_ACCELERATION_POLICY:
+        webkit_settings_set_hardware_acceleration_policy(settings, static_cast&lt;WebKitHardwareAccelerationPolicy&gt;(g_value_get_enum(value)));
+        break;
</ins><span class="cx">     default:
</span><span class="cx">         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
</span><span class="cx">         break;
</span><span class="lines">@@ -486,6 +491,9 @@
</span><span class="cx">     case PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS:
</span><span class="cx">         g_value_set_boolean(value, webkit_settings_get_allow_universal_access_from_file_urls(settings));
</span><span class="cx">         break;
</span><ins>+    case PROP_HARDWARE_ACCELERATION_POLICY:
+        g_value_set_enum(value, webkit_settings_get_hardware_acceleration_policy(settings));
+        break;
</ins><span class="cx">     default:
</span><span class="cx">         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
</span><span class="cx">         break;
</span><span class="lines">@@ -1279,6 +1287,28 @@
</span><span class="cx">             _(&quot;Whether or not universal access is allowed from the context of file scheme URLs&quot;),
</span><span class="cx">             FALSE,
</span><span class="cx">             readWriteConstructParamFlags));
</span><ins>+
+    /**
+     * WebKitSettings:hardware-acceleration-policy:
+     *
+     * The #WebKitHardwareAccelerationPolicy to decide how to enable and disable
+     * hardware acceleration. The default value %WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND
+     * enables the hardware acceleration when the web contents request it, disabling it again
+     * when no longer needed. It's possible to enfore hardware acceleration to be always enabled
+     * by using %WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS. And it's also posible to disable it
+     * completely using %WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER. Note that disabling hardware
+     * acceleration might cause some websites to not render correctly or consume more CPU.
+     *
+     * Since: 2.16
+     */
+    g_object_class_install_property(gObjectClass,
+        PROP_HARDWARE_ACCELERATION_POLICY,
+        g_param_spec_enum(&quot;hardware-acceleration-policy&quot;,
+            _(&quot;Hardware Acceleration Policy&quot;),
+            _(&quot;The policy to decide how to enable and disable hardware acceleration&quot;),
+            WEBKIT_TYPE_HARDWARE_ACCELERATION_POLICY,
+            WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND,
+            readWriteConstructParamFlags));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebPreferences* webkitSettingsGetPreferences(WebKitSettings* settings)
</span><span class="lines">@@ -3142,3 +3172,83 @@
</span><span class="cx">     priv-&gt;preferences-&gt;setAllowUniversalAccessFromFileURLs(allowed);
</span><span class="cx">     g_object_notify(G_OBJECT(settings), &quot;allow-universal-access-from-file-urls&quot;);
</span><span class="cx"> }
</span><ins>+
+/**
+ * webkit_settings_get_hardware_acceleration_policy:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:hardware-acceleration-policy property.
+ *
+ * Return: a #WebKitHardwareAccelerationPolicy
+ *
+ * Since: 2.16
+ */
+WebKitHardwareAccelerationPolicy webkit_settings_get_hardware_acceleration_policy(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
+
+    WebKitSettingsPrivate* priv = settings-&gt;priv;
+    if (!priv-&gt;preferences-&gt;acceleratedCompositingEnabled())
+        return WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER;
+
+    if (priv-&gt;preferences-&gt;forceCompositingMode())
+        return WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS;
+
+    return WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND;
+}
+
+/**
+ * webkit_settings_set_hardware_acceleration_policy:
+ * @settings: a #WebKitSettings
+ * @policy: a #WebKitHardwareAccelerationPolicy
+ *
+ * Set the #WebKitSettings:hardware-acceleration-policy property.
+ *
+ * Since: 2.16
+ */
+void webkit_settings_set_hardware_acceleration_policy(WebKitSettings* settings, WebKitHardwareAccelerationPolicy policy)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings-&gt;priv;
+    bool changed = false;
+    switch (policy) {
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS:
+        if (!priv-&gt;preferences-&gt;acceleratedCompositingEnabled()) {
+            priv-&gt;preferences-&gt;setAcceleratedCompositingEnabled(true);
+            changed = true;
+        }
+        if (!priv-&gt;preferences-&gt;forceCompositingMode()) {
+            priv-&gt;preferences-&gt;setForceCompositingMode(true);
+            changed = true;
+        }
+        break;
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER:
+        if (priv-&gt;preferences-&gt;acceleratedCompositingEnabled()) {
+            priv-&gt;preferences-&gt;setAcceleratedCompositingEnabled(false);
+            changed = true;
+        }
+
+        if (priv-&gt;preferences-&gt;forceCompositingMode()) {
+            priv-&gt;preferences-&gt;setForceCompositingMode(false);
+            changed = true;
+        }
+        break;
+
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND:
+        if (!priv-&gt;preferences-&gt;acceleratedCompositingEnabled()) {
+            priv-&gt;preferences-&gt;setAcceleratedCompositingEnabled(true);
+            changed = true;
+        }
+
+        if (priv-&gt;preferences-&gt;forceCompositingMode()) {
+            priv-&gt;preferences-&gt;setForceCompositingMode(false);
+            changed = true;
+        }
+
+        break;
+    }
+
+    if (changed)
+        g_object_notify(G_OBJECT(settings), &quot;hardware-acceleration-policy&quot;);
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -47,6 +47,22 @@
</span><span class="cx"> #define WEBKIT_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_SETTINGS))
</span><span class="cx"> #define WEBKIT_SETTINGS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_SETTINGS, WebKitSettingsClass))
</span><span class="cx"> 
</span><ins>+/**
+ * WebKitHardwareAccelerationPolicy:
+ * @WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND: Hardware acceleration is enabled/disabled as request by web contents.
+ * @WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS: Hardware acceleration is always enabled, even for websites not requesting it.
+ * @WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER: Hardware acceleration is always disabled, even for websites requesting it.
+ *
+ * Enum values used for determining the hardware acceleration policy.
+ *
+ * Since: 2.16
+ */
+typedef enum {
+    WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND,
+    WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS,
+    WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER
+} WebKitHardwareAccelerationPolicy;
+
</ins><span class="cx"> typedef struct _WebKitSettings WebKitSettings;
</span><span class="cx"> typedef struct _WebKitSettingsClass WebKitSettingsClass;
</span><span class="cx"> typedef struct _WebKitSettingsPrivate WebKitSettingsPrivate;
</span><span class="lines">@@ -428,6 +444,13 @@
</span><span class="cx"> webkit_settings_set_allow_universal_access_from_file_urls      (WebKitSettings *settings,
</span><span class="cx">                                                                 gboolean        allowed);
</span><span class="cx"> 
</span><ins>+WEBKIT_API WebKitHardwareAccelerationPolicy
+webkit_settings_get_hardware_acceleration_policy               (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_hardware_acceleration_policy               (WebKitSettings *settings,
+                                                                WebKitHardwareAccelerationPolicy policy);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx"> 
</span><span class="cx"> #endif /* WebKitSettings_h */
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -358,6 +358,7 @@
</span><span class="cx"> &lt;SECTION&gt;
</span><span class="cx"> &lt;FILE&gt;WebKitSettings&lt;/FILE&gt;
</span><span class="cx"> WebKitSettings
</span><ins>+WebKitHardwareAccelerationPolicy
</ins><span class="cx"> webkit_settings_new
</span><span class="cx"> webkit_settings_new_with_settings
</span><span class="cx"> webkit_settings_get_auto_load_images
</span><span class="lines">@@ -461,6 +462,8 @@
</span><span class="cx"> webkit_settings_set_allow_file_access_from_file_urls
</span><span class="cx"> webkit_settings_get_allow_universal_access_from_file_urls
</span><span class="cx"> webkit_settings_set_allow_universal_access_from_file_urls
</span><ins>+webkit_settings_get_hardware_acceleration_policy
+webkit_settings_set_hardware_acceleration_policy
</ins><span class="cx"> 
</span><span class="cx"> &lt;SUBSECTION Standard&gt;
</span><span class="cx"> WebKitSettingsClass
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreaImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -177,8 +177,8 @@
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="cx">     // Fixed position elements need to be composited and create stacking contexts
</span><span class="cx">     // in order to be scrolled by the ScrollingCoordinator.
</span><del>-    settings.setAcceleratedCompositingForFixedPositionEnabled(true);
-    settings.setFixedPositionCreatesStackingContext(true);
</del><ins>+    settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled());
+    settings.setFixedPositionCreatesStackingContext(settings.acceleratedCompositingEnabled());
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     m_alwaysUseCompositing = settings.acceleratedCompositingEnabled() &amp;&amp; settings.forceCompositingMode();
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Tools/ChangeLog        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2017-01-30  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add API to handle the accelerated compositing policy
+        https://bugs.webkit.org/show_bug.cgi?id=167509
+
+        Reviewed by Michael Catanzaro.
+
+        Handle new setting in MiniBrowser. The settings dialog doesn't support enum settings so it needs to be handled
+        as a special case. Also add test cases to the get/set API.
+
+        * MiniBrowser/gtk/BrowserSettingsDialog.c:
+        (hardwareAccelerationPolicyToString):
+        (stringToHardwareAccelerationPolicy):
+        (cellRendererChanged):
+        (browserSettingsDialogConstructed):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp:
+        (testWebKitSettings):
+
</ins><span class="cx"> 2017-01-29  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
</span></span></pre></div>
<a id="trunkToolsMiniBrowsergtkBrowserSettingsDialogc"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/gtk/BrowserSettingsDialog.c (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/gtk/BrowserSettingsDialog.c        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Tools/MiniBrowser/gtk/BrowserSettingsDialog.c        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -55,6 +55,34 @@
</span><span class="cx"> 
</span><span class="cx"> G_DEFINE_TYPE(BrowserSettingsDialog, browser_settings_dialog, GTK_TYPE_DIALOG)
</span><span class="cx"> 
</span><ins>+static const char *hardwareAccelerationPolicyToString(WebKitHardwareAccelerationPolicy policy)
+{
+    switch (policy) {
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS:
+        return &quot;always&quot;;
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER:
+        return &quot;never&quot;;
+    case WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND:
+        return &quot;ondemand&quot;;
+    }
+
+    g_assert_not_reached();
+    return &quot;ondemand&quot;;
+}
+
+static int stringToHardwareAccelerationPolicy(const char *policy)
+{
+    if (!g_ascii_strcasecmp(policy, &quot;always&quot;))
+        return WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS;
+    if (!g_ascii_strcasecmp(policy, &quot;never&quot;))
+        return WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER;
+    if (!g_ascii_strcasecmp(policy, &quot;ondemand&quot;))
+        return WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND;
+
+    g_warning(&quot;Invalid value %s for hardware-acceleration-policy setting valid values are always, never and ondemand&quot;, policy);
+    return -1;
+}
+
</ins><span class="cx"> static void cellRendererChanged(GtkCellRenderer *renderer, const char *path, const GValue *value, BrowserSettingsDialog *dialog)
</span><span class="cx"> {
</span><span class="cx">     GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(dialog-&gt;settingsList));
</span><span class="lines">@@ -62,12 +90,21 @@
</span><span class="cx">     GtkTreeIter iter;
</span><span class="cx">     gtk_tree_model_get_iter(model, &amp;iter, treePath);
</span><span class="cx"> 
</span><ins>+    gboolean updateTreeStore = TRUE;
</ins><span class="cx">     char *name;
</span><span class="cx">     gtk_tree_model_get(model, &amp;iter, SETTINGS_LIST_COLUMN_NAME, &amp;name, -1);
</span><del>-    g_object_set_property(G_OBJECT(dialog-&gt;settings), name, value);
</del><ins>+    if (!g_strcmp0(name, &quot;hardware-acceleration-policy&quot;)) {
+        int policy = stringToHardwareAccelerationPolicy(g_value_get_string(value));
+        if (policy != -1)
+            webkit_settings_set_hardware_acceleration_policy(dialog-&gt;settings, policy);
+        else
+            updateTreeStore = FALSE;
+    } else
+        g_object_set_property(G_OBJECT(dialog-&gt;settings), name, value);
</ins><span class="cx">     g_free(name);
</span><span class="cx"> 
</span><del>-    gtk_list_store_set(GTK_LIST_STORE(model), &amp;iter, SETTINGS_LIST_COLUMN_VALUE, value, -1);
</del><ins>+    if (updateTreeStore)
+        gtk_list_store_set(GTK_LIST_STORE(model), &amp;iter, SETTINGS_LIST_COLUMN_VALUE, value, -1);
</ins><span class="cx">     gtk_tree_path_free(treePath);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -134,10 +171,19 @@
</span><span class="cx">         GParamSpec *property = properties[i];
</span><span class="cx">         const char *name = g_param_spec_get_name(property);
</span><span class="cx">         const char *nick = g_param_spec_get_nick(property);
</span><ins>+        char *blurb = g_markup_escape_text(g_param_spec_get_blurb(property), -1);
</ins><span class="cx"> 
</span><span class="cx">         GValue value = { 0, { { 0 } } };
</span><del>-        g_value_init(&amp;value, G_PARAM_SPEC_VALUE_TYPE(property));
-        g_object_get_property(G_OBJECT(settings), name, &amp;value);
</del><ins>+        if (!g_strcmp0(name, &quot;hardware-acceleration-policy&quot;)) {
+            g_value_init(&amp;value, G_TYPE_STRING);
+            g_value_set_string(&amp;value, hardwareAccelerationPolicyToString(webkit_settings_get_hardware_acceleration_policy(settings)));
+            char *extendedBlutb = g_strdup_printf(&quot;%s (always, never or ondemand)&quot;, blurb);
+            g_free(blurb);
+            blurb = extendedBlutb;
+        } else {
+            g_value_init(&amp;value, G_PARAM_SPEC_VALUE_TYPE(property));
+            g_object_get_property(G_OBJECT(settings), name, &amp;value);
+        }
</ins><span class="cx"> 
</span><span class="cx">         GtkAdjustment *adjustment = NULL;
</span><span class="cx">         if (G_PARAM_SPEC_VALUE_TYPE(property) == G_TYPE_UINT) {
</span><span class="lines">@@ -146,7 +192,6 @@
</span><span class="cx">                                             uIntProperty-&gt;maximum, 1, 1, 1);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        char *blurb = g_markup_escape_text(g_param_spec_get_blurb(property), -1);
</del><span class="cx">         GtkTreeIter iter;
</span><span class="cx">         gtk_list_store_append(model, &amp;iter);
</span><span class="cx">         gtk_list_store_set(model, &amp;iter,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp (211362 => 211363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp        2017-01-30 12:07:15 UTC (rev 211362)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp        2017-01-30 13:50:37 UTC (rev 211363)
</span><span class="lines">@@ -285,6 +285,15 @@
</span><span class="cx">     webkit_settings_set_allow_universal_access_from_file_urls(settings, TRUE);
</span><span class="cx">     g_assert(webkit_settings_get_allow_universal_access_from_file_urls(settings));
</span><span class="cx"> 
</span><ins>+    // Ondemand is the default hardware acceleration policy.
+    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
+    webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER);
+    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER);
+    webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS);
+    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS);
+    webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
+    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
+
</ins><span class="cx">     g_object_unref(G_OBJECT(settings));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>