bug 1324886 with GTK versions < 3.8 draw menuitem background and frame only when in hover and not a separator r=stransky+263117
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 04 Jan 2017 09:57:48 +1300
changeset 328483 678233880a0fa57811e4a1965ddaea17e6912c32
parent 328482 3cb6640378eae57e141c06c721054b67b49b983d
child 328484 8197af1f32d1842721e7b033e5795cc0ca2f1768
push id31174
push usercbook@mozilla.com
push dateMon, 09 Jan 2017 09:32:17 +0000
treeherdermozilla-central@97896f92f196 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1324886, 263117
milestone53.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 1324886 with GTK versions < 3.8 draw menuitem background and frame only when in hover and not a separator r=stransky+263117 MozReview-Commit-ID: JdZbuXRbP9X
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -1808,22 +1808,28 @@ moz_gtk_menu_separator_paint(cairo_t *cr
 }
 
 // See gtk_menu_item_draw() for reference.
 static gint
 moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect,
                         GtkWidgetState* state, GtkTextDirection direction)
 {
     gint x, y, w, h;
+    guint minorVersion = gtk_get_minor_version();
+    GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
 
-    GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+    // GTK versions prior to 3.8 render the background and frame only when not
+    // a separator and in hover prelight.
+    if (minorVersion < 8 && (widget == MOZ_GTK_MENUSEPARATOR ||
+                             !(state_flags & GTK_STATE_FLAG_PRELIGHT)))
+        return MOZ_GTK_SUCCESS;
+
     GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags);
 
-    bool pre_3_6 = gtk_check_version(3, 6, 0) != nullptr;
-    if (pre_3_6) {
+    if (minorVersion < 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);
         }
     }
@@ -1831,17 +1837,17 @@ moz_gtk_menu_item_paint(WidgetNodeType w
     x = rect->x;
     y = rect->y;
     w = rect->width;
     h = rect->height;
 
     gtk_render_background(style, cr, x, y, w, h);
     gtk_render_frame(style, cr, x, y, w, h);
 
-    if (pre_3_6) {
+    if (minorVersion < 6) {
         gtk_style_context_restore(style);
     }
     ReleaseStyleContext(style);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint