Title: [192723] trunk/Source/WebCore
Revision
192723
Author
mcatanz...@igalia.com
Date
2015-11-21 08:57:47 -0800 (Sat, 21 Nov 2015)

Log Message

[GTK] Warning spam from GtkStyleContext
https://bugs.webkit.org/show_bug.cgi?id=151520

Reviewed by Carlos Garcia Campos.

Audit every use of gtk_style_context_get_* to fix compatibility with GTK+ 3.19. Some of
these were already fine and are only changed for clarity.

Company:  gtk_style_context_get() (and _get_padding/border/color()) should only ever be
          called with the same state as gtk_style_context_get_state()
Company:  usually that's a simple replacing of the old state (like in the trace you posted)
Company:  sometimes it requires calling gtk_style_context_set_sate() with the right state
          first
Company:  and in very rare cases it needs a gtk_style_context_save() before the set_state(),
          too

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::adjustRectAccordingToMargin):
* rendering/RenderThemeGtk.cpp:
(gtk_css_section_print):
(WebCore::getStyleContext):
(WebCore::RenderThemeGtk::initMediaColors):
(WebCore::renderButton):
(WebCore::getComboBoxMetrics):
(WebCore::RenderThemeGtk::paintMenuList):
(WebCore::RenderThemeGtk::paintTextField):
(WebCore::RenderThemeGtk::paintProgressBar):
(WebCore::spinButtonArrowSize):
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
(WebCore::styleColor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (192722 => 192723)


--- trunk/Source/WebCore/ChangeLog	2015-11-21 06:07:40 UTC (rev 192722)
+++ trunk/Source/WebCore/ChangeLog	2015-11-21 16:57:47 UTC (rev 192723)
@@ -1,3 +1,36 @@
+2015-11-21  Michael Catanzaro  <mcatanz...@igalia.com>
+
+        [GTK] Warning spam from GtkStyleContext
+        https://bugs.webkit.org/show_bug.cgi?id=151520
+
+        Reviewed by Carlos Garcia Campos.
+
+        Audit every use of gtk_style_context_get_* to fix compatibility with GTK+ 3.19. Some of
+        these were already fine and are only changed for clarity.
+
+        Company:  gtk_style_context_get() (and _get_padding/border/color()) should only ever be
+                  called with the same state as gtk_style_context_get_state()
+        Company:  usually that's a simple replacing of the old state (like in the trace you posted)
+        Company:  sometimes it requires calling gtk_style_context_set_sate() with the right state
+                  first
+        Company:  and in very rare cases it needs a gtk_style_context_save() before the set_state(),
+                  too
+
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::adjustRectAccordingToMargin):
+        * rendering/RenderThemeGtk.cpp:
+        (gtk_css_section_print):
+        (WebCore::getStyleContext):
+        (WebCore::RenderThemeGtk::initMediaColors):
+        (WebCore::renderButton):
+        (WebCore::getComboBoxMetrics):
+        (WebCore::RenderThemeGtk::paintMenuList):
+        (WebCore::RenderThemeGtk::paintTextField):
+        (WebCore::RenderThemeGtk::paintProgressBar):
+        (WebCore::spinButtonArrowSize):
+        (WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
+        (WebCore::styleColor):
+
 2015-11-20  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: After versionchange transactions complete, fire onsuccess on the original IDBOpenDBRequest

Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (192722 => 192723)


--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2015-11-21 06:07:40 UTC (rev 192722)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2015-11-21 16:57:47 UTC (rev 192723)
@@ -281,7 +281,8 @@
 static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
 {
     GtkBorder margin;
-    gtk_style_context_get_margin(context, state, &margin);
+    gtk_style_context_set_state(context, state);
+    gtk_style_context_get_margin(context, gtk_style_context_get_state(context), &margin);
     rect.move(margin.left, margin.right);
     rect.contract(margin.left + margin.right, margin.top + margin.bottom);
 }

Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (192722 => 192723)


--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2015-11-21 06:07:40 UTC (rev 192722)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2015-11-21 16:57:47 UTC (rev 192723)
@@ -273,12 +273,19 @@
     GdkRGBA color;
     GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);
 
-    gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_NORMAL, &color);
+    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), &color);
     m_panelColor = color;
-    gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_ACTIVE, &color);
+    gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_ACTIVE);
+    gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
     m_sliderColor = color;
-    gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_SELECTED, &color);
+    gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_SELECTED);
+    gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
     m_sliderThumbColor = color;
+
+    gtk_style_context_restore(containerContext);
 }
 
 void RenderThemeGtk::initMediaButtons()
@@ -610,7 +617,7 @@
 
         if (interiorFocus) {
             GtkBorder borderWidth;
-            gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
+            gtk_style_context_get_border(context, gtk_style_context_get_state(context), &borderWidth);
 
             buttonRect = IntRect(
                 buttonRect.x() + borderWidth.left + focusPad,
@@ -672,7 +679,8 @@
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
     gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
 
-    gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &border);
+    gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));
+    gtk_style_context_get_border(context, gtk_style_context_get_state(context), &border);
 
     gboolean interiorFocus;
     gint focusWidth, focusPad;
@@ -838,9 +846,9 @@
         gtk_render_frame(separatorStyleContext, cairoContext, separatorPosition.x(), separatorPosition.y(), separatorWidth, innerRect.height());
     } else {
         GtkBorder padding;
-        gtk_style_context_get_padding(separatorStyleContext, state, &padding);
+        gtk_style_context_get_padding(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &padding);
         GtkBorder border;
-        gtk_style_context_get_border(separatorStyleContext, state, &border);
+        gtk_style_context_get_border(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &border);
 
         if (direction == GTK_TEXT_DIR_LTR)
             separatorPosition.move(-(padding.left + border.left), 0);
@@ -1184,10 +1192,10 @@
 
     gtk_style_context_save(context);
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
+    gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));
 
-
     GtkBorder padding;
-    gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
+    gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);
     IntRect progressRect(
         rect.x() + padding.left,
         rect.y() + padding.top,
@@ -1211,7 +1219,7 @@
 static gint spinButtonArrowSize(GtkStyleContext* context)
 {
     PangoFontDescription* fontDescription;
-    gtk_style_context_get(context, static_cast<GtkStateFlags>(0), "font", &fontDescription, nullptr);
+    gtk_style_context_get(context, gtk_style_context_get_state(context), "font", &fontDescription, nullptr);
     gint fontSize = pango_font_description_get_size(fontDescription);
     gint arrowSize = std::max(PANGO_PIXELS(fontSize), minSpinButtonArrowSize);
     pango_font_description_free(fontDescription);
@@ -1224,7 +1232,7 @@
     GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
 
     GtkBorder padding;
-    gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
+    gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);
 
     int width = spinButtonArrowSize(context) + padding.left + padding.right;
     style.setWidth(Length(width, Fixed));
@@ -1347,9 +1355,9 @@
 
     GdkRGBA gdkRGBAColor;
     if (colorType == StyleColorBackground)
-        gtk_style_context_get_background_color(context, state, &gdkRGBAColor);
+        gtk_style_context_get_background_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
     else
-        gtk_style_context_get_color(context, state, &gdkRGBAColor);
+        gtk_style_context_get_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
     return gdkRGBAColor;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to