bug 1343802 update notebook_has_tab_gap and scrollbar metrics after theme changes r?jhorak draft
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 21 Mar 2017 17:27:41 +1300
changeset 503434 3a02aff5a74a4f217b332ec08085e78bdbf287ce
parent 503433 232d59d66b51a3d09bb5563ad2e080a2e35a2410
child 503435 b6c60aa5be6fe3f1c84b897aed40df3260f465aa
push id50576
push userktomlinson@mozilla.com
push dateThu, 23 Mar 2017 06:19:17 +0000
reviewersjhorak
bugs1343802
milestone55.0a1
bug 1343802 update notebook_has_tab_gap and scrollbar metrics after theme changes r?jhorak MozReview-Commit-ID: IRPXNwLe5Ey
widget/gtk/gtk3drawing.cpp
widget/gtk/gtkdrawing.h
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -80,30 +80,39 @@ gint
 moz_gtk_init()
 {
     if (gtk_major_version > 3 ||
        (gtk_major_version == 3 && gtk_minor_version >= 14))
         checkbox_check_state = GTK_STATE_FLAG_CHECKED;
     else
         checkbox_check_state = GTK_STATE_FLAG_ACTIVE;
 
+    moz_gtk_refresh();
+
+    return MOZ_GTK_SUCCESS;
+}
+
+void
+moz_gtk_refresh()
+{
     if (gtk_check_version(3, 12, 0) == nullptr &&
         gtk_check_version(3, 20, 0) != nullptr)
     {
         // Deprecated for Gtk >= 3.20+
         GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TAB_TOP);
         gtk_style_context_get_style(style,
                                     "has-tab-gap", &notebook_has_tab_gap, NULL);
         ReleaseStyleContext(style);
     }
     else {
         notebook_has_tab_gap = true;
     }
 
-    return MOZ_GTK_SUCCESS;
+    sScrollbarMetrics[GTK_ORIENTATION_HORIZONTAL].initialized = false;
+    sScrollbarMetrics[GTK_ORIENTATION_VERTICAL].initialized = false;
 }
 
 gint
 moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing)
 {
     gtk_widget_style_get(GetWidget(MOZ_GTK_CHECKBUTTON_CONTAINER),
                          "indicator_size", indicator_size,
                          "indicator_spacing", indicator_spacing,
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -284,16 +284,21 @@ typedef enum {
  * prior to using any other functionality.
  * returns: MOZ_GTK_SUCCESS if there were no errors
  *          MOZ_GTK_UNSAFE_THEME if the current theme engine is known
  *                               to crash with gtkdrawing.
  */
 gint moz_gtk_init();
 
 /**
+ * Updates the drawing library when the theme changes.
+ */
+void moz_gtk_refresh();
+
+/**
  * Perform cleanup of the drawing library. You should call this function
  * when your program exits, or you no longer need the library.
  *
  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
  */
 gint moz_gtk_shutdown();
 
 #if (MOZ_WIDGET_GTK == 2)
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1440,16 +1440,17 @@ nsLookAndFeel::GetPasswordCharacterImpl(
 {
     return sInvisibleCharacter;
 }
 
 void
 nsLookAndFeel::RefreshImpl()
 {
     nsXPLookAndFeel::RefreshImpl();
+    moz_gtk_refresh();
 
     mDefaultFontCached = false;
     mButtonFontCached = false;
     mFieldFontCached = false;
     mMenuFontCached = false;
 
 #if (MOZ_WIDGET_GTK == 2)
     g_object_unref(mStyle);