<!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>[197250] releases/WebKitGTK/webkit-2.4/Source/WebCore</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/197250">197250</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-27 07:09:16 -0800 (Sat, 27 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/173110">r173110</a>, <a href="http://trac.webkit.org/projects/webkit/changeset/193896">r193896</a> - [GTK] ScrollbarThemeGtk should not depend on RenderThemeGtk
https://bugs.webkit.org/show_bug.cgi?id=136338

Reviewed by Philippe Normand.

Remove the dependency by creating the GtkStyleContext for the
scrollbars in ScrollbarThemeGtk.

* platform/gtk/RenderThemeGtk.cpp:
(WebCore::gtkStyleChangedCallback): Call ScrollbarThemeGtk::themeChanged().
(WebCore::getStyleContext): Remove the scrollbar style context support.
* platform/gtk/RenderThemeGtk.h: Remove gtkScrollbarStyle().
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarStyleContext::ScrollbarStyleContext): Helper
class to create the global GtkStyleContext for scrollbars.
(WebCore::ScrollbarStyleContext::~ScrollbarStyleContext):
(WebCore::ScrollbarStyleContext::context):
(WebCore::gtkScrollbarStyleContext):
(WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk): Remove m_context initialization.
(WebCore::ScrollbarThemeGtk::themeChanged): Invalidate the
GtkStylecontext and call updateThemeProperties().
(WebCore::ScrollbarThemeGtk::updateThemeProperties): Use the
global style context.
(WebCore::ScrollbarThemeGtk::paintTrackBackground): Ditto.
(WebCore::ScrollbarThemeGtk::paintScrollbarBackground): Ditto.
(WebCore::ScrollbarThemeGtk::paintThumb): Ditto.
(WebCore::ScrollbarThemeGtk::paintButton): Ditto.
* platform/gtk/ScrollbarThemeGtk.h:

[GTK] RenderThemeGtk::platformActiveSelectionBackgroundColor, et. al. should not clobber state of cached GtkStyleContexts
https://bugs.webkit.org/show_bug.cgi?id=151533

Reviewed by Carlos Garcia Campos.

Remove the style context cache to simplify the code, drastically reduce the number of
expensive save/restore operations performed on style contexts, and avoid unwanted
side-effects in RenderThemeGtk::styleColor. This is also a speculative fix for improper
button rendering with certain custom themes, and a simplification that will make it easier
to fix bug #150550.

This change does have performance implications, which I intend to check on the perf bot
after landing to ensure that removing the cache does not have a significant negative impact
on performance; I have no clue whether this will be a net performance win or loss. However,
this is a bit tricky, because the bot is running GTK+ 3.16, whereas I expect save/restore
might be much more expensive in GTK+ 3.20, and I do not want to make performance decisions
except based on the latest GTK+ due to large changes in the implementation of</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgtkRenderThemeGtkh">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk.h</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgtkRenderThemeGtk3cpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgtkScrollbarThemeGtkh">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgtkScrollbarThemeGtk3cpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit24SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (197249 => 197250)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2016-02-27 15:08:56 UTC (rev 197249)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2016-02-27 15:09:16 UTC (rev 197250)
</span><span class="lines">@@ -1,3 +1,80 @@
</span><ins>+2015-12-10  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
+
+        [GTK] RenderThemeGtk::platformActiveSelectionBackgroundColor, et. al. should not clobber state of cached GtkStyleContexts
+        https://bugs.webkit.org/show_bug.cgi?id=151533
+
+        Reviewed by Carlos Garcia Campos.
+
+        Remove the style context cache to simplify the code, drastically reduce the number of
+        expensive save/restore operations performed on style contexts, and avoid unwanted
+        side-effects in RenderThemeGtk::styleColor. This is also a speculative fix for improper
+        button rendering with certain custom themes, and a simplification that will make it easier
+        to fix bug #150550.
+
+        This change does have performance implications, which I intend to check on the perf bot
+        after landing to ensure that removing the cache does not have a significant negative impact
+        on performance; I have no clue whether this will be a net performance win or loss. However,
+        this is a bit tricky, because the bot is running GTK+ 3.16, whereas I expect save/restore
+        might be much more expensive in GTK+ 3.20, and I do not want to make performance decisions
+        except based on the latest GTK+ due to large changes in the implementation of
+        GtkStyleContext.
+
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::createStyleContext):
+        (WebCore::getStockIconForWidgetType):
+        (WebCore::getStockSymbolicIconForWidgetType):
+        (WebCore::RenderThemeGtk::initMediaColors):
+        (WebCore::RenderThemeGtk::adjustRepaintRect):
+        (WebCore::setToggleSize):
+        (WebCore::paintToggle):
+        (WebCore::RenderThemeGtk::setCheckboxSize):
+        (WebCore::RenderThemeGtk::setRadioSize):
+        (WebCore::RenderThemeGtk::paintButton):
+        (WebCore::getComboBoxMetrics):
+        (WebCore::RenderThemeGtk::paintMenuList):
+        (WebCore::RenderThemeGtk::paintTextField):
+        (WebCore::RenderThemeGtk::paintSliderTrack):
+        (WebCore::RenderThemeGtk::paintSliderThumb):
+        (WebCore::RenderThemeGtk::adjustSliderThumbSize):
+        (WebCore::RenderThemeGtk::paintProgressBar):
+        (WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
+        (WebCore::RenderThemeGtk::paintInnerSpinButton):
+        (WebCore::styleColor):
+        (WebCore::gtkStyleChangedCallback): Deleted.
+        (WebCore::styleContextMap): Deleted.
+        (WebCore::getStyleContext): Deleted.
+
+2014-08-29  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] ScrollbarThemeGtk should not depend on RenderThemeGtk
+        https://bugs.webkit.org/show_bug.cgi?id=136338
+
+        Reviewed by Philippe Normand.
+
+        Remove the dependency by creating the GtkStyleContext for the
+        scrollbars in ScrollbarThemeGtk.
+
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::gtkStyleChangedCallback): Call ScrollbarThemeGtk::themeChanged().
+        (WebCore::getStyleContext): Remove the scrollbar style context support.
+        * platform/gtk/RenderThemeGtk.h: Remove gtkScrollbarStyle().
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::ScrollbarStyleContext::ScrollbarStyleContext): Helper
+        class to create the global GtkStyleContext for scrollbars.
+        (WebCore::ScrollbarStyleContext::~ScrollbarStyleContext):
+        (WebCore::ScrollbarStyleContext::context):
+        (WebCore::gtkScrollbarStyleContext):
+        (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk): Remove m_context initialization.
+        (WebCore::ScrollbarThemeGtk::themeChanged): Invalidate the
+        GtkStylecontext and call updateThemeProperties().
+        (WebCore::ScrollbarThemeGtk::updateThemeProperties): Use the
+        global style context.
+        (WebCore::ScrollbarThemeGtk::paintTrackBackground): Ditto.
+        (WebCore::ScrollbarThemeGtk::paintScrollbarBackground): Ditto.
+        (WebCore::ScrollbarThemeGtk::paintThumb): Ditto.
+        (WebCore::ScrollbarThemeGtk::paintButton): Ditto.
+        * platform/gtk/ScrollbarThemeGtk.h:
+
</ins><span class="cx"> 2015-11-21  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Off-by-one error in getStyleContext()
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgtkRenderThemeGtkh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk.h (197249 => 197250)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk.h        2016-02-27 15:08:56 UTC (rev 197249)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk.h        2016-02-27 15:09:16 UTC (rev 197250)
</span><span class="lines">@@ -108,8 +108,6 @@
</span><span class="cx">     GtkWidget* gtkVScrollbar() const;
</span><span class="cx">     GtkWidget* gtkHScrollbar() const;
</span><span class="cx">     static void getIndicatorMetrics(ControlPart, int&amp; indicatorSize, int&amp; indicatorSpacing);
</span><del>-#else
-    GtkStyleContext* gtkScrollbarStyle();
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgtkRenderThemeGtk3cpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (197249 => 197250)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp        2016-02-27 15:08:56 UTC (rev 197249)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp        2016-02-27 15:09:16 UTC (rev 197250)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;PaintInfo.h&quot;
</span><span class="cx"> #include &quot;PlatformContextCairo.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><ins>+#include &quot;ScrollbarThemeGtk.h&quot;
</ins><span class="cx"> #include &quot;TextDirection.h&quot;
</span><span class="cx"> #include &quot;UserAgentStyleSheets.h&quot;
</span><span class="cx"> #include &lt;cmath&gt;
</span><span class="lines">@@ -49,22 +50,14 @@
</span><span class="cx"> // This is the default value defined by GTK+, where it was defined as MIN_ARROW_WIDTH in gtkspinbutton.c.
</span><span class="cx"> static const int minSpinButtonArrowSize = 6;
</span><span class="cx"> 
</span><del>-typedef HashMap&lt;GType, GRefPtr&lt;GtkStyleContext&gt; &gt; StyleContextMap;
-static StyleContextMap&amp; styleContextMap();
-
</del><span class="cx"> static void gtkStyleChangedCallback(GObject*, GParamSpec*)
</span><span class="cx"> {
</span><del>-    StyleContextMap::const_iterator end = styleContextMap().end();
-    for (StyleContextMap::const_iterator iter = styleContextMap().begin(); iter != end; ++iter)
-        gtk_style_context_invalidate(iter-&gt;value.get());
-
</del><ins>+    static_cast&lt;ScrollbarThemeGtk*&gt;(ScrollbarTheme::theme())-&gt;themeChanged();
</ins><span class="cx">     Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static StyleContextMap&amp; styleContextMap()
</del><ins>+static GRefPtr&lt;GtkStyleContext&gt; createStyleContext(GType widgetType)
</ins><span class="cx"> {
</span><del>-    DEFINE_STATIC_LOCAL(StyleContextMap, map, ());
-
</del><span class="cx">     static bool initialized = false;
</span><span class="cx">     if (!initialized) {
</span><span class="cx">         GtkSettings* settings = gtk_settings_get_default();
</span><span class="lines">@@ -72,21 +65,11 @@
</span><span class="cx">         g_signal_connect(settings, &quot;notify::gtk-color-scheme&quot;, G_CALLBACK(gtkStyleChangedCallback), 0);
</span><span class="cx">         initialized = true;
</span><span class="cx">     }
</span><del>-    return map;
-}
</del><span class="cx"> 
</span><del>-static GtkStyleContext* getStyleContext(GType widgetType)
-{
-    StyleContextMap::AddResult result = styleContextMap().add(widgetType, nullptr);
-    if (!result.isNewEntry)
-        return result.iterator-&gt;value.get();
-
</del><span class="cx">     GtkWidgetPath* path = gtk_widget_path_new();
</span><span class="cx">     gtk_widget_path_append_type(path, widgetType);
</span><span class="cx"> 
</span><del>-    if (widgetType == GTK_TYPE_SCROLLBAR)
-        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCROLLBAR);
-    else if (widgetType == GTK_TYPE_ENTRY)
</del><ins>+    if (widgetType == GTK_TYPE_ENTRY)
</ins><span class="cx">         gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
</span><span class="cx">     else if (widgetType == GTK_TYPE_ARROW)
</span><span class="cx">         gtk_widget_path_iter_add_class(path, 0, &quot;arrow&quot;);
</span><span class="lines">@@ -113,15 +96,9 @@
</span><span class="cx">     gtk_style_context_set_path(context.get(), path);
</span><span class="cx">     gtk_widget_path_free(path);
</span><span class="cx"> 
</span><del>-    result.iterator-&gt;value = context;
-    return context.get();
</del><ins>+    return context;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GtkStyleContext* RenderThemeGtk::gtkScrollbarStyle()
-{
-    return getStyleContext(GTK_TYPE_SCROLLBAR);
-}
-
</del><span class="cx"> // This is not a static method, because we want to avoid having GTK+ headers in RenderThemeGtk.h.
</span><span class="cx"> extern GtkTextDirection gtkTextDirection(TextDirection);
</span><span class="cx"> 
</span><span class="lines">@@ -137,21 +114,17 @@
</span><span class="cx"> void RenderThemeGtk::initMediaColors()
</span><span class="cx"> {
</span><span class="cx">     GdkRGBA color;
</span><del>-    GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; containerContext = createStyleContext(GTK_TYPE_CONTAINER);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_save(containerContext);
-
-    gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_NORMAL);
-    gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &amp;color);
</del><ins>+    gtk_style_context_set_state(containerContext.get(), GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color(containerContext.get(), gtk_style_context_get_state(containerContext.get()), &amp;color);
</ins><span class="cx">     m_panelColor = color;
</span><del>-    gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_ACTIVE);
-    gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &amp;color);
</del><ins>+    gtk_style_context_set_state(containerContext.get(), GTK_STATE_FLAG_ACTIVE);
+    gtk_style_context_get_background_color(containerContext.get(), gtk_style_context_get_state(containerContext.get()), &amp;color);
</ins><span class="cx">     m_sliderColor = color;
</span><del>-    gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_SELECTED);
-    gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &amp;color);
</del><ins>+    gtk_style_context_set_state(containerContext.get(), GTK_STATE_FLAG_SELECTED);
+    gtk_style_context_get_background_color(containerContext.get(), gtk_style_context_get_state(containerContext.get()), &amp;color);
</ins><span class="cx">     m_sliderThumbColor = color;
</span><del>-
-    gtk_style_context_restore(containerContext);
</del><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -166,32 +139,32 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderThemeGtk::adjustRepaintRect(const RenderObject* renderObject, IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = 0;
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context;
</ins><span class="cx">     bool checkInteriorFocus = false;
</span><span class="cx">     ControlPart part = renderObject-&gt;style().appearance();
</span><span class="cx">     switch (part) {
</span><span class="cx">     case CheckboxPart:
</span><span class="cx">     case RadioPart:
</span><del>-        context = getStyleContext(part == CheckboxPart ? GTK_TYPE_CHECK_BUTTON : GTK_TYPE_RADIO_BUTTON);
</del><ins>+        context = createStyleContext(part == CheckboxPart ? GTK_TYPE_CHECK_BUTTON : GTK_TYPE_RADIO_BUTTON);
</ins><span class="cx"> 
</span><span class="cx">         gint indicatorSpacing;
</span><del>-        gtk_style_context_get_style(context, &quot;indicator-spacing&quot;, &amp;indicatorSpacing, NULL);
</del><ins>+        gtk_style_context_get_style(context.get(), &quot;indicator-spacing&quot;, &amp;indicatorSpacing, nullptr);
</ins><span class="cx">         rect.inflate(indicatorSpacing);
</span><span class="cx"> 
</span><span class="cx">         return;
</span><span class="cx">     case SliderVerticalPart:
</span><span class="cx">     case SliderHorizontalPart:
</span><del>-        context = getStyleContext(GTK_TYPE_SCALE);
</del><ins>+        context = createStyleContext(GTK_TYPE_SCALE);
</ins><span class="cx">         break;
</span><span class="cx">     case ButtonPart:
</span><span class="cx">     case MenulistButtonPart:
</span><span class="cx">     case MenulistPart:
</span><del>-        context = getStyleContext(GTK_TYPE_BUTTON);
</del><ins>+        context = createStyleContext(GTK_TYPE_BUTTON);
</ins><span class="cx">         checkInteriorFocus = true;
</span><span class="cx">         break;
</span><span class="cx">     case TextFieldPart:
</span><span class="cx">     case TextAreaPart:
</span><del>-        context = getStyleContext(GTK_TYPE_ENTRY);
</del><ins>+        context = createStyleContext(GTK_TYPE_ENTRY);
</ins><span class="cx">         checkInteriorFocus = true;
</span><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="lines">@@ -201,15 +174,17 @@
</span><span class="cx">     ASSERT(context);
</span><span class="cx">     if (checkInteriorFocus) {
</span><span class="cx">         gboolean interiorFocus;
</span><del>-        gtk_style_context_get_style(context, &quot;interior-focus&quot;, &amp;interiorFocus, NULL);
</del><ins>+        gtk_style_context_get_style(context.get(), &quot;interior-focus&quot;, &amp;interiorFocus, nullptr);
</ins><span class="cx">         if (interiorFocus)
</span><span class="cx">             return;
</span><span class="cx">     }
</span><del>-    adjustRectForFocus(context, rect);
</del><ins>+    adjustRectForFocus(context.get(), rect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void setToggleSize(GtkStyleContext* context, RenderStyle* style)
</del><ins>+static void setToggleSize(GType widgetType, RenderStyle&amp; style)
</ins><span class="cx"> {
</span><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(widgetType);
+
</ins><span class="cx">     // The width and height are both specified, so we shouldn't change them.
</span><span class="cx">     if (!style-&gt;width().isIntrinsicOrAuto() &amp;&amp; !style-&gt;height().isAuto())
</span><span class="cx">         return;
</span><span class="lines">@@ -218,7 +193,7 @@
</span><span class="cx">     // GTK+ users tend to demand the native look.
</span><span class="cx">     // It could be made a configuration option values other than 13 actually break site compatibility.
</span><span class="cx">     gint indicatorSize;
</span><del>-    gtk_style_context_get_style(context, &quot;indicator-size&quot;, &amp;indicatorSize, NULL);
</del><ins>+    gtk_style_context_get_style(context.get(), &quot;indicator-size&quot;, &amp;indicatorSize, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     if (style-&gt;width().isIntrinsicOrAuto())
</span><span class="cx">         style-&gt;setWidth(Length(indicatorSize, Fixed));
</span><span class="lines">@@ -229,15 +204,14 @@
</span><span class="cx"> 
</span><span class="cx"> static void paintToggle(const RenderThemeGtk* theme, GType widgetType, RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; fullRect)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(widgetType);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(widgetType);
</ins><span class="cx"> 
</span><span class="cx">     // Some themes do not render large toggle buttons properly, so we simply
</span><span class="cx">     // shrink the rectangle back down to the default size and then center it
</span><span class="cx">     // in the full toggle button region. The reason for not simply forcing toggle
</span><span class="cx">     // buttons to be a smaller size is that we don't want to break site layouts.
</span><span class="cx">     gint indicatorSize;
</span><del>-    gtk_style_context_get_style(context, &quot;indicator-size&quot;, &amp;indicatorSize, NULL);
</del><ins>+    gtk_style_context_get_style(context.get(), &quot;indicator-size&quot;, &amp;indicatorSize, nullptr);
</ins><span class="cx">     IntRect rect(fullRect);
</span><span class="cx">     if (rect.width() &gt; indicatorSize) {
</span><span class="cx">         rect.inflateX(-(rect.width() - indicatorSize) / 2);
</span><span class="lines">@@ -249,8 +223,8 @@
</span><span class="cx">         rect.setHeight(indicatorSize); // In case rect.height() was equal to indicatorSize + 1.
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
-    gtk_style_context_add_class(context, widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
</del><ins>+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
+    gtk_style_context_add_class(context.get(), widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if (!theme-&gt;isEnabled(renderObject) || theme-&gt;isReadOnlyControl(renderObject))
</span><span class="lines">@@ -267,28 +241,26 @@
</span><span class="cx"> #endif
</span><span class="cx">     if (theme-&gt;isPressed(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_SELECTED;
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
</ins><span class="cx"> 
</span><span class="cx">     if (widgetType == GTK_TYPE_CHECK_BUTTON)
</span><del>-        gtk_render_check(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+        gtk_render_check(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx">     else
</span><del>-        gtk_render_option(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+        gtk_render_option(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx"> 
</span><span class="cx">     if (theme-&gt;isFocused(renderObject)) {
</span><span class="cx">         IntRect indicatorRect(rect);
</span><span class="cx">         gint indicatorSpacing;
</span><del>-        gtk_style_context_get_style(context, &quot;indicator-spacing&quot;, &amp;indicatorSpacing, NULL);
</del><ins>+        gtk_style_context_get_style(context.get(), &quot;indicator-spacing&quot;, &amp;indicatorSpacing, nullptr);
</ins><span class="cx">         indicatorRect.inflate(indicatorSpacing);
</span><del>-        gtk_render_focus(context, paintInfo.context-&gt;platformContext()-&gt;cr(), indicatorRect.x(), indicatorRect.y(),
</del><ins>+        gtk_render_focus(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), indicatorRect.x(), indicatorRect.y(),
</ins><span class="cx">                          indicatorRect.width(), indicatorRect.height());
</span><span class="cx">     }
</span><del>-
-    gtk_style_context_restore(context);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const
</span><span class="cx"> {
</span><del>-    setToggleSize(getStyleContext(GTK_TYPE_CHECK_BUTTON), style);
</del><ins>+    setToggleSize(GTK_TYPE_CHECK_BUTTON, style);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderThemeGtk::paintCheckbox(RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; rect)
</span><span class="lines">@@ -299,7 +271,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderThemeGtk::setRadioSize(RenderStyle* style) const
</span><span class="cx"> {
</span><del>-    setToggleSize(getStyleContext(GTK_TYPE_RADIO_BUTTON), style);
</del><ins>+    setToggleSize(GTK_TYPE_RADIO_BUTTON, style);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderThemeGtk::paintRadio(RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; rect)
</span><span class="lines">@@ -376,16 +348,13 @@
</span><span class="cx"> }
</span><span class="cx"> bool RenderThemeGtk::paintButton(RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_BUTTON);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_BUTTON);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
</del><ins>+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
</ins><span class="cx"> 
</span><del>-    renderButton(this, context, renderObject, paintInfo, rect);
</del><ins>+    renderButton(this, context.get(), renderObject, paintInfo, rect);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -396,46 +365,34 @@
</span><span class="cx">     if (style-&gt;appearance() == NoControlPart)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_COMBO_BOX);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_COMBO_BOX);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(style-&gt;direction())));
</del><ins>+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(style-&gt;direction())));
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(0));
-    gtk_style_context_get_border(context, gtk_style_context_get_state(context), &amp;border);
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(0));
+    gtk_style_context_get_border(context.get(), gtk_style_context_get_state(context.get()), &amp;border);
</ins><span class="cx"> 
</span><span class="cx">     gboolean interiorFocus;
</span><span class="cx">     gint focusWidth, focusPad;
</span><del>-    gtk_style_context_get_style(context,
-                                &quot;interior-focus&quot;, &amp;interiorFocus,
-                                &quot;focus-line-width&quot;, &amp;focusWidth,
-                                &quot;focus-padding&quot;, &amp;focusPad, NULL);
</del><ins>+    gtk_style_context_get_style(context.get(), &quot;interior-focus&quot;, &amp;interiorFocus, &quot;focus-line-width&quot;, &amp;focusWidth, &quot;focus-padding&quot;, &amp;focusPad, nullptr);
</ins><span class="cx">     focus = interiorFocus ? focusWidth + focusPad : 0;
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
</del><ins>+    context = createStyleContext(GTK_TYPE_SEPARATOR);
</ins><span class="cx"> 
</span><del>-    context = getStyleContext(GTK_TYPE_SEPARATOR);
-    gtk_style_context_save(context);
-
</del><span class="cx">     GtkTextDirection direction = static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(style-&gt;direction()));
</span><del>-    gtk_style_context_set_direction(context, direction);
-    gtk_style_context_add_class(context, &quot;separator&quot;);
</del><ins>+    gtk_style_context_set_direction(context.get(), direction);
+    gtk_style_context_add_class(context.get(), &quot;separator&quot;);
</ins><span class="cx"> 
</span><span class="cx">     gboolean wideSeparators;
</span><span class="cx">     gint separatorWidth;
</span><del>-    gtk_style_context_get_style(context,
-                                &quot;wide-separators&quot;, &amp;wideSeparators,
-                                &quot;separator-width&quot;, &amp;separatorWidth,
-                                NULL);
</del><ins>+    gtk_style_context_get_style(context.get(), &quot;wide-separators&quot;, &amp;wideSeparators, &quot;separator-width&quot;, &amp;separatorWidth, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     // GTK+ always uses border.left, regardless of text direction. See gtkseperator.c.
</span><span class="cx">     if (!wideSeparators)
</span><span class="cx">         separatorWidth = border.left;
</span><span class="cx"> 
</span><span class="cx">     separator = separatorWidth;
</span><del>-
-    gtk_style_context_restore(context);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle* style) const
</span><span class="lines">@@ -482,29 +439,24 @@
</span><span class="cx">     GtkTextDirection direction = static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction()));
</span><span class="cx"> 
</span><span class="cx">     // Paint the button.
</span><del>-    GtkStyleContext* buttonStyleContext = getStyleContext(GTK_TYPE_BUTTON);
-    gtk_style_context_save(buttonStyleContext);
-    gtk_style_context_set_direction(buttonStyleContext, direction);
-    gtk_style_context_add_class(buttonStyleContext, GTK_STYLE_CLASS_BUTTON);
-    renderButton(this, buttonStyleContext, renderObject, paintInfo, rect);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; buttonStyleContext = createStyleContext(GTK_TYPE_BUTTON);
+    gtk_style_context_set_direction(buttonStyleContext.get(), direction);
+    gtk_style_context_add_class(buttonStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
+    renderButton(this, buttonStyleContext.get(), renderObject, paintInfo, rect);
</ins><span class="cx"> 
</span><span class="cx">     // Get the inner rectangle.
</span><span class="cx">     gint focusWidth, focusPad;
</span><span class="cx">     GtkBorder* innerBorderPtr = 0;
</span><span class="cx">     GtkBorder innerBorder = { 1, 1, 1, 1 };
</span><del>-    gtk_style_context_get_style(buttonStyleContext,
-                                &quot;inner-border&quot;, &amp;innerBorderPtr,
-                                &quot;focus-line-width&quot;, &amp;focusWidth,
-                                &quot;focus-padding&quot;, &amp;focusPad,
-                                NULL);
</del><ins>+    gtk_style_context_get_style(buttonStyleContext.get(), &quot;inner-border&quot;, &amp;innerBorderPtr, &quot;focus-line-width&quot;, &amp;focusWidth, &quot;focus-padding&quot;, &amp;focusPad, nullptr);
</ins><span class="cx">     if (innerBorderPtr) {
</span><span class="cx">         innerBorder = *innerBorderPtr;
</span><span class="cx">         gtk_border_free(innerBorderPtr);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     GtkBorder borderWidth;
</span><del>-    GtkStateFlags state = gtk_style_context_get_state(buttonStyleContext);
-    gtk_style_context_get_border(buttonStyleContext, state, &amp;borderWidth);
</del><ins>+    GtkStateFlags state = gtk_style_context_get_state(buttonStyleContext.get());
+    gtk_style_context_get_border(buttonStyleContext.get(), state, &amp;borderWidth);
</ins><span class="cx"> 
</span><span class="cx">     focusWidth += focusPad;
</span><span class="cx">     IntRect innerRect(rect.x() + innerBorder.left + borderWidth.left + focusWidth,
</span><span class="lines">@@ -515,27 +467,21 @@
</span><span class="cx">     if (isPressed(renderObject)) {
</span><span class="cx">         gint childDisplacementX;
</span><span class="cx">         gint childDisplacementY;
</span><del>-        gtk_style_context_get_style(buttonStyleContext,
-                                    &quot;child-displacement-x&quot;, &amp;childDisplacementX,
-                                    &quot;child-displacement-y&quot;, &amp;childDisplacementY,
-                                    NULL);
</del><ins>+        gtk_style_context_get_style(buttonStyleContext.get(), &quot;child-displacement-x&quot;, &amp;childDisplacementX, &quot;child-displacement-y&quot;, &amp;childDisplacementY, nullptr);
</ins><span class="cx">         innerRect.move(childDisplacementX, childDisplacementY);
</span><span class="cx">     }
</span><span class="cx">     innerRect.setWidth(std::max(1, innerRect.width()));
</span><span class="cx">     innerRect.setHeight(std::max(1, innerRect.height()));
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(buttonStyleContext);
-
</del><span class="cx">     // Paint the arrow.
</span><del>-    GtkStyleContext* arrowStyleContext = getStyleContext(GTK_TYPE_ARROW);
-    gtk_style_context_save(arrowStyleContext);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; arrowStyleContext = createStyleContext(GTK_TYPE_ARROW);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(arrowStyleContext, direction);
-    gtk_style_context_add_class(arrowStyleContext, &quot;arrow&quot;);
-    gtk_style_context_add_class(arrowStyleContext, GTK_STYLE_CLASS_BUTTON);
</del><ins>+    gtk_style_context_set_direction(arrowStyleContext.get(), direction);
+    gtk_style_context_add_class(arrowStyleContext.get(), &quot;arrow&quot;);
+    gtk_style_context_add_class(arrowStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
</ins><span class="cx"> 
</span><span class="cx">     gfloat arrowScaling;
</span><del>-    gtk_style_context_get_style(arrowStyleContext, &quot;arrow-scaling&quot;, &amp;arrowScaling, NULL);
</del><ins>+    gtk_style_context_get_style(arrowStyleContext.get(), &quot;arrow-scaling&quot;, &amp;arrowScaling, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     IntSize arrowSize(minArrowSize, innerRect.height());
</span><span class="cx">     FloatPoint arrowPosition(innerRect.location());
</span><span class="lines">@@ -547,30 +493,22 @@
</span><span class="cx">     gint extent = std::min(arrowSize.width(), arrowSize.height()) * arrowScaling;
</span><span class="cx">     arrowPosition.move((arrowSize.width() - extent) / 2, (arrowSize.height() - extent) / 2);
</span><span class="cx"> 
</span><del>-    gtk_style_context_set_state(arrowStyleContext, state);
-    gtk_render_arrow(arrowStyleContext, cairoContext, G_PI, arrowPosition.x(), arrowPosition.y(), extent);
</del><ins>+    gtk_style_context_set_state(arrowStyleContext.get(), state);
+    gtk_render_arrow(arrowStyleContext.get(), cairoContext, G_PI, arrowPosition.x(), arrowPosition.y(), extent);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(arrowStyleContext);
-
</del><span class="cx">     // Paint the separator if needed.
</span><del>-    GtkStyleContext* separatorStyleContext = getStyleContext(GTK_TYPE_COMBO_BOX);
-    gtk_style_context_save(separatorStyleContext);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; separatorStyleContext = createStyleContext(GTK_TYPE_COMBO_BOX);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(separatorStyleContext, direction);
-    gtk_style_context_add_class(separatorStyleContext, &quot;separator&quot;);
</del><ins>+    gtk_style_context_set_direction(separatorStyleContext.get(), direction);
+    gtk_style_context_add_class(separatorStyleContext.get(), &quot;separator&quot;);
</ins><span class="cx"> 
</span><span class="cx">     gboolean wideSeparators;
</span><span class="cx">     gint separatorWidth;
</span><del>-    gtk_style_context_get_style(separatorStyleContext,
-                                &quot;wide-separators&quot;, &amp;wideSeparators,
-                                &quot;separator-width&quot;, &amp;separatorWidth,
-                                NULL);
-    if (wideSeparators &amp;&amp; !separatorWidth) {
-        gtk_style_context_restore(separatorStyleContext);
</del><ins>+    gtk_style_context_get_style(separatorStyleContext.get(), &quot;wide-separators&quot;, &amp;wideSeparators, &quot;separator-width&quot;, &amp;separatorWidth, nullptr);
+    if (wideSeparators &amp;&amp; !separatorWidth)
</ins><span class="cx">         return false;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    gtk_style_context_set_state(separatorStyleContext, state);
</del><ins>+    gtk_style_context_set_state(separatorStyleContext.get(), state);
</ins><span class="cx">     IntPoint separatorPosition(arrowPosition.x(), innerRect.y());
</span><span class="cx">     if (wideSeparators) {
</span><span class="cx">         if (direction == GTK_TEXT_DIR_LTR)
</span><span class="lines">@@ -578,14 +516,12 @@
</span><span class="cx">         else
</span><span class="cx">             separatorPosition.move(arrowSize.width(), 0);
</span><span class="cx"> 
</span><del>-        gtk_render_frame(separatorStyleContext, cairoContext,
-                         separatorPosition.x(), separatorPosition.y(),
-                         separatorWidth, innerRect.height());
</del><ins>+        gtk_render_frame(separatorStyleContext.get(), cairoContext, separatorPosition.x(), separatorPosition.y(), separatorWidth, innerRect.height());
</ins><span class="cx">     } else {
</span><span class="cx">         GtkBorder padding;
</span><del>-        gtk_style_context_get_padding(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &amp;padding);
</del><ins>+        gtk_style_context_get_padding(separatorStyleContext.get(), gtk_style_context_get_state(separatorStyleContext.get()), &amp;padding);
</ins><span class="cx">         GtkBorder border;
</span><del>-        gtk_style_context_get_border(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &amp;border);
</del><ins>+        gtk_style_context_get_border(separatorStyleContext.get(), gtk_style_context_get_state(separatorStyleContext.get()), &amp;border);
</ins><span class="cx"> 
</span><span class="cx">         if (direction == GTK_TEXT_DIR_LTR)
</span><span class="cx">             separatorPosition.move(-(padding.left + border.left), 0);
</span><span class="lines">@@ -597,52 +533,41 @@
</span><span class="cx">         // An extra clip prevents the separator bleeding outside of the specified rectangle because of subpixel positioning.
</span><span class="cx">         cairo_rectangle(cairoContext, separatorPosition.x(), separatorPosition.y(), border.left, innerRect.height());
</span><span class="cx">         cairo_clip(cairoContext);
</span><del>-        gtk_render_line(separatorStyleContext, cairoContext,
-                        separatorPosition.x(), separatorPosition.y(),
-                        separatorPosition.x(), innerRect.maxY());
</del><ins>+        gtk_render_line(separatorStyleContext.get(), cairoContext, separatorPosition.x(), separatorPosition.y(), separatorPosition.x(), innerRect.maxY());
</ins><span class="cx">         cairo_restore(cairoContext);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(separatorStyleContext);
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderThemeGtk::paintTextField(RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_ENTRY);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_ENTRY);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY);
</del><ins>+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction())));
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_ENTRY);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_INSENSITIVE;
</span><span class="cx">     else if (isFocused(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_FOCUSED;
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
</ins><span class="cx"> 
</span><del>-    gtk_render_background(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
-    gtk_render_frame(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+    gtk_render_background(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx"> 
</span><span class="cx">     if (isFocused(renderObject) &amp;&amp; isEnabled(renderObject)) {
</span><span class="cx">         gboolean interiorFocus;
</span><span class="cx">         gint focusWidth, focusPad;
</span><del>-        gtk_style_context_get_style(context,
-                                    &quot;interior-focus&quot;, &amp;interiorFocus,
-                                    &quot;focus-line-width&quot;, &amp;focusWidth,
-                                    &quot;focus-padding&quot;, &amp;focusPad,
-                                    NULL);
</del><ins>+        gtk_style_context_get_style(context.get(), &quot;interior-focus&quot;, &amp;interiorFocus, &quot;focus-line-width&quot;, &amp;focusWidth, &quot;focus-padding&quot;, &amp;focusPad, nullptr);
</ins><span class="cx">         if (!interiorFocus) {
</span><span class="cx">             IntRect focusRect(rect);
</span><span class="cx">             focusRect.inflate(focusWidth + focusPad);
</span><del>-            gtk_render_focus(context, paintInfo.context-&gt;platformContext()-&gt;cr(),
-                             focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
</del><ins>+            gtk_render_focus(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -660,33 +585,26 @@
</span><span class="cx">     ControlPart part = renderObject-&gt;style().appearance();
</span><span class="cx">     ASSERT_UNUSED(part, part == SliderHorizontalPart || part == SliderVerticalPart || part == MediaVolumeSliderPart);
</span><span class="cx"> 
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_SCALE);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(context, gtkTextDirection(renderObject-&gt;style().direction()));
-    applySliderStyleContextClasses(context, part);
-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
</del><ins>+    gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject-&gt;style().direction()));
+    applySliderStyleContextClasses(context.get(), part);
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
</ins><span class="cx"> 
</span><span class="cx">     if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
</span><del>-        gtk_style_context_set_state(context, GTK_STATE_FLAG_INSENSITIVE);
</del><ins>+        gtk_style_context_set_state(context.get(), GTK_STATE_FLAG_INSENSITIVE);
</ins><span class="cx"> 
</span><del>-    gtk_render_background(context, paintInfo.context-&gt;platformContext()-&gt;cr(),
-                          rect.x(), rect.y(), rect.width(), rect.height());
-    gtk_render_frame(context, paintInfo.context-&gt;platformContext()-&gt;cr(),
-                     rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+    gtk_render_background(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx"> 
</span><span class="cx">     if (isFocused(renderObject)) {
</span><span class="cx">         gint focusWidth, focusPad;
</span><del>-        gtk_style_context_get_style(context,
-                                    &quot;focus-line-width&quot;, &amp;focusWidth,
-                                    &quot;focus-padding&quot;, &amp;focusPad, NULL);
</del><ins>+        gtk_style_context_get_style(context.get(), &quot;focus-line-width&quot;, &amp;focusWidth, &quot;focus-padding&quot;, &amp;focusPad, nullptr);
</ins><span class="cx">         IntRect focusRect(rect);
</span><span class="cx">         focusRect.inflate(focusWidth + focusPad);
</span><del>-        gtk_render_focus(context, paintInfo.context-&gt;platformContext()-&gt;cr(),
-                         focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
</del><ins>+        gtk_render_focus(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -695,12 +613,11 @@
</span><span class="cx">     ControlPart part = renderObject-&gt;style().appearance();
</span><span class="cx">     ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
</span><span class="cx"> 
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_SCALE);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_direction(context, gtkTextDirection(renderObject-&gt;style().direction()));
-    applySliderStyleContextClasses(context, part);
-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_SLIDER);
</del><ins>+    gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject-&gt;style().direction()));
+    applySliderStyleContextClasses(context.get(), part);
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_SLIDER);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
</span><span class="lines">@@ -709,13 +626,11 @@
</span><span class="cx">         flags |= GTK_STATE_FLAG_PRELIGHT;
</span><span class="cx">     if (isPressed(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_ACTIVE;
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
</ins><span class="cx"> 
</span><del>-    gtk_render_slider(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height(),
-                      part == SliderThumbHorizontalPart ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
</del><ins>+    gtk_render_slider(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height(),
+        part == SliderThumbHorizontalPart ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -725,11 +640,9 @@
</span><span class="cx">     if (part != SliderThumbHorizontalPart &amp;&amp; part != SliderThumbVerticalPart)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_SCALE);
</ins><span class="cx">     gint sliderWidth, sliderLength;
</span><del>-    gtk_style_context_get_style(getStyleContext(GTK_TYPE_SCALE),
-                                &quot;slider-width&quot;, &amp;sliderWidth,
-                                &quot;slider-length&quot;, &amp;sliderLength,
-                                NULL);
</del><ins>+    gtk_style_context_get_style(context.get(), &quot;slider-width&quot;, &amp;sliderWidth, &quot;slider-length&quot;, &amp;sliderLength, nullptr);
</ins><span class="cx">     if (part == SliderThumbHorizontalPart) {
</span><span class="cx">         style-&gt;setWidth(Length(sliderLength, Fixed));
</span><span class="cx">         style-&gt;setHeight(Length(sliderWidth, Fixed));
</span><span class="lines">@@ -746,23 +659,21 @@
</span><span class="cx">     if (!renderObject-&gt;isProgress())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_PROGRESS_BAR);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_PROGRESS_BAR);
+    gtk_style_context_save(context.get());
</ins><span class="cx"> 
</span><del>-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
</del><ins>+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
</ins><span class="cx"> 
</span><del>-    gtk_render_background(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
-    gtk_render_frame(context, paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+    gtk_render_background(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
</del><ins>+    gtk_style_context_restore(context.get());
</ins><span class="cx"> 
</span><del>-    gtk_style_context_save(context);
-    gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
</del><ins>+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR);
+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(0));
</ins><span class="cx"> 
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(0));
-
</del><span class="cx">     GtkBorder padding;
</span><del>-    gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &amp;padding);
</del><ins>+    gtk_style_context_get_padding(context.get(), gtk_style_context_get_state(context.get()), &amp;padding);
</ins><span class="cx">     IntRect progressRect(rect.x() + padding.left, rect.y() + padding.top,
</span><span class="cx">                          rect.width() - (padding.left + padding.right),
</span><span class="cx">                          rect.height() - (padding.top + padding.bottom));
</span><span class="lines">@@ -770,13 +681,13 @@
</span><span class="cx"> 
</span><span class="cx">     if (!progressRect.isEmpty()) {
</span><span class="cx"> #if GTK_CHECK_VERSION(3, 13, 7)
</span><del>-        gtk_render_background(context, paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
-        gtk_render_frame(context, paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
</del><ins>+        gtk_render_background(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
+        gtk_render_frame(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
</ins><span class="cx"> #else
</span><del>-        gtk_render_activity(context, paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
</del><ins>+        gtk_render_activity(context.get(), paintInfo.context-&gt;platformContext()-&gt;cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
</ins><span class="cx"> #endif
</span><span class="cx">     }
</span><del>-    gtk_style_context_restore(context);
</del><ins>+
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -794,12 +705,12 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle* style, Element*) const
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_SPIN_BUTTON);
</ins><span class="cx"> 
</span><span class="cx">     GtkBorder padding;
</span><del>-    gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &amp;padding);
</del><ins>+    gtk_style_context_get_padding(context.get(), gtk_style_context_get_state(context.get()), &amp;padding);
</ins><span class="cx"> 
</span><del>-    int width = spinButtonArrowSize(context) + padding.left + padding.right;
</del><ins>+    int width = spinButtonArrowSize(context.get()) + padding.left + padding.right;
</ins><span class="cx">     style-&gt;setWidth(Length(width, Fixed));
</span><span class="cx">     style-&gt;setMinWidth(Length(width, Fixed));
</span><span class="cx"> }
</span><span class="lines">@@ -872,74 +783,63 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderThemeGtk::paintInnerSpinButton(RenderObject* renderObject, const PaintInfo&amp; paintInfo, const IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
-    gtk_style_context_save(context);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(GTK_TYPE_SPIN_BUTTON);
</ins><span class="cx"> 
</span><span class="cx">     GtkTextDirection direction = static_cast&lt;GtkTextDirection&gt;(gtkTextDirection(renderObject-&gt;style().direction()));
</span><del>-    gtk_style_context_set_direction(context, direction);
</del><ins>+    gtk_style_context_set_direction(context.get(), direction);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_INSENSITIVE;
</span><span class="cx">     else if (isFocused(renderObject))
</span><span class="cx">         flags |= GTK_STATE_FLAG_FOCUSED;
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
-    gtk_style_context_remove_class(context, GTK_STYLE_CLASS_ENTRY);
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
+    gtk_style_context_remove_class(context.get(), GTK_STYLE_CLASS_ENTRY);
</ins><span class="cx"> 
</span><del>-    paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_UP);
-    paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_DOWN);
</del><ins>+    paintSpinArrowButton(this, context.get(), renderObject, paintInfo, rect, GTK_ARROW_UP);
+    paintSpinArrowButton(this, context.get(), renderObject, paintInfo, rect, GTK_ARROW_DOWN);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GRefPtr&lt;GdkPixbuf&gt; getStockIconForWidgetType(GType widgetType, const char* iconName, gint direction, gint state, gint iconSize)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(widgetType);
-    GtkIconSet* iconSet = gtk_style_context_lookup_icon_set(context, iconName);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(widgetType);
+    GtkIconSet* iconSet = gtk_style_context_lookup_icon_set(context.get(), iconName);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_save(context);
-
</del><span class="cx">     guint flags = 0;
</span><span class="cx">     if (state == GTK_STATE_PRELIGHT)
</span><span class="cx">         flags |= GTK_STATE_FLAG_PRELIGHT;
</span><span class="cx">     else if (state == GTK_STATE_INSENSITIVE)
</span><span class="cx">         flags |= GTK_STATE_FLAG_INSENSITIVE;
</span><span class="cx"> 
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(direction));
-    GdkPixbuf* icon = gtk_icon_set_render_icon_pixbuf(iconSet, context, static_cast&lt;GtkIconSize&gt;(iconSize));
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(direction));
+    GdkPixbuf* icon = gtk_icon_set_render_icon_pixbuf(iconSet, context.get(), static_cast&lt;GtkIconSize&gt;(iconSize));
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     return adoptGRef(icon);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GRefPtr&lt;GdkPixbuf&gt; getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char *fallbackStockIconName, gint direction, gint state, gint iconSize)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(widgetType);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(widgetType);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_save(context);
-
</del><span class="cx">     guint flags = 0;
</span><span class="cx">     if (state == GTK_STATE_PRELIGHT)
</span><span class="cx">         flags |= GTK_STATE_FLAG_PRELIGHT;
</span><span class="cx">     else if (state == GTK_STATE_INSENSITIVE)
</span><span class="cx">         flags |= GTK_STATE_FLAG_INSENSITIVE;
</span><span class="cx"> 
</span><del>-    gtk_style_context_set_state(context, static_cast&lt;GtkStateFlags&gt;(flags));
-    gtk_style_context_set_direction(context, static_cast&lt;GtkTextDirection&gt;(direction));
</del><ins>+    gtk_style_context_set_state(context.get(), static_cast&lt;GtkStateFlags&gt;(flags));
+    gtk_style_context_set_direction(context.get(), static_cast&lt;GtkTextDirection&gt;(direction));
</ins><span class="cx">     GtkIconInfo* info = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), symbolicIconName, iconSize,
</span><span class="cx">         static_cast&lt;GtkIconLookupFlags&gt;(GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_FORCE_SIZE));
</span><span class="cx">     GdkPixbuf* icon = 0;
</span><span class="cx">     if (info) {
</span><del>-        icon = gtk_icon_info_load_symbolic_for_context(info, context, 0, 0);
</del><ins>+        icon = gtk_icon_info_load_symbolic_for_context(info, context.get(), nullptr, nullptr);
</ins><span class="cx">         gtk_icon_info_free(info);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(context);
-
</del><span class="cx">     if (!icon)
</span><span class="cx">         return getStockIconForWidgetType(widgetType, fallbackStockIconName, direction, state, iconSize);
</span><span class="cx"> 
</span><span class="lines">@@ -950,15 +850,15 @@
</span><span class="cx"> 
</span><span class="cx"> static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
</span><span class="cx"> {
</span><del>-    GtkStyleContext* context = getStyleContext(widgetType);
</del><ins>+    GRefPtr&lt;GtkStyleContext&gt; context = createStyleContext(widgetType);
</ins><span class="cx">     // Recent GTK+ versions (&gt; 3.14) require to explicitly set the state before getting the color.
</span><del>-    gtk_style_context_set_state(context, state);
</del><ins>+    gtk_style_context_set_state(context.get(), state);
</ins><span class="cx"> 
</span><span class="cx">     GdkRGBA gdkRGBAColor;
</span><span class="cx">     if (colorType == StyleColorBackground)
</span><del>-        gtk_style_context_get_background_color(context, gtk_style_context_get_state(context), &amp;gdkRGBAColor);
</del><ins>+        gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &amp;gdkRGBAColor);
</ins><span class="cx">     else
</span><del>-        gtk_style_context_get_color(context, gtk_style_context_get_state(context), &amp;gdkRGBAColor);
</del><ins>+        gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &amp;gdkRGBAColor);
</ins><span class="cx">     return gdkRGBAColor;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgtkScrollbarThemeGtkh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h (197249 => 197250)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h        2016-02-27 15:08:56 UTC (rev 197249)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h        2016-02-27 15:09:16 UTC (rev 197250)
</span><span class="lines">@@ -56,15 +56,20 @@
</span><span class="cx">     // TODO: These are the default GTK+ values. At some point we should pull these from the theme itself.
</span><span class="cx">     virtual double initialAutoscrollTimerDelay() { return 0.20; }
</span><span class="cx">     virtual double autoscrollTimerDelay() { return 0.02; }
</span><ins>+#ifdef GTK_API_VERSION_2
</ins><span class="cx">     void updateThemeProperties();
</span><ins>+#else
+    void themeChanged();
+#endif
</ins><span class="cx">     void updateScrollbarsFrameThickness();
</span><span class="cx">     void registerScrollbar(ScrollbarThemeClient*);
</span><span class="cx">     void unregisterScrollbar(ScrollbarThemeClient*);
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx"> #ifndef GTK_API_VERSION_2
</span><del>-    GtkStyleContext* m_context;
</del><ins>+    void updateThemeProperties();
</ins><span class="cx"> #endif
</span><ins>+
</ins><span class="cx">     int m_thumbFatness;
</span><span class="cx">     int m_troughBorderWidth;
</span><span class="cx">     int m_stepperSize;
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgtkScrollbarThemeGtk3cpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp (197249 => 197250)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp        2016-02-27 15:08:56 UTC (rev 197249)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp        2016-02-27 15:09:16 UTC (rev 197250)
</span><span class="lines">@@ -30,39 +30,68 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformContextCairo.h&quot;
</span><span class="cx"> #include &quot;PlatformMouseEvent.h&quot;
</span><del>-#include &quot;RenderThemeGtk.h&quot;
</del><span class="cx"> #include &quot;ScrollView.h&quot;
</span><span class="cx"> #include &quot;Scrollbar.h&quot;
</span><span class="cx"> #include &lt;gtk/gtk.h&gt;
</span><ins>+#include &lt;wtf/gobject/GRefPtr.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static void gtkStyleChangedCallback(GtkWidget*, ScrollbarThemeGtk* scrollbarTheme)
</del><ins>+class ScrollbarStyleContext {
+    WTF_MAKE_NONCOPYABLE(ScrollbarStyleContext); WTF_MAKE_FAST_ALLOCATED;
+public:
+    ScrollbarStyleContext()
+        : m_context(adoptGRef(gtk_style_context_new()))
+    {
+        GtkWidgetPath* path = gtk_widget_path_new();
+        gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR);
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCROLLBAR);
+        gtk_style_context_set_path(m_context.get(), path);
+        gtk_widget_path_free(path);
+    }
+
+    ~ScrollbarStyleContext()
+    {
+    }
+
+    GtkStyleContext* context() const { return m_context.get(); }
+
+private:
+    GRefPtr&lt;GtkStyleContext&gt; m_context;
+};
+
+static GtkStyleContext* gtkScrollbarStyleContext()
</ins><span class="cx"> {
</span><del>-    scrollbarTheme-&gt;updateThemeProperties();
</del><ins>+    DEFINE_STATIC_LOCAL(ScrollbarStyleContext, styleContext, ());
+    return styleContext.context();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ScrollbarThemeGtk::themeChanged()
+{
+    gtk_style_context_invalidate(gtkScrollbarStyleContext());
+    updateThemeProperties();
+}
+
</ins><span class="cx"> ScrollbarThemeGtk::ScrollbarThemeGtk()
</span><del>-    : m_context(static_cast&lt;RenderThemeGtk*&gt;(RenderTheme::defaultTheme().get())-&gt;gtkScrollbarStyle())
</del><span class="cx"> {
</span><span class="cx">     updateThemeProperties();
</span><del>-    g_signal_connect(m_context, &quot;changed&quot;, G_CALLBACK(gtkStyleChangedCallback), this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollbarThemeGtk::updateThemeProperties()
</span><span class="cx"> {
</span><del>-    gtk_style_context_get_style(m_context,
-                                &quot;min-slider-length&quot;, &amp;m_minThumbLength,
-                                &quot;slider-width&quot;, &amp;m_thumbFatness,
-                                &quot;trough-border&quot;, &amp;m_troughBorderWidth,
-                                &quot;stepper-size&quot;, &amp;m_stepperSize,
-                                &quot;stepper-spacing&quot;, &amp;m_stepperSpacing,
-                                &quot;trough-under-steppers&quot;, &amp;m_troughUnderSteppers,
-                                &quot;has-backward-stepper&quot;, &amp;m_hasBackButtonStartPart,
-                                &quot;has-forward-stepper&quot;, &amp;m_hasForwardButtonEndPart,
-                                &quot;has-secondary-backward-stepper&quot;, &amp;m_hasBackButtonEndPart,
-                                &quot;has-secondary-forward-stepper&quot;, &amp;m_hasForwardButtonStartPart,
-                                NULL);
</del><ins>+    gtk_style_context_get_style(
+        gtkScrollbarStyleContext(),
+        &quot;min-slider-length&quot;, &amp;m_minThumbLength,
+        &quot;slider-width&quot;, &amp;m_thumbFatness,
+        &quot;trough-border&quot;, &amp;m_troughBorderWidth,
+        &quot;stepper-size&quot;, &amp;m_stepperSize,
+        &quot;stepper-spacing&quot;, &amp;m_stepperSpacing,
+        &quot;trough-under-steppers&quot;, &amp;m_troughUnderSteppers,
+        &quot;has-backward-stepper&quot;, &amp;m_hasBackButtonStartPart,
+        &quot;has-forward-stepper&quot;, &amp;m_hasForwardButtonEndPart,
+        &quot;has-secondary-backward-stepper&quot;, &amp;m_hasBackButtonEndPart,
+        &quot;has-secondary-forward-stepper&quot;, &amp;m_hasForwardButtonStartPart,
+        nullptr);
</ins><span class="cx">     updateScrollbarsFrameThickness();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -90,60 +119,62 @@
</span><span class="cx">     if (m_troughUnderSteppers)
</span><span class="cx">         fullScrollbarRect = IntRect(scrollbar-&gt;x(), scrollbar-&gt;y(), scrollbar-&gt;width(), scrollbar-&gt;height());
</span><span class="cx"> 
</span><del>-    gtk_style_context_save(m_context);
</del><ins>+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
</ins><span class="cx"> 
</span><del>-    applyScrollbarStyleContextClasses(m_context, scrollbar-&gt;orientation());
-    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_TROUGH);
</del><ins>+    applyScrollbarStyleContextClasses(styleContext, scrollbar-&gt;orientation());
+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH);
</ins><span class="cx"> 
</span><del>-    adjustRectAccordingToMargin(m_context, static_cast&lt;GtkStateFlags&gt;(0), fullScrollbarRect);
-    gtk_render_background(m_context, context-&gt;platformContext()-&gt;cr(),
-                          fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
-    gtk_render_frame(m_context, context-&gt;platformContext()-&gt;cr(),
-                     fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
</del><ins>+    adjustRectAccordingToMargin(styleContext, static_cast&lt;GtkStateFlags&gt;(0), fullScrollbarRect);
+    gtk_render_background(styleContext, context-&gt;platformContext()-&gt;cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+    gtk_render_frame(styleContext, context-&gt;platformContext()-&gt;cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(m_context);
</del><ins>+    gtk_style_context_restore(styleContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
</span><span class="cx"> {
</span><del>-    gtk_style_context_save(m_context);
</del><ins>+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
</ins><span class="cx"> 
</span><del>-    applyScrollbarStyleContextClasses(m_context, scrollbar-&gt;orientation());
-    gtk_style_context_add_class(m_context, &quot;scrolled-window&quot;);
-    gtk_render_frame(m_context, context-&gt;platformContext()-&gt;cr(), scrollbar-&gt;x(), scrollbar-&gt;y(), scrollbar-&gt;width(), scrollbar-&gt;height());
</del><ins>+    applyScrollbarStyleContextClasses(styleContext, scrollbar-&gt;orientation());
+    gtk_style_context_add_class(styleContext, &quot;scrolled-window&quot;);
+    gtk_render_frame(styleContext, context-&gt;platformContext()-&gt;cr(), scrollbar-&gt;x(), scrollbar-&gt;y(), scrollbar-&gt;width(), scrollbar-&gt;height());
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(m_context);
</del><ins>+    gtk_style_context_restore(styleContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    gtk_style_context_save(m_context);
</del><ins>+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
</ins><span class="cx"> 
</span><span class="cx">     ScrollbarOrientation orientation = scrollbar-&gt;orientation();
</span><del>-    applyScrollbarStyleContextClasses(m_context, orientation);
-    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SLIDER);
</del><ins>+    applyScrollbarStyleContextClasses(styleContext, orientation);
+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if (scrollbar-&gt;pressedPart() == ThumbPart)
</span><span class="cx">         flags |= GTK_STATE_FLAG_ACTIVE;
</span><span class="cx">     if (scrollbar-&gt;hoveredPart() == ThumbPart)
</span><span class="cx">         flags |= GTK_STATE_FLAG_PRELIGHT;
</span><del>-    gtk_style_context_set_state(m_context, static_cast&lt;GtkStateFlags&gt;(flags));
</del><ins>+    gtk_style_context_set_state(styleContext, static_cast&lt;GtkStateFlags&gt;(flags));
</ins><span class="cx"> 
</span><span class="cx">     IntRect thumbRect(rect);
</span><del>-    adjustRectAccordingToMargin(m_context, static_cast&lt;GtkStateFlags&gt;(flags), thumbRect);
-    gtk_render_slider(m_context, context-&gt;platformContext()-&gt;cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
</del><ins>+    adjustRectAccordingToMargin(styleContext, static_cast&lt;GtkStateFlags&gt;(flags), thumbRect);
+    gtk_render_slider(styleContext, context-&gt;platformContext()-&gt;cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
</ins><span class="cx">         orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
</span><span class="cx"> 
</span><del>-    gtk_style_context_restore(m_context);
</del><ins>+    gtk_style_context_restore(styleContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollbarThemeGtk::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect&amp; rect, ScrollbarPart part)
</span><span class="cx"> {
</span><del>-    gtk_style_context_save(m_context);
</del><ins>+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
</ins><span class="cx"> 
</span><span class="cx">     ScrollbarOrientation orientation = scrollbar-&gt;orientation();
</span><del>-    applyScrollbarStyleContextClasses(m_context, orientation);
</del><ins>+    applyScrollbarStyleContextClasses(styleContext, orientation);
</ins><span class="cx"> 
</span><span class="cx">     guint flags = 0;
</span><span class="cx">     if ((BackButtonStartPart == part &amp;&amp; scrollbar-&gt;currentPos())
</span><span class="lines">@@ -156,14 +187,14 @@
</span><span class="cx">             flags |= GTK_STATE_FLAG_PRELIGHT;
</span><span class="cx">     } else
</span><span class="cx">         flags |= GTK_STATE_FLAG_INSENSITIVE;
</span><del>-    gtk_style_context_set_state(m_context, static_cast&lt;GtkStateFlags&gt;(flags));
</del><ins>+    gtk_style_context_set_state(styleContext, static_cast&lt;GtkStateFlags&gt;(flags));
</ins><span class="cx"> 
</span><del>-    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_BUTTON);
-    gtk_render_background(m_context, context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
-    gtk_render_frame(m_context, context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</del><ins>+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BUTTON);
+    gtk_render_background(styleContext, context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(styleContext, context-&gt;platformContext()-&gt;cr(), rect.x(), rect.y(), rect.width(), rect.height());
</ins><span class="cx"> 
</span><span class="cx">     gfloat arrowScaling;
</span><del>-    gtk_style_context_get_style(m_context, &quot;arrow-scaling&quot;, &amp;arrowScaling, NULL);
</del><ins>+    gtk_style_context_get_style(styleContext, &quot;arrow-scaling&quot;, &amp;arrowScaling, NULL);
</ins><span class="cx"> 
</span><span class="cx">     double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
</span><span class="cx">     FloatPoint arrowPoint(rect.x() + (rect.width() - arrowSize) / 2,
</span><span class="lines">@@ -171,10 +202,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (flags &amp; GTK_STATE_FLAG_ACTIVE) {
</span><span class="cx">         gint arrowDisplacementX, arrowDisplacementY;
</span><del>-        gtk_style_context_get_style(m_context,
-                                    &quot;arrow-displacement-x&quot;, &amp;arrowDisplacementX,
-                                    &quot;arrow-displacement-y&quot;, &amp;arrowDisplacementY,
-                                    NULL);
</del><ins>+        gtk_style_context_get_style(styleContext, &quot;arrow-displacement-x&quot;, &amp;arrowDisplacementX, &quot;arrow-displacement-y&quot;, &amp;arrowDisplacementY, nullptr);
</ins><span class="cx">         arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -185,9 +213,9 @@
</span><span class="cx">         angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gtk_render_arrow(m_context, context-&gt;platformContext()-&gt;cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
</del><ins>+    gtk_render_arrow(styleContext, context-&gt;platformContext()-&gt;cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
</ins><span class="cx"> 
</span><del>-    gtk_style_context_restore(m_context);
</del><ins>+    gtk_style_context_restore(styleContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>