bug 1272194 only add menubar class to menu items with GTK 3.4 r=stransky+263117
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 17 May 2016 18:02:00 +1200
changeset 298229 3909bcf5501b7ee54ba3252a6a32044d22ea4207
parent 298228 5299d183263bcc5465ab76fa9de2c0c8ea7a1d49
child 298230 764650604afd8277b6bd58cb2100c7aa52e5ccba
push id77078
push userktomlinson@mozilla.com
push dateSat, 21 May 2016 00:08:02 +0000
treeherdermozilla-inbound@53e791a65fa2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1272194, 263117
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1272194 only add menubar class to menu items with GTK 3.4 r=stransky+263117 and save/restore context consistent with GTK 3.4. MozReview-Commit-ID: GdMoAmzOJlf
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -2468,35 +2468,42 @@ moz_gtk_menu_item_paint(WidgetNodeType w
             ensure_menu_bar_item_widget();
             item_widget = gMenuBarItemWidget;
         } else {
             ensure_menu_item_widget();
             item_widget = gMenuItemWidget;
         }
         style = gtk_widget_get_style_context(item_widget);
 
-        if (widget == MOZ_GTK_MENUBARITEM) {
-            gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
+        bool pre_3_6 = gtk_check_version(3, 6, 0) != nullptr;
+        if (pre_3_6) {
+            // GTK+ 3.4 saves the style context and adds the menubar class to
+            // menubar children, but does each of these only when drawing, not
+            // during layout.
+            gtk_style_context_save(style);
+            if (widget == MOZ_GTK_MENUBARITEM) {
+                gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
+            }
         }
 
         gtk_widget_set_direction(item_widget, direction);
         gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
 
         border_width = gtk_container_get_border_width(GTK_CONTAINER(item_widget));
 
         x = rect->x + border_width;
         y = rect->y + border_width;
         w = rect->width - border_width * 2;
         h = rect->height - border_width * 2;
 
         gtk_render_background(style, cr, x, y, w, h);
         gtk_render_frame(style, cr, x, y, w, h);
 
-        if (widget == MOZ_GTK_MENUBARITEM) {
-            gtk_style_context_remove_class(style, GTK_STYLE_CLASS_MENUBAR);
+        if (pre_3_6) {
+            gtk_style_context_restore(style);
         }
         gtk_style_context_set_state(style, GTK_STATE_FLAG_NORMAL);
     }
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint