Blob Blame History Raw
diff -up firefox-53.0/widget/gtk/nsLookAndFeel.cpp.1158076-2 firefox-53.0/widget/gtk/nsLookAndFeel.cpp
--- firefox-53.0/widget/gtk/nsLookAndFeel.cpp.1158076-2	2017-04-18 13:09:01.756315856 +0200
+++ firefox-53.0/widget/gtk/nsLookAndFeel.cpp	2017-04-18 13:10:10.615069083 +0200
@@ -49,9 +49,9 @@ nsLookAndFeel::nsLookAndFeel()
       mStyle(nullptr),
 #endif
       mDefaultFontCached(false), mButtonFontCached(false),
-      mFieldFontCached(false), mMenuFontCached(false)
+      mFieldFontCached(false), mMenuFontCached(false),
+      mInitialized(false)
 {
-    Init();    
 }
 
 nsLookAndFeel::~nsLookAndFeel()
@@ -223,6 +223,8 @@ GetBorderColors(GtkStyleContext* aContex
 nsresult
 nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
 {
+    EnsureInit();
+
 #if (MOZ_WIDGET_GTK == 3)
     GdkRGBA gdk_color;
 #endif
@@ -674,6 +676,11 @@ nsLookAndFeel::GetIntImpl(IntID aID, int
         return res;
     res = NS_OK;
 
+    // We use delayed initialization by EnsureInit() here
+    // to make sure mozilla::Preferences is available (Bug 115807).
+    // eIntID_UseAccessibilityTheme is requested before user preferences
+    // are read, and so EnsureInit(), which depends on preference values,
+    // is deliberately delayed until required.
     switch (aID) {
     case eIntID_CaretBlinkTime:
         {
@@ -836,6 +843,7 @@ nsLookAndFeel::GetIntImpl(IntID aID, int
         aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
         break;
     case eIntID_MenuBarDrag:
+        EnsureInit();
         aResult = sMenuSupportsDrag;
         break;
     case eIntID_ScrollbarButtonAutoRepeatBehavior:
@@ -876,6 +884,7 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
         aResult = 1.0f;
         break;
     case eFloatID_CaretAspectRatio:
+        EnsureInit();
         aResult = sCaretRatio;
         break;
     default:
@@ -1056,11 +1065,15 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
 }
 
 void
-nsLookAndFeel::Init()
+nsLookAndFeel::EnsureInit()
 {
     GdkColor colorValue;
     GdkColor *colorValuePtr;
 
+    if (mInitialized)
+        return;
+    mInitialized = true;
+
 #if (MOZ_WIDGET_GTK == 2)
     NS_ASSERTION(!mStyle, "already initialized");
     // GtkInvisibles come with a refcount that is not floating
@@ -1451,6 +1464,7 @@ nsLookAndFeel::Init()
 char16_t
 nsLookAndFeel::GetPasswordCharacterImpl()
 {
+    EnsureInit();
     return sInvisibleCharacter;
 }
 
@@ -1469,7 +1483,7 @@ nsLookAndFeel::RefreshImpl()
     mStyle = nullptr;
 #endif
 
-    Init();
+    mInitialized = false;
 }
 
 bool
diff -up firefox-53.0/widget/gtk/nsLookAndFeel.h.1158076-2 firefox-53.0/widget/gtk/nsLookAndFeel.h
--- firefox-53.0/widget/gtk/nsLookAndFeel.h.1158076-2	2017-04-11 06:15:20.000000000 +0200
+++ firefox-53.0/widget/gtk/nsLookAndFeel.h	2017-04-18 13:09:01.759315845 +0200
@@ -81,8 +81,9 @@ protected:
     char16_t sInvisibleCharacter;
     float   sCaretRatio;
     bool    sMenuSupportsDrag;
+    bool    mInitialized;
 
-    void Init();
+    void EnsureInit();
 };
 
 #endif