Bug 513493 - Adjust native theme colors to match Snow Leopard. r=josh
authorMarkus Stange <mstange@themasta.com>
Tue, 22 Sep 2009 19:48:55 +1200
changeset 32941 9bbef3004ce835238e7f0e52ab6db623289f56f2
parent 32940 e259f581ac08355b88a6aaf98e6a12ce6686f011
child 32942 ccdf3c2791bdc48df963ef687a734073f40b54a4
push idunknown
push userunknown
push dateunknown
reviewersjosh
bugs513493
milestone1.9.3a1pre
Bug 513493 - Adjust native theme colors to match Snow Leopard. r=josh
widget/src/cocoa/nsLookAndFeel.mm
widget/src/cocoa/nsNativeThemeColors.h
widget/src/cocoa/nsToolkit.h
widget/src/cocoa/nsToolkit.mm
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -283,18 +283,21 @@ nsresult nsLookAndFeel::NativeGetColor(c
       break;
     case eColor__moz_mac_chrome_active:
     case eColor__moz_mac_chrome_inactive: {
       int grey = NativeGreyColorAsInt(headerEndGrey, (aID == eColor__moz_mac_chrome_active));
       aColor = NS_RGB(grey, grey, grey);
     }
       break;
     case eColor__moz_mac_focusring:
-      aColor = [NSColor currentControlTint] == NSGraphiteControlTint ?
-               NS_RGB(0x5F,0x70,0x82) : NS_RGB(0x53,0x90,0xD2);
+      aColor = nsToolkit::OnSnowLeopardOrLater() ?
+                 ([NSColor currentControlTint] == NSGraphiteControlTint ?
+                    NS_RGB(0x6C,0x7E,0x8D) : NS_RGB(0x3F,0x98,0xDD)) :
+                 ([NSColor currentControlTint] == NSGraphiteControlTint ?
+                    NS_RGB(0x5F,0x70,0x82) : NS_RGB(0x53,0x90,0xD2));
       break;
     case eColor__moz_mac_menushadow:
       res = GetMacBrushColor(kThemeBrushBevelActiveDark, aColor, NS_RGB(0x88,0x88,0x88));
       break;          
     case eColor__moz_mac_menutextdisable:
       res = GetMacTextColor(kThemeTextColorMenuItemDisabled, aColor, NS_RGB(0x99,0x99,0x99));
       break;      
     case eColor__moz_mac_menutextselect:
--- a/widget/src/cocoa/nsNativeThemeColors.h
+++ b/widget/src/cocoa/nsNativeThemeColors.h
@@ -33,16 +33,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsNativeThemeColors_h_
 #define nsNativeThemeColors_h_
 
+#include "nsToolkit.h"
 #import <Cocoa/Cocoa.h>
 
 enum ColorName {
   headerStartGrey,
   headerEndGrey,
   headerBorderGrey,
   toolbarTopBorderGrey,
   statusbarFirstTopBorderGrey,
@@ -60,18 +61,35 @@ static const int sLeopardThemeColors[][2
   { 0xC0, 0xE2 }, // top separator line
   // statusbar:
   { 0x42, 0x86 }, // first top border
   { 0xD8, 0xEE }, // second top border
   { 0xBD, 0xE4 }, // gradient start
   { 0x96, 0xCF }  // gradient end
 };
 
+static const int sSnowLeopardThemeColors[][2] = {
+  /* { active window, inactive window } */
+  // titlebar and toolbar:
+  { 0xD1, 0xEE }, // start grey
+  { 0xA7, 0xD8 }, // end grey
+  { 0x51, 0x99 }, // bottom separator line
+  { 0xD0, 0xF1 }, // top separator line
+  // statusbar:
+  { 0x51, 0x99 }, // first top border
+  { 0xE8, 0xF6 }, // second top border
+  { 0xCB, 0xEA }, // gradient start
+  { 0xA7, 0xDE }  // gradient end
+};
+
 static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
 {
+  if (nsToolkit::OnSnowLeopardOrLater())
+    return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
+
   return sLeopardThemeColors[name][isMain ? 0 : 1];
 }
 
 static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
 {
   return NativeGreyColorAsInt(name, isMain) / 255.0f;
 }
 
--- a/widget/src/cocoa/nsToolkit.h
+++ b/widget/src/cocoa/nsToolkit.h
@@ -43,32 +43,34 @@
 
 #import <Carbon/Carbon.h>
 #import <Cocoa/Cocoa.h>
 #import <objc/Object.h>
 #import <IOKit/IOKitLib.h>
 
 #define MAC_OS_X_VERSION_10_4_HEX 0x00001040
 #define MAC_OS_X_VERSION_10_5_HEX 0x00001050
+#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
 
 class nsToolkit : public nsIToolkit
 {
 public:
                      nsToolkit();
   virtual            ~nsToolkit();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSITOOLKIT
 
   // Returns the OS X version as returned from Gestalt(gestaltSystemVersion, ...)
   static PRInt32     OSXVersion();
-  
+
   // Convenience functions to check the OS version
   static PRBool      OnLeopardOrLater();
-  
+  static PRBool      OnSnowLeopardOrLater();
+
   static void        PostSleepWakeNotification(const char* aNotification);
 
   static nsresult    SwizzleMethods(Class aClass, SEL orgMethod, SEL posedMethod,
                                     PRBool classMethods = PR_FALSE);
 
 protected:
 
   nsresult           RegisterForSleepWakeNotifcations();
--- a/widget/src/cocoa/nsToolkit.mm
+++ b/widget/src/cocoa/nsToolkit.mm
@@ -396,17 +396,22 @@ PRInt32 nsToolkit::OSXVersion()
   }
   return gOSXVersion;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 PRBool nsToolkit::OnLeopardOrLater()
 {
-    return (OSXVersion() >= MAC_OS_X_VERSION_10_5_HEX) ? PR_TRUE : PR_FALSE;
+  return (OSXVersion() >= MAC_OS_X_VERSION_10_5_HEX);
+}
+
+PRBool nsToolkit::OnSnowLeopardOrLater()
+{
+  return (OSXVersion() >= MAC_OS_X_VERSION_10_6_HEX);
 }
 
 // An alternative to [NSObject poseAsClass:] that isn't deprecated on OS X
 // Leopard and is available to 64-bit binaries on Leopard and above.  Based on
 // ideas and code from http://www.cocoadev.com/index.pl?MethodSwizzling.
 // Since the Method type becomes an opaque type as of Objective-C 2.0, we'll
 // have to switch to using accessor methods like method_exchangeImplementations()
 // when we build 64-bit binaries that use Objective-C 2.0 (on and for Leopard