bug 1365556 invalidate widget style contexts after their ancestors are set r=stransky+263117
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 01 Aug 2017 09:17:46 +1200
changeset 373160 96777f4f483e77572640f671bf64a24f734488f9
parent 373159 7a722d0827fbfeebb31a6242f04ba3ec033cb08a
child 373161 80648a32ef3659138dd58146f681178b1a85dd58
push id48124
push userktomlinson@mozilla.com
push dateMon, 07 Aug 2017 03:54:31 +0000
treeherderautoland@96777f4f483e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1365556, 263117
milestone57.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 1365556 invalidate widget style contexts after their ancestors are set r=stransky+263117 Although this is only known to affect buttons with builtin child widgets, it is difficult to audit all GTK widgets for similar situations, and so the same defense is applied to all widgets. MozReview-Commit-ID: LMVXX3UYqR9
widget/gtk/WidgetStyleCache.cpp
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -617,16 +617,30 @@ CreateWidget(WidgetNodeType aWidgetType)
 }
 
 GtkWidget*
 GetWidget(WidgetNodeType aWidgetType)
 {
   GtkWidget* widget = sWidgetStorage[aWidgetType];
   if (!widget) {
     widget = CreateWidget(aWidgetType);
+    // In GTK versions prior to 3.18, automatic invalidation of style contexts
+    // for widgets was delayed until the next resize event.  Gecko however,
+    // typically uses the style context before the resize event runs and so an
+    // explicit invalidation may be required.  This is necessary if a style
+    // property was retrieved before all changes were made to the style
+    // context.  One such situation is where gtk_button_construct_child()
+    // retrieves the style property "image-spacing" during construction of the
+    // GtkButton, before its parent is set to provide inheritance of ancestor
+    // properties.  More recent GTK versions do not need this, but do not
+    // re-resolve until required and so invalidation does not trigger
+    // unnecessary resolution in general.
+    GtkStyleContext* style = gtk_widget_get_style_context(widget);
+    gtk_style_context_invalidate(style);
+
     sWidgetStorage[aWidgetType] = widget;
   }
   return widget;
 }
 
 static void
 AddStyleClassesFromStyle(GtkStyleContext* aDest, GtkStyleContext* aSrc)
 {