bug 474825 - honor mozilla.widget.disable-native-theme preference. r/sr=stuart
authorDoug Turner <dougt@meer.net>
Wed, 28 Jan 2009 17:26:28 -0800
changeset 23061 a7858cfcb2ee061432f8b2461b1725f0f81591b9
parent 23054 cabcbb97bb8666efadaec1c0b63c75fb8628acb7
child 23062 1893ce01b38fc0e268822a2b1b22fa00d78476b7
push id581
push userdougt@mozilla.com
push dateThu, 29 Jan 2009 15:14:53 +0000
bugs474825
milestone1.9.1b3pre
bug 474825 - honor mozilla.widget.disable-native-theme preference. r/sr=stuart
widget/src/build/nsWinWidgetFactory.cpp
widget/src/windows/nsWindow.cpp
--- a/widget/src/build/nsWinWidgetFactory.cpp
+++ b/widget/src/build/nsWinWidgetFactory.cpp
@@ -70,22 +70,52 @@
 #include "nsPrintOptionsWin.h"
 #include "nsPrintSession.h"
 #endif
 
 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)
 
+// 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)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceWin)
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -356,16 +356,19 @@ PRInt32    nsWindow::sIMECompClauseArray
 // then, we should not set caret position to text event.
 #define NO_IME_CARET -1
 long       nsWindow::sIMECursorPosition        = NO_IME_CARET;
 
 RECT*      nsWindow::sIMECompCharPos           = nsnull;
 
 PRBool     nsWindow::gSwitchKeyboardLayout     = PR_FALSE;
 
+// imported in nsWidgetFactory.cpp
+PRBool gDisableNativeTheme = PR_FALSE;
+
 #ifndef WINCE
 static KeyboardLayout gKbdLayout;
 #endif
 
 TriStateBool nsWindow::sCanQuit = TRI_UNKNOWN;
 
 BOOL nsWindow::sIsRegistered       = FALSE;
 BOOL nsWindow::sIsPopupClassRegistered = FALSE;
@@ -1390,26 +1393,30 @@ nsWindow::StandardWindowCreate(nsIWidget
        will have that entire bug tattooed on their backside. */
 
     gTrimOnMinimize = 0;
     nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefs) {
       nsCOMPtr<nsIPrefBranch> 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;
       }
     }
   }
 #ifdef WINCE
   if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel )
      CreateSoftKeyMenuBar(mWnd);
 #endif