Bug 1535790 - Initialize members in nsLookAndFeel, and bail out when there's no screen settings. r=stransky

A patch of mine starts calling nsLookAndFeel from xpcshell tests, which makes
gtk crash eventually.

Differential Revision: https://phabricator.services.mozilla.com/D23759

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-03-16 15:17:49 +00:00
Родитель 11cbaa0ead
Коммит bfed43b178
2 изменённых файлов: 55 добавлений и 53 удалений

Просмотреть файл

@ -48,13 +48,7 @@ using mozilla::LookAndFeel;
# define GTK_STATE_FLAG_LINK (static_cast<GtkStateFlags>(1 << 9)) # define GTK_STATE_FLAG_LINK (static_cast<GtkStateFlags>(1 << 9))
#endif #endif
nsLookAndFeel::nsLookAndFeel() nsLookAndFeel::nsLookAndFeel() = default;
: nsXPLookAndFeel(),
mDefaultFontCached(false),
mButtonFontCached(false),
mFieldFontCached(false),
mMenuFontCached(false),
mInitialized(false) {}
nsLookAndFeel::~nsLookAndFeel() {} nsLookAndFeel::~nsLookAndFeel() {}
@ -866,6 +860,11 @@ void nsLookAndFeel::EnsureInit() {
// with wrong color theme, see Bug 972382 // with wrong color theme, see Bug 972382
GtkSettings* settings = gtk_settings_get_for_screen(gdk_screen_get_default()); GtkSettings* settings = gtk_settings_get_for_screen(gdk_screen_get_default());
if (MOZ_UNLIKELY(!settings)) {
NS_WARNING("EnsureInit: No settings");
return;
}
// Dark themes interacts poorly with widget styling (see bug 1216658). // Dark themes interacts poorly with widget styling (see bug 1216658).
// We disable dark themes by default for all processes (chrome, web content) // We disable dark themes by default for all processes (chrome, web content)
// but allow user to overide it by prefs. // but allow user to overide it by prefs.

Просмотреть файл

@ -33,12 +33,15 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
bool IsCSDAvailable() const { return mCSDAvailable; } bool IsCSDAvailable() const { return mCSDAvailable; }
static const nscolor kBlack = NS_RGB(0, 0, 0);
static const nscolor kWhite = NS_RGB(255, 255, 255);
protected: protected:
// Cached fonts // Cached fonts
bool mDefaultFontCached; bool mDefaultFontCached = false;
bool mButtonFontCached; bool mButtonFontCached = false;
bool mFieldFontCached; bool mFieldFontCached = false;
bool mMenuFontCached; bool mMenuFontCached = false;
nsString mDefaultFontName; nsString mDefaultFontName;
nsString mButtonFontName; nsString mButtonFontName;
nsString mFieldFontName; nsString mFieldFontName;
@ -49,48 +52,48 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
gfxFontStyle mMenuFontStyle; gfxFontStyle mMenuFontStyle;
// Cached colors // Cached colors
nscolor mInfoBackground; nscolor mInfoBackground = kWhite;
nscolor mInfoText; nscolor mInfoText = kBlack;
nscolor mMenuBackground; nscolor mMenuBackground = kWhite;
nscolor mMenuBarText; nscolor mMenuBarText = kBlack;
nscolor mMenuBarHoverText; nscolor mMenuBarHoverText = kBlack;
nscolor mMenuText; nscolor mMenuText = kBlack;
nscolor mMenuTextInactive; nscolor mMenuTextInactive = kWhite;
nscolor mMenuHover; nscolor mMenuHover = kWhite;
nscolor mMenuHoverText; nscolor mMenuHoverText = kBlack;
nscolor mButtonDefault; nscolor mButtonDefault = kWhite;
nscolor mButtonText; nscolor mButtonText = kBlack;
nscolor mButtonHoverText; nscolor mButtonHoverText = kBlack;
nscolor mButtonHoverFace; nscolor mButtonHoverFace = kWhite;
nscolor mFrameOuterLightBorder; nscolor mFrameOuterLightBorder = kBlack;
nscolor mFrameInnerDarkBorder; nscolor mFrameInnerDarkBorder = kBlack;
nscolor mOddCellBackground; nscolor mOddCellBackground = kWhite;
nscolor mNativeHyperLinkText; nscolor mNativeHyperLinkText = kBlack;
nscolor mComboBoxText; nscolor mComboBoxText = kBlack;
nscolor mComboBoxBackground; nscolor mComboBoxBackground = kWhite;
nscolor mMozFieldText; nscolor mMozFieldText = kBlack;
nscolor mMozFieldBackground; nscolor mMozFieldBackground = kWhite;
nscolor mMozWindowText; nscolor mMozWindowText = kBlack;
nscolor mMozWindowBackground; nscolor mMozWindowBackground = kWhite;
nscolor mMozWindowActiveBorder; nscolor mMozWindowActiveBorder = kBlack;
nscolor mMozWindowInactiveBorder; nscolor mMozWindowInactiveBorder = kBlack;
nscolor mMozWindowInactiveCaption; nscolor mMozWindowInactiveCaption = kWhite;
nscolor mMozCellHighlightBackground; nscolor mMozCellHighlightBackground = kWhite;
nscolor mMozCellHighlightText; nscolor mMozCellHighlightText = kBlack;
nscolor mTextSelectedText; nscolor mTextSelectedText = kBlack;
nscolor mTextSelectedBackground; nscolor mTextSelectedBackground = kWhite;
nscolor mMozScrollbar; nscolor mMozScrollbar = kWhite;
nscolor mInfoBarText; nscolor mInfoBarText = kBlack;
char16_t mInvisibleCharacter; char16_t mInvisibleCharacter = 0;
float mCaretRatio; float mCaretRatio = 0.0f;
bool mMenuSupportsDrag; bool mMenuSupportsDrag = false;
bool mCSDAvailable; bool mCSDAvailable = false;
bool mCSDHideTitlebarByDefault; bool mCSDHideTitlebarByDefault = false;
bool mCSDMaximizeButton; bool mCSDMaximizeButton = false;
bool mCSDMinimizeButton; bool mCSDMinimizeButton = false;
bool mCSDCloseButton; bool mCSDCloseButton = false;
bool mCSDReversedPlacement; bool mCSDReversedPlacement = false;
bool mInitialized; bool mInitialized = false;
void EnsureInit(); void EnsureInit();