From 8bc26a06ea6f87eebe9f070a118116325618f31c Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Wed, 28 Jan 2009 15:39:13 -0800 Subject: [PATCH] Bug 474825 - honor mozilla.widget.disable-native-theme preference on windows. r/sr=stuart --- gfx/cairo/Makefile.in | 4 +-- widget/src/build/nsWinWidgetFactory.cpp | 34 +++++++++++++++++++++++-- widget/src/windows/nsWindow.cpp | 19 +++++++++----- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/gfx/cairo/Makefile.in b/gfx/cairo/Makefile.in index 2f403d89d93..bf21c3b22a9 100644 --- a/gfx/cairo/Makefile.in +++ b/gfx/cairo/Makefile.in @@ -42,9 +42,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = $(NULL) - -DIRS += libpixman/src cairo/src +DIRS = libpixman/src cairo/src include $(topsrcdir)/config/rules.mk diff --git a/widget/src/build/nsWinWidgetFactory.cpp b/widget/src/build/nsWinWidgetFactory.cpp index 9c1a5afb1fd..2f73ae53af0 100644 --- a/widget/src/build/nsWinWidgetFactory.cpp +++ b/widget/src/build/nsWinWidgetFactory.cpp @@ -75,12 +75,42 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeWin) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerWin) -#ifndef WINCE +// from nsWindow.cpp +extern PRBool gDisableNativeTheme; +static NS_IMETHODIMP +nsNativeThemeWinConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + nsresult rv; + nsNativeThemeWin * inst; + + if (gDisableNativeTheme) + return NS_ERROR_NO_INTERFACE; + + *aResult = NULL; + if (NULL != aOuter) { + rv = NS_ERROR_NO_AGGREGATION; + return rv; + } + + NS_NEWXPCOM(inst, nsNativeThemeWin); + if (NULL == inst) { + rv = NS_ERROR_OUT_OF_MEMORY; + return rv; + } + NS_ADDREF(inst); + rv = inst->QueryInterface(aIID, aResult); + NS_RELEASE(inst); + + return rv; +} + + +#ifndef WINCE NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 55ad3684067..f49fa63ebc6 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -348,6 +348,9 @@ RECT* nsWindow::sIMECompCharPos = nsnull; PRBool nsWindow::gSwitchKeyboardLayout = PR_FALSE; +// imported in nsWidgetFactory.cpp +PRBool gDisableNativeTheme = PR_FALSE; + #ifndef WINCE static KeyboardLayout gKbdLayout; #endif @@ -1367,16 +1370,20 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent, nsCOMPtr prefBranch; prefs->GetBranch(0, getter_AddRefs(prefBranch)); if (prefBranch) { - PRBool trimOnMinimize; + + PRBool temp; if (NS_SUCCEEDED(prefBranch->GetBoolPref("config.trim_on_minimize", - &trimOnMinimize)) - && trimOnMinimize) + &temp)) + && temp) gTrimOnMinimize = 1; - PRBool switchKeyboardLayout; if (NS_SUCCEEDED(prefBranch->GetBoolPref("intl.keyboard.per_window_layout", - &switchKeyboardLayout))) - gSwitchKeyboardLayout = switchKeyboardLayout; + &temp))) + gSwitchKeyboardLayout = temp; + + if (NS_SUCCEEDED(prefBranch->GetBoolPref("mozilla.widget.disable-native-theme", + &temp))) + gDisableNativeTheme = temp; } } }