Bug 1290048 - Remove gtk_style_context_set_state/gtk_style_context_set_direction after ClaimStyleContext() call. r=acomminos
authorMartin Stransky <stransky@redhat.com>
Thu, 28 Jul 2016 04:13:00 -0400
changeset 332345 5ad44f0d3ea46981d77e10563fe5c868384bfdc4
parent 332344 3776797b6c7154191ebd774005c01ad8bb2e654c
child 332346 61c513b90c50559092a853e365ed50be7af6addd
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersacomminos
bugs1290048
milestone50.0a1
Bug 1290048 - Remove gtk_style_context_set_state/gtk_style_context_set_direction after ClaimStyleContext() call. r=acomminos
widget/gtk/WidgetStyleCache.cpp
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -1,19 +1,14 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* TODO:
-    - implement GtkTextDirection
-    - implement StyleFlags
-*/
-
 #include <dlfcn.h>
 #include <gtk/gtk.h>
 #include "WidgetStyleCache.h"
 #include "gtkdrawing.h"
 
 static GtkWidget* sWidgetStorage[MOZ_GTK_WIDGET_NODE_COUNT];
 static GtkStyleContext* sStyleStorage[MOZ_GTK_WIDGET_NODE_COUNT];
 
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -655,27 +655,25 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
     width = indicator_size;
     height = indicator_size;
 
     focus_x = x - indicator_spacing;
     focus_y = y - indicator_spacing;
     focus_width = width + 2 * indicator_spacing;
     focus_height = height + 2 * indicator_spacing;
 
-    style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOBUTTON :
-                                        MOZ_GTK_CHECKBUTTON);
-
     if (selected)
         state_flags = static_cast<GtkStateFlags>(state_flags|checkbox_check_state);
 
     if (inconsistent)
         state_flags = static_cast<GtkStateFlags>(state_flags|GTK_STATE_FLAG_INCONSISTENT);
 
-    gtk_style_context_set_state(style, state_flags);
-    gtk_style_context_set_direction(style, direction);
+    style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOBUTTON :
+                                        MOZ_GTK_CHECKBUTTON,
+                              direction, state_flags);
 
     if (gtk_check_version(3, 20, 0) == nullptr) {
         gtk_render_background(style, cr, x, y, width, height);
         gtk_render_frame(style, cr, x, y, width, height);
     }
 
     if (isradio) {
         gtk_render_option(style, cr, x, y, width, height);
@@ -1488,22 +1486,19 @@ moz_gtk_combo_box_entry_button_paint(cai
 }
 
 static gint
 moz_gtk_container_paint(cairo_t *cr, GdkRectangle* rect,
                         GtkWidgetState* state, 
                         WidgetNodeType  widget_type,
                         GtkTextDirection direction)
 {
-    GtkStyleContext* style = ClaimStyleContext(widget_type);
     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
-
-    gtk_style_context_set_state(style, state_flags);
-    gtk_style_context_set_direction(style, direction);
-
+    GtkStyleContext* style = ClaimStyleContext(widget_type, direction,
+                                               state_flags);
     /* this is for drawing a prelight box */
     if (state_flags & GTK_STATE_FLAG_PRELIGHT) {
         gtk_render_background(style, cr,
                               rect->x, rect->y, rect->width, rect->height);
     }
 
     ReleaseStyleContext(style);
 
@@ -1513,23 +1508,21 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
 static gint
 moz_gtk_toggle_label_paint(cairo_t *cr, GdkRectangle* rect,
                            GtkWidgetState* state, 
                            gboolean isradio, GtkTextDirection direction)
 {
     if (!state->focused)
         return MOZ_GTK_SUCCESS;
 
-    GtkStyleContext *style = ClaimStyleContext(isradio ?
-                                               MOZ_GTK_RADIOBUTTON_CONTAINER :
-                                               MOZ_GTK_CHECKBUTTON_CONTAINER);
-
-    gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
-    gtk_style_context_set_direction(style, direction);
-
+    GtkStyleContext *style =
+        ClaimStyleContext(isradio ? MOZ_GTK_RADIOBUTTON_CONTAINER :
+                                    MOZ_GTK_CHECKBUTTON_CONTAINER,
+                          direction,
+                          GetStateFlagsFromGtkWidgetState(state));
     gtk_render_focus(style, cr,
                     rect->x, rect->y, rect->width, rect->height);
 
     ReleaseStyleContext(style);
 
     return MOZ_GTK_SUCCESS;
 }