bug 1362170 force a style resolution on context creation to set GTK 3.4 theming_engine r=stransky+263117
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 14 Dec 2016 19:22:28 +1300
changeset 356988 81977c96c6ff49e4b70f88a55f38d47f5e54a08b
parent 356987 4c79f09831e75cabc6837dd391184b7a9932df24
child 357002 1fda52a1f3b81cf1a821155998dca637bb64e3d9
child 357050 cba5c15d4c9885d1a0a01594edff8a154efd5c37
push id31777
push usercbook@mozilla.com
push dateMon, 08 May 2017 08:04:08 +0000
treeherdermozilla-central@81977c96c6ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1362170, 263117
milestone55.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 1362170 force a style resolution on context creation to set GTK 3.4 theming_engine r=stransky+263117 This works around a GTK bug that led to the default engine being used instead for the first draw. MozReview-Commit-ID: 4r48HNUgVBE
widget/gtk/WidgetStyleCache.cpp
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -709,16 +709,31 @@ CreateCSSNode(const char* aName, GtkStyl
     (*sGtkWidgetPathIterSetObjectName)(path, -1, aName);
   }
 
   GtkStyleContext *context = gtk_style_context_new();
   gtk_style_context_set_path(context, path);
   gtk_style_context_set_parent(context, aParentStyle);
   gtk_widget_path_unref(path);
 
+  // In GTK 3.4, gtk_render_* functions use |theming_engine| on the style
+  // context without ensuring any style resolution sets it appropriately
+  // in style_data_lookup(). e.g.
+  // https://git.gnome.org/browse/gtk+/tree/gtk/gtkstylecontext.c?h=3.4.4#n3847
+  //
+  // That can result in incorrect drawing on first draw.  To work around this,
+  // force a style look-up to set |theming_engine|.  It is sufficient to do
+  // this only on context creation, instead of after every modification to the
+  // context, because themes typically (Ambiance and oxygen-gtk, at least) set
+  // the "engine" property with the '*' selector.
+  if (GTK_MAJOR_VERSION == 3 && gtk_get_minor_version() < 6) {
+    GdkRGBA unused;
+    gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &unused);
+  }
+
   return context;
 }
 
 // Return a style context matching that of the root CSS node of a widget.
 // This is used by all GTK versions.
 static GtkStyleContext*
 GetWidgetRootStyle(WidgetNodeType aNodeType)
 {