bug 1272194 only add menubar class to menu items with GTK 3.4 r=stransky
and save/restore context consistent with GTK 3.4.
MozReview-Commit-ID: GdMoAmzOJlf
--- 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