summaryrefslogtreecommitdiff
path: root/mozilla-1158076-2.patch
blob: 2999b1fe337fd6151b48378e90f95d98e33c3436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
bgstack15