Bug 477586 - We should be able to disable NativeColors using in xpwidgets.
authorOleg Romashin <romaxa@gmail.com>
Tue, 10 Feb 2009 14:25:00 -0500
changeset 24830 096c7652745656d37b3a3f860e323da8e87f6d54
parent 24829 8334582740d7c159cb191583b21a0504c575cb47
child 24831 c823439c14090689cb9e170b41a6197b490cff86
push idunknown
push userunknown
push dateunknown
bugs477586
milestone1.9.2a1pre
Bug 477586 - We should be able to disable NativeColors using in xpwidgets.
modules/libpref/src/init/all.js
widget/src/xpwidgets/nsXPLookAndFeel.cpp
widget/src/xpwidgets/nsXPLookAndFeel.h
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -78,16 +78,17 @@ pref("offline-apps.quota.max",        20
 // the user should be warned if offline app disk usage exceeds this amount
 // (in kilobytes)
 pref("offline-apps.quota.warn",        51200);
 
 // Fastback caching - if this pref is negative, then we calculate the number
 // of content viewers to cache based on the amount of available memory.
 pref("browser.sessionhistory.max_total_viewers", -1);
 
+pref("ui.use_native_colors", true);
 pref("browser.display.use_document_fonts",  1);  // 0 = never, 1 = quick, 2 = always
 pref("browser.display.use_document_colors", true);
 pref("browser.display.use_system_colors",   false);
 pref("browser.display.foreground_color",    "#000000");
 pref("browser.display.background_color",    "#FFFFFF");
 pref("browser.display.force_inline_alttext", false); // true = force ALT text for missing images to be layed out inline
 // 0 = no external leading, 
 // 1 = use external leading only when font provides, 
--- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp
@@ -47,17 +47,17 @@
 #include "nsFont.h"
 
 #include "gfxPlatform.h"
 #include "lcms.h"
 
 #ifdef DEBUG
 #include "nsSize.h"
 #endif
- 
+
 NS_IMPL_ISUPPORTS2(nsXPLookAndFeel, nsILookAndFeel, nsIObserver)
 
 nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] =
 {
   { "ui.windowTitleHeight", eMetric_WindowTitleHeight, PR_FALSE, nsLookAndFeelTypeInt, 0 },
   { "ui.windowBorderWidth", eMetric_WindowBorderWidth, PR_FALSE, nsLookAndFeelTypeInt, 0 },
   { "ui.windowBorderHeight", eMetric_WindowBorderHeight, PR_FALSE, nsLookAndFeelTypeInt, 0 },
   { "ui.widget3DBorder", eMetric_Widget3DBorder, PR_FALSE, nsLookAndFeelTypeInt, 0 },
@@ -249,16 +249,17 @@ const char nsXPLookAndFeel::sColorPrefs[
   "ui.-moz-comboboxtext",
   "ui.-moz-combobox"
 };
 
 PRInt32 nsXPLookAndFeel::sCachedColors[nsILookAndFeel::eColor_LAST_COLOR] = {0};
 PRInt32 nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
 
 PRBool nsXPLookAndFeel::sInitialized = PR_FALSE;
+PRBool nsXPLookAndFeel::sUseNativeColors = PR_TRUE;
 
 nsXPLookAndFeel::nsXPLookAndFeel() : nsILookAndFeel()
 {
 }
 
 void
 nsXPLookAndFeel::IntPrefChanged (nsLookAndFeelIntPref *data)
 {
@@ -447,16 +448,21 @@ nsXPLookAndFeel::Init()
     InitFromPref(&sFloatPrefs[i], prefs);
     prefBranchInternal->AddObserver(sFloatPrefs[i].name, this, PR_FALSE);
   }
 
   for (i = 0; i < NS_ARRAY_LENGTH(sColorPrefs); ++i) {
     InitColorFromPref(i, prefs);
     prefBranchInternal->AddObserver(sColorPrefs[i], this, PR_FALSE);
   }
+
+  PRBool val;
+  if (NS_SUCCEEDED(prefs->GetBoolPref("ui.use_native_colors", &val))) {
+    sUseNativeColors = val;
+  }
 }
 
 nsXPLookAndFeel::~nsXPLookAndFeel()
 {
 }
 
 PRBool
 nsXPLookAndFeel::IsSpecialColor(const nsColorID aID, nscolor &aColor)
@@ -609,17 +615,17 @@ nsXPLookAndFeel::GetColor(const nsColorI
 
   if (aID == eColor_TextHighlightForeground) {
     // The foreground color for the matched text in findbar highlighting
     // Used with nsISelectionController::SELECTION_FIND
     aColor = NS_RGB(0xff, 0xff, 0xff);
     return NS_OK;
   }
 
-  if (NS_SUCCEEDED(NativeGetColor(aID, aColor))) {
+  if (sUseNativeColors && NS_SUCCEEDED(NativeGetColor(aID, aColor))) {
     if ((gfxPlatform::GetCMSMode() == eCMSMode_All) && !IsSpecialColor(aID, aColor)) {
       cmsHTRANSFORM transform = gfxPlatform::GetCMSInverseRGBTransform();
       if (transform) {
         PRUint8 color[3];
         color[0] = NS_GET_R(aColor);
         color[1] = NS_GET_G(aColor);
         color[2] = NS_GET_B(aColor);
         cmsDoTransform(transform, color, color, 1);
--- a/widget/src/xpwidgets/nsXPLookAndFeel.h
+++ b/widget/src/xpwidgets/nsXPLookAndFeel.h
@@ -126,13 +126,14 @@ protected:
   static nsLookAndFeelIntPref sIntPrefs[];
   static nsLookAndFeelFloatPref sFloatPrefs[];
   /* this length must not be shorter than the length of the longest string in the array
    * see nsXPLookAndFeel.cpp
    */
   static const char sColorPrefs[][38];
   static PRInt32 sCachedColors[nsILookAndFeel::eColor_LAST_COLOR];
   static PRInt32 sCachedColorBits[COLOR_CACHE_SIZE];
+  static PRBool sUseNativeColors;
 };
 
 extern nsresult NS_NewXPLookAndFeel(nsILookAndFeel**);
 
 #endif