Bug 715024 - Remove duplicate functions on nsCocoaFeatures and nsToolkit. r=bgirard
authorCameron McCormack <cam@mcc.id.au>
Thu, 17 May 2012 17:53:20 +1000
changeset 94213 12f13acb5ea84c633b07153f09ccd8a27561d130
parent 94212 c9ce0e49040a3f005d865d6ffa7ccce8afcdc423
child 94214 bb07c2f3427ffe784d4a4784a8623da3187bea07
push id9515
push usercmccormack@mozilla.com
push dateThu, 17 May 2012 07:54:31 +0000
treeherdermozilla-inbound@12f13acb5ea8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs715024
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 715024 - Remove duplicate functions on nsCocoaFeatures and nsToolkit. r=bgirard
widget/cocoa/GfxInfo.mm
widget/cocoa/nsAppShell.mm
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaFeatures.h
widget/cocoa/nsCocoaFeatures.mm
widget/cocoa/nsCocoaUtils.mm
widget/cocoa/nsCocoaWindow.mm
widget/cocoa/nsFilePicker.mm
widget/cocoa/nsLookAndFeel.mm
widget/cocoa/nsMenuBarX.mm
widget/cocoa/nsMenuX.mm
widget/cocoa/nsNativeThemeCocoa.mm
widget/cocoa/nsNativeThemeColors.h
widget/cocoa/nsToolkit.h
widget/cocoa/nsToolkit.mm
--- a/widget/cocoa/GfxInfo.mm
+++ b/widget/cocoa/GfxInfo.mm
@@ -39,17 +39,17 @@
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLRenderers.h>
 
 #include "mozilla/Util.h"
 
 #include "GfxInfo.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/FunctionTimer.h"
-#include "nsToolkit.h"
+#include "nsCocoaFeatures.h"
 #include "mozilla/Preferences.h"
 
 #import <Foundation/Foundation.h>
 #import <IOKit/IOKitLib.h>
 #import <Cocoa/Cocoa.h>
 
 #if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
@@ -171,17 +171,17 @@ GfxInfo::Init()
 
   CGLDestroyRendererInfo(renderer);
 #endif
 
   GetDeviceInfo();
 
   AddCrashReportAnnotations();
 
-  mOSXVersion = nsToolkit::OSXVersion();
+  mOSXVersion = nsCocoaFeatures::OSXVersion();
 
   return rv;
 }
 
 NS_IMETHODIMP
 GfxInfo::GetD2DEnabled(bool *aEnabled)
 {
   return NS_ERROR_FAILURE;
@@ -399,17 +399,17 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aF
     *aOS = os;
 
   // Don't evaluate special cases when we're evaluating the downloaded blocklist.
   if (!aDriverInfo.Length()) {
     // Many WebGL issues on 10.5, especially:
     //   * bug 631258: WebGL shader paints using textures belonging to other processes on Mac OS 10.5
     //   * bug 618848: Post process shaders and texture mapping crash OS X 10.5
     if (aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL &&
-        !nsToolkit::OnSnowLeopardOrLater()) {
+        !nsCocoaFeatures::OnSnowLeopardOrLater()) {
       *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
       return NS_OK;
     }
 
     // The code around the following has been moved into the global blocklist.
 #if 0
       // CGL reports a list of renderers, some renderers are slow (e.g. software)
       // and AFAIK we can't decide which one will be used among them, so let's implement this by returning NO_INFO
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -53,16 +53,17 @@
 #include "nsIRollupListener.h"
 #include "nsIWidget.h"
 #include "nsThreadUtils.h"
 #include "nsIWindowMediator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsObjCExceptions.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "nsChildView.h"
 #include "nsToolkit.h"
 #include "TextInputHandler.h"
 #include "mozilla/HangMonitor.h"
 #include "sampler.h"
 
 #include "npapi.h"
@@ -366,17 +367,17 @@ nsAppShell::Init()
     nsToolkit::SwizzleMethods([NSApplication class], @selector(endModalSession:),
                               @selector(nsAppShell_NSApplication_endModalSession:));
     // We should only replace the original terminate: method if we're not
     // running in a Cocoa embedder (like Camino).  See bug 604901.
     if (!mRunningCocoaEmbedded) {
       nsToolkit::SwizzleMethods([NSApplication class], @selector(terminate:),
                                 @selector(nsAppShell_NSApplication_terminate:));
     }
-    if (!nsToolkit::OnSnowLeopardOrLater()) {
+    if (!nsCocoaFeatures::OnSnowLeopardOrLater()) {
       dlopen("/System/Library/Frameworks/Carbon.framework/Frameworks/Print.framework/Versions/Current/Plugins/PrintCocoaUI.bundle/Contents/MacOS/PrintCocoaUI",
              RTLD_LAZY);
       Class PDEPluginCallbackClass = ::NSClassFromString(@"PDEPluginCallback");
       nsresult rv1 = nsToolkit::SwizzleMethods(PDEPluginCallbackClass, @selector(initWithPrintWindowController:),
                                                @selector(nsAppShell_PDEPluginCallback_initWithPrintWindowController:));
       if (NS_SUCCEEDED(rv1)) {
         nsToolkit::SwizzleMethods(PDEPluginCallbackClass, @selector(dealloc),
                                   @selector(nsAppShell_PDEPluginCallback_dealloc));
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -69,16 +69,17 @@
 #include "nsIDOMSimpleGestureEvent.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsThemeConstants.h"
 
 #include "nsDragService.h"
 #include "nsClipboard.h"
 #include "nsCursorManager.h"
 #include "nsWindowMap.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "nsMenuUtilsX.h"
 #include "nsMenuBarX.h"
 #ifdef __LP64__
 #include "ComplexTextInputPanel.h"
 #endif
 
 #include "gfxContext.h"
@@ -301,17 +302,17 @@ nsresult nsChildView::Create(nsIWidget *
   // (see bug 559075).
   nsAutoreleasePool localPool;
 
   // See NSView (MethodSwizzling) below.
   if (!gChildViewMethodsSwizzled) {
     nsToolkit::SwizzleMethods([NSView class], @selector(mouseDownCanMoveWindow),
                               @selector(nsChildView_NSView_mouseDownCanMoveWindow));
 #ifdef __LP64__
-    if (nsToolkit::OnLionOrLater()) {
+    if (nsCocoaFeatures::OnLionOrLater()) {
       nsToolkit::SwizzleMethods([NSEvent class], @selector(addLocalMonitorForEventsMatchingMask:handler:),
                                 @selector(nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:handler:),
                                 true);
       nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
                                 @selector(nsChildView_NSEvent_removeMonitor:), true);
     }
 #endif
 #ifndef NP_NO_CARBON
@@ -3048,17 +3049,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
 // now swipe animation is unsupported (e.g. no bounces).  This method is
 // partly based on Apple sample code available at
 // http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html
 // (under Fluid Swipe Tracking API).
 #ifdef __LP64__
 - (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent
                       scrollOverflow:(PRInt32)overflow
 {
-  if (!nsToolkit::OnLionOrLater()) {
+  if (!nsCocoaFeatures::OnLionOrLater()) {
     return;
   }
   // This method checks whether the AppleEnableSwipeNavigateWithScrolls global
   // preference is set.  If it isn't, fluid swipe tracking is disabled, and a
   // horizontal two-finger gesture is always a scroll (even in Safari).  This
   // preference can't (currently) be set from the Preferences UI -- only using
   // 'defaults write'.
   if (![NSEvent isSwipeTrackingFromScrollEventsEnabled]) {
@@ -3955,17 +3956,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
   NSPoint localPoint = [self convertPoint:locationInWindow fromView:nil];
   outGeckoEvent->refPoint.x = static_cast<nscoord>(localPoint.x);
   outGeckoEvent->refPoint.y = static_cast<nscoord>(localPoint.y);
 
   nsMouseEvent_base* mouseEvent =
     static_cast<nsMouseEvent_base*>(outGeckoEvent);
   mouseEvent->buttons = 0;
   NSUInteger mouseButtons =
-    nsToolkit::OnSnowLeopardOrLater() ? [NSEvent pressedMouseButtons] : 0;
+    nsCocoaFeatures::OnSnowLeopardOrLater() ? [NSEvent pressedMouseButtons] : 0;
 
   if (mouseButtons & 0x01) {
     mouseEvent->buttons |= nsMouseEvent::eLeftButtonFlag;
   }
   if (mouseButtons & 0x02) {
     mouseEvent->buttons |= nsMouseEvent::eRightButtonFlag;
   }
   if (mouseButtons & 0x04) {
--- a/widget/cocoa/nsCocoaFeatures.h
+++ b/widget/cocoa/nsCocoaFeatures.h
@@ -39,17 +39,16 @@
 #ifndef nsCocoaFeatures_h_
 #define nsCocoaFeatures_h_
 
 #include "prtypes.h"
 
 class nsCocoaFeatures {
 public:
   static PRInt32 OSXVersion();
-
   static bool OnSnowLeopardOrLater();
   static bool OnLionOrLater();
+  static bool SupportCoreAnimationPlugins();
 
-  static bool SupportCoreAnimationPlugins();
 private:
   static PRInt32 mOSXVersion;
 };
 #endif // nsCocoaFeatures_h_
--- a/widget/cocoa/nsCocoaFeatures.mm
+++ b/widget/cocoa/nsCocoaFeatures.mm
@@ -40,36 +40,41 @@
 #define MAC_OS_X_VERSION_10_5_HEX 0x00001050
 #define MAC_OS_X_VERSION_10_6_HEX 0x00001060
 #define MAC_OS_X_VERSION_10_7_HEX 0x00001070
 
 // This API will not work for OS X 10.10, see Gestalt.h.
 
 #include "nsCocoaFeatures.h"
 #include "nsDebug.h"
+#include "nsObjCExceptions.h"
 
 #import <Cocoa/Cocoa.h>
 
 PRInt32 nsCocoaFeatures::mOSXVersion = 0;
 
 /* static */ PRInt32
 nsCocoaFeatures::OSXVersion()
 {
+    NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
     if (!mOSXVersion) {
         // minor version is not accurate, use gestaltSystemVersionMajor, 
         // gestaltSystemVersionMinor, gestaltSystemVersionBugFix for these
         OSErr err = ::Gestalt(gestaltSystemVersion, reinterpret_cast<SInt32*>(&mOSXVersion));
         if (err != noErr) {
             // This should probably be changed when our minimum version changes
             NS_ERROR("Couldn't determine OS X version, assuming 10.5");
             mOSXVersion = MAC_OS_X_VERSION_10_5_HEX;
         }
         mOSXVersion &= MAC_OS_X_VERSION_MASK;
     }
     return mOSXVersion;
+
+    NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 /* static */ bool
 nsCocoaFeatures::SupportCoreAnimationPlugins()
 {
     // Disallow Core Animation on 10.5 because of crashes.
     // See Bug 711564.
     return (OSXVersion() >= MAC_OS_X_VERSION_10_6_HEX);
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -479,17 +479,17 @@ nsCocoaUtils::InitInputEvent(nsInputEven
 }
 
 // static
 NSUInteger
 nsCocoaUtils::GetCurrentModifiers()
 {
   // NOTE: [[NSApp currentEvent] modifiers] isn't useful because it sometime 0
   //       and we cannot check if it's actual state.
-  if (nsToolkit::OnSnowLeopardOrLater()) {
+  if (nsCocoaFeatures::OnSnowLeopardOrLater()) {
     // XXX [NSEvent modifierFlags] returns "current" modifier state, so,
     //     it's not event-queue-synchronized.  GetCurrentEventKeyModifiers()
     //     might be better, but it's Carbon API, we shouldn't use it as far as
     //     possible.
     return [NSEvent modifierFlags];
   }
 
   // If [NSEvent modifierFlags] isn't available, use carbon API.
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -56,16 +56,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
 #include "nsThreadUtils.h"
 #include "nsMenuBarX.h"
 #include "nsMenuUtilsX.h"
 #include "nsStyleConsts.h"
 #include "nsNativeThemeColors.h"
 #include "nsChildView.h"
+#include "nsCocoaFeatures.h"
 
 #include "gfxPlatform.h"
 #include "qcms.h"
 
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace layers {
@@ -2379,17 +2380,17 @@ static const NSString* kStateShowsToolba
   // text at all is selected.  (This always happens when accessibility is off.
   // It doesn't happen in Firefox releases because Apple has (on OS X 10.7)
   // special-cased the handling of apps whose CFBundleIdentifier is
   // org.mozilla.firefox.)
   //
   // We work around this problem by only returning AXChildren that are
   // mozAccessible object or are one of the titlebar's buttons (which
   // instantiate subclasses of NSButtonCell).
-  if (nsToolkit::OnLionOrLater() && [retval isKindOfClass:[NSArray class]] &&
+  if (nsCocoaFeatures::OnLionOrLater() && [retval isKindOfClass:[NSArray class]] &&
       [attribute isEqualToString:@"AXChildren"]) {
     NSMutableArray *holder = [NSMutableArray arrayWithCapacity:10];
     [holder addObjectsFromArray:(NSArray *)retval];
     NSUInteger count = [holder count];
     for (NSInteger i = count - 1; i >= 0; --i) {
       id item = [holder objectAtIndex:i];
       // Remove anything from holder that isn't one of the titlebar's buttons
       // (which instantiate subclasses of NSButtonCell) or a mozAccessible
@@ -2684,17 +2685,17 @@ DrawNativeTitlebar(CGContextRef aContext
             @"kCUIWidgetWindowFrame", @"widget",
             @"regularwin", @"windowtype",
             (aIsMain ? @"normal" : @"inactive"), @"state",
             [NSNumber numberWithInt:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
             [NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey",
             nil],
           nil);
 
-  if (nsToolkit::OnLionOrLater()) {
+  if (nsCocoaFeatures::OnLionOrLater()) {
     // On Lion the call to CUIDraw doesn't draw the top pixel strip at some
     // window widths. We don't want to have a flickering transparent line, so
     // we overdraw it.
     CGContextSetRGBFillColor(aContext, 0.95, 0.95, 0.95, 1);
     CGContextFillRect(aContext, CGRectMake(0, CGRectGetMaxY(aTitlebarRect) - 1,
                                            aTitlebarRect.size.width, 1));
   }
 }
--- a/widget/cocoa/nsFilePicker.mm
+++ b/widget/cocoa/nsFilePicker.mm
@@ -48,18 +48,18 @@
 #include "nsReadableUtils.h"
 #include "nsNetUtil.h"
 #include "nsIComponentManager.h"
 #include "nsILocalFile.h"
 #include "nsILocalFileMac.h"
 #include "nsIURL.h"
 #include "nsArrayEnumerator.h"
 #include "nsIStringBundle.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
-#include "nsToolkit.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
 const float kAccessoryViewPadding = 5;
 const int   kSaveTypeControlTag = 1;
 
 static bool gCallSecretHiddenFileAPI = false;
@@ -351,17 +351,17 @@ nsFilePicker::GetLocalFiles(const nsStri
       [(NSString *)[filters objectAtIndex:0] isEqualToString:@"app"]) {
     theDir = @"/Applications/";
   }
 
   // On 10.6+, we let users change the filters. Unfortunately, some methods
   // are not available on 10.5 and without using them it happens to be buggy.
   int result;
   nsCocoaUtils::PrepareForNativeAppModalDialog();
-  if (mFilters.Length() > 1 && nsToolkit::OnSnowLeopardOrLater()) {
+  if (mFilters.Length() > 1 && nsCocoaFeatures::OnSnowLeopardOrLater()) {
     // [NSURL initWithString:] (below) throws an exception if URLString is nil.
     if (!theDir) {
       theDir = @"";
     }
 
     NSPopUpButtonObserver* observer = [[NSPopUpButtonObserver alloc] init];
 
     NSView* accessoryView = GetAccessoryView();
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -32,16 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * 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 ***** */
 
 #include "nsLookAndFeel.h"
+#include "nsCocoaFeatures.h"
 #include "nsObjCExceptions.h"
 #include "nsIServiceManager.h"
 #include "nsNativeThemeColors.h"
 #include "nsStyleConsts.h"
 #include "gfxFont.h"
 
 #import <Cocoa/Cocoa.h>
 
@@ -255,17 +256,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       break;
     case eColorID__moz_mac_focusring:
       aColor = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]);
       break;
     case eColorID__moz_mac_menushadow:
       aColor = NS_RGB(0xA3,0xA3,0xA3);
       break;          
     case eColorID__moz_mac_menutextdisable:
-      aColor = nsToolkit::OnSnowLeopardOrLater() ?
+      aColor = nsCocoaFeatures::OnSnowLeopardOrLater() ?
                  NS_RGB(0x88,0x88,0x88) : NS_RGB(0x98,0x98,0x98);
       break;      
     case eColorID__moz_mac_menutextselect:
       aColor = GetColorFromNSColor([NSColor selectedMenuItemTextColor]);
       break;      
     case eColorID__moz_mac_disabledtoolbartext:
       aColor = NS_RGB(0x3F,0x3F,0x3F);
       break;
@@ -344,17 +345,17 @@ nsLookAndFeel::GetIntImpl(IntID aID, PRI
     case eIntID_SkipNavigatingDisabledMenuItem:
       aResult = 1;
       break;
     case eIntID_DragThresholdX:
     case eIntID_DragThresholdY:
       aResult = 4;
       break;
     case eIntID_ScrollArrowStyle:
-      if (nsToolkit::OnLionOrLater()) {
+      if (nsCocoaFeatures::OnLionOrLater()) {
         // OS X Lion's scrollbars have no arrows
         aResult = eScrollArrow_None;
       } else {
         NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
         if ([buttonPlacement isEqualToString:@"Single"]) {
           aResult = eScrollArrowStyle_Single;
         } else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
           aResult = eScrollArrowStyle_BothAtTop;
@@ -391,17 +392,17 @@ nsLookAndFeel::GetIntImpl(IntID aID, PRI
     case eIntID_WindowsThemeIdentifier:
       aResult = 0;
       res = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eIntID_MacGraphiteTheme:
       aResult = [NSColor currentControlTint] == NSGraphiteControlTint;
       break;
     case eIntID_MacLionTheme:
-      aResult = nsToolkit::OnLionOrLater();
+      aResult = nsCocoaFeatures::OnLionOrLater();
       break;
     case eIntID_TabFocusModel:
     {
       // we should probably cache this
       CFPropertyListRef fullKeyboardAccessProperty;
       fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"),
                                                             kCFPreferencesAnyApplication,
                                                             kCFPreferencesCurrentUser,
--- a/widget/cocoa/nsMenuBarX.mm
+++ b/widget/cocoa/nsMenuBarX.mm
@@ -38,19 +38,19 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include <objc/objc-runtime.h>
 
 #include "nsMenuBarX.h"
 #include "nsMenuX.h"
 #include "nsMenuItemX.h"
 #include "nsMenuUtilsX.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "nsCocoaWindow.h"
-#include "nsToolkit.h"
 #include "nsChildView.h"
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsGkAtoms.h"
 #include "nsGUIEvent.h"
 #include "nsObjCExceptions.h"
 #include "nsHashtable.h"
@@ -360,17 +360,17 @@ nsMenuX* nsMenuBarX::GetXULHelpMenu()
 }
 
 // On SnowLeopard and later we must tell the OS which is our Help menu.
 // Otherwise it will only add Spotlight for Help (the Search item) to our
 // Help menu if its label/title is "Help" -- i.e. if the menu is in English.
 // This resolves bugs 489196 and 539317.
 void nsMenuBarX::SetSystemHelpMenu()
 {
-  if (!nsToolkit::OnSnowLeopardOrLater())
+  if (!nsCocoaFeatures::OnSnowLeopardOrLater())
     return;
   nsMenuX* xulHelpMenu = GetXULHelpMenu();
   if (xulHelpMenu) {
     NSMenu* helpMenu = (NSMenu*)xulHelpMenu->NativeData();
     if (helpMenu)
       [NSApp setHelpMenu:helpMenu];
   }
 }
--- a/widget/cocoa/nsMenuX.mm
+++ b/widget/cocoa/nsMenuX.mm
@@ -42,16 +42,17 @@
 #include "nsMenuItemX.h"
 #include "nsMenuUtilsX.h"
 #include "nsMenuItemIconX.h"
 #include "nsStandaloneNativeMenu.h"
 
 #include "nsObjCExceptions.h"
 
 #include "nsToolkit.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "nsCOMPtr.h"
 #include "prinrval.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "plstr.h"
 #include "nsGkAtoms.h"
@@ -134,17 +135,17 @@ nsMenuX::nsMenuX()
     nsToolkit::SwizzleMethods([NSMenu class], @selector(_addItem:toTable:),
                               @selector(nsMenuX_NSMenu_addItem:toTable:), true);
     nsToolkit::SwizzleMethods([NSMenu class], @selector(_removeItem:fromTable:),
                               @selector(nsMenuX_NSMenu_removeItem:fromTable:), true);
     // On SnowLeopard the Shortcut framework (which contains the
     // SCTGRLIndex class) is loaded on demand, whenever the user first opens
     // a menu (which normally hasn't happened yet).  So we need to load it
     // here explicitly.
-    if (nsToolkit::OnSnowLeopardOrLater())
+    if (nsCocoaFeatures::OnSnowLeopardOrLater())
       dlopen("/System/Library/PrivateFrameworks/Shortcut.framework/Shortcut", RTLD_LAZY);
     Class SCTGRLIndexClass = ::NSClassFromString(@"SCTGRLIndex");
     nsToolkit::SwizzleMethods(SCTGRLIndexClass, @selector(indexMenuBarDynamically),
                               @selector(nsMenuX_SCTGRLIndex_indexMenuBarDynamically));
 
     gMenuMethodsSwizzled = true;
   }
 
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -51,17 +51,17 @@
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIAtom.h"
 #include "nsEventStates.h"
 #include "nsINameSpaceManager.h"
 #include "nsPresContext.h"
 #include "nsGkAtoms.h"
-#include "nsToolkit.h"
+#include "nsCocoaFeatures.h"
 #include "nsCocoaWindow.h"
 #include "nsNativeThemeColors.h"
 #include "nsIScrollableFrame.h"
 #include "nsIDOMHTMLProgressElement.h"
 
 #include "gfxContext.h"
 #include "gfxQuartzSurface.h"
 #include "gfxQuartzNativeDrawing.h"
@@ -1620,17 +1620,17 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo
 
   aTdi.trackInfo.scrollbar.pressState = 0;
 
   // Only go get these scrollbar button states if we need it. For example,
   // there's no reason to look up scrollbar button states when we're only
   // creating a TrackDrawInfo to determine the size of the thumb. There's
   // also no reason to do this on Lion or later, whose scrollbars have no
   // arrow buttons.
-  if (aShouldGetButtonStates && !nsToolkit::OnLionOrLater()) {
+  if (aShouldGetButtonStates && !nsCocoaFeatures::OnLionOrLater()) {
     nsEventStates buttonStates[4];
     GetScrollbarPressStates(aFrame, buttonStates);
     NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
     // It seems that unless all four buttons are showing, kThemeTopOutsideArrowPressed is the correct constant for
     // the up scrollbar button.
     if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
       aTdi.trackInfo.scrollbar.pressState = ConvertToPressState(buttonStates[0], kThemeTopOutsideArrowPressed) |
                                             ConvertToPressState(buttonStates[1], kThemeTopInsideArrowPressed) |
@@ -2320,17 +2320,17 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDe
       aResult->SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
       break;
     }
 
     case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
     case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
     {
       // On Lion and later, scrollbars have no arrows.
-      if (!nsToolkit::OnLionOrLater()) {
+      if (!nsCocoaFeatures::OnLionOrLater()) {
         // There's only an endcap to worry about when both arrows are on the bottom
         NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
         if (!buttonPlacement || [buttonPlacement isEqualToString:@"DoubleMax"]) {
           bool isHorizontal = (aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL);
 
           nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame);
           if (!scrollbarFrame) return NS_ERROR_FAILURE;
           bool isSmall = (scrollbarFrame->GetStyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
--- a/widget/cocoa/nsNativeThemeColors.h
+++ b/widget/cocoa/nsNativeThemeColors.h
@@ -33,17 +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"
+#include "nsCocoaFeatures.h"
 #import <Cocoa/Cocoa.h>
 
 extern "C" {
   typedef CFTypeRef CUIRendererRef;
   void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result);
 }
 
 @interface NSWindow(CoreUIRendererPrivate)
@@ -78,20 +78,20 @@ static const int sLionThemeColors[][2] =
   { 0xD0, 0xF0 }, // top separator line
   { 0xB2, 0xE1 }, // fill color
   { 0x59, 0x87 }, // bottom separator line
 };
 
 __attribute__((unused))
 static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
 {
-  if (nsToolkit::OnLionOrLater())
+  if (nsCocoaFeatures::OnLionOrLater())
     return sLionThemeColors[name][isMain ? 0 : 1];
 
-  if (nsToolkit::OnSnowLeopardOrLater())
+  if (nsCocoaFeatures::OnSnowLeopardOrLater())
     return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
 
   return sLeopardThemeColors[name][isMain ? 0 : 1];
 }
 
 __attribute__((unused))
 static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
 {
--- a/widget/cocoa/nsToolkit.h
+++ b/widget/cocoa/nsToolkit.h
@@ -35,59 +35,52 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsToolkit_h_
 #define nsToolkit_h_
 
 #include "nscore.h"
+#include "nsCocoaFeatures.h"
 
 #import <Carbon/Carbon.h>
 #import <Cocoa/Cocoa.h>
 #import <objc/Object.h>
 #import <IOKit/IOKitLib.h>
 
-#define MAC_OS_X_VERSION_10_5_HEX 0x00001050
-#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
-#define MAC_OS_X_VERSION_10_7_HEX 0x00001070
-
 class nsToolkit
 {
 public:
                      nsToolkit();
   virtual            ~nsToolkit();
 
-  static nsToolkit* GetToolkit();
+  static nsToolkit*  GetToolkit();
 
   static void Shutdown() {
     delete gToolkit;
     gToolkit = nsnull;
   }
 
-  static PRInt32     OSXVersion();
-  static bool        OnSnowLeopardOrLater();
-  static bool        OnLionOrLater();
-
   static void        PostSleepWakeNotification(const char* aNotification);
 
   static nsresult    SwizzleMethods(Class aClass, SEL orgMethod, SEL posedMethod,
                                     bool classMethods = false);
 
 protected:
 
   nsresult           RegisterForSleepWakeNotifcations();
   void               RemoveSleepWakeNotifcations();
 
   void               RegisterForAllProcessMouseEvents();
   void               UnregisterAllProcessMouseEventHandlers();
 
 protected:
 
-  static nsToolkit* gToolkit;
+  static nsToolkit*  gToolkit;
 
   CFRunLoopSourceRef mSleepWakeNotificationRLS;
   io_object_t        mPowerNotifier;
 
   CFMachPortRef      mEventTapPort;
   CFRunLoopSourceRef mEventTapRLS;
 };
 
--- a/widget/cocoa/nsToolkit.mm
+++ b/widget/cocoa/nsToolkit.mm
@@ -309,44 +309,16 @@ nsToolkit* nsToolkit::GetToolkit()
     gToolkit = new nsToolkit();
   }
 
   return gToolkit;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsnull);
 }
 
-PRInt32 nsToolkit::OSXVersion()
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
-
-  static PRInt32 gOSXVersion = 0x0;
-  if (gOSXVersion == 0x0) {
-    OSErr err = ::Gestalt(gestaltSystemVersion, (SInt32*)&gOSXVersion);
-    if (err != noErr) {
-      // This should probably be changed when our minimum version changes
-      NS_ERROR("Couldn't determine OS X version, assuming 10.5");
-      gOSXVersion = MAC_OS_X_VERSION_10_5_HEX;
-    }
-  }
-  return gOSXVersion;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
-}
-
-bool nsToolkit::OnSnowLeopardOrLater()
-{
-  return (OSXVersion() >= MAC_OS_X_VERSION_10_6_HEX);
-}
-
-bool nsToolkit::OnLionOrLater()
-{
-  return (OSXVersion() >= MAC_OS_X_VERSION_10_7_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
 // and above).  But these accessor methods aren't available in Objective-C 1
 // (or on Tiger).  So we need to access Method's members directly for (Tiger-
@@ -511,17 +483,17 @@ OSStatus Hooked_InstallEventLoopIdleTime
 // Try to hook (or "subclass") the dynamically bound functions specified in
 // gHookedFunctions.  We don't hook these functions at their "original"
 // addresses, so we can only "subclass" calls to them from modules other than
 // the one in which they're defined.  Of course, this only works for globally
 // accessible functions.
 void HookImportedFunctions()
 {
   // We currently only need to do anything on Tiger or Leopard.
-  if (nsToolkit::OnSnowLeopardOrLater())
+  if (nsCocoaFeatures::OnSnowLeopardOrLater())
     return;
 
   // _dyld_register_func_for_add_image() makes the dynamic linker runtime call
   // ScanImportedFunctions() "once for each of the images that are currently
   // loaded into the program" (including the main image, i.e. firefox-bin).
   // When a new image is added (e.g. a plugin), ScanImportedFunctions() is
   // called again with data for that image.
   //