Bug 679717 - Add "mac-lion-theme" system metric in order to allow for Lion-specific CSS rules without the need for per-file manifest overrides. r=dbaron
authorMarkus Stange <mstange@themasta.com>
Thu, 18 Aug 2011 10:40:27 +0200
changeset 75483 805cd41a9b9fa7a7255a8be7ec568e46e5a30ae7
parent 75458 f69a10f23bf334215464758d71ad900542856f5a
child 75484 63b8853b1d67da1b8c7a05ce9bb986157d58bb81
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersdbaron
bugs679717
milestone9.0a1
Bug 679717 - Add "mac-lion-theme" system metric in order to allow for Lion-specific CSS rules without the need for per-file manifest overrides. r=dbaron
content/base/src/nsGkAtomList.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsMediaFeatures.cpp
layout/style/test/test_media_queries.html
widget/public/nsILookAndFeel.h
widget/src/cocoa/nsLookAndFeel.mm
widget/src/gtk2/nsLookAndFeel.cpp
widget/src/os2/nsLookAndFeel.cpp
widget/src/windows/nsLookAndFeel.cpp
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1868,16 +1868,17 @@ GK_ATOM(scrollbar_start_backward, "scrol
 GK_ATOM(scrollbar_start_forward, "scrollbar-start-forward")
 GK_ATOM(scrollbar_end_backward, "scrollbar-end-backward")
 GK_ATOM(scrollbar_end_forward, "scrollbar-end-forward")
 GK_ATOM(scrollbar_thumb_proportional, "scrollbar-thumb-proportional")
 GK_ATOM(images_in_menus, "images-in-menus")
 GK_ATOM(images_in_buttons, "images-in-buttons")
 GK_ATOM(windows_default_theme, "windows-default-theme")
 GK_ATOM(mac_graphite_theme, "mac-graphite-theme")
+GK_ATOM(mac_lion_theme, "mac-lion-theme")
 GK_ATOM(windows_compositor, "windows-compositor")
 GK_ATOM(touch_enabled, "touch-enabled")
 GK_ATOM(maemo_classic, "maemo-classic")
 GK_ATOM(menubar_drag, "menubar-drag")
 
 // windows theme selector metrics
 GK_ATOM(windows_classic, "windows-classic")
 GK_ATOM(windows_theme_aero, "windows-theme-aero")
@@ -1893,16 +1894,17 @@ GK_ATOM(_moz_scrollbar_start_backward, "
 GK_ATOM(_moz_scrollbar_start_forward, "-moz-scrollbar-start-forward")
 GK_ATOM(_moz_scrollbar_end_backward, "-moz-scrollbar-end-backward")
 GK_ATOM(_moz_scrollbar_end_forward, "-moz-scrollbar-end-forward")
 GK_ATOM(_moz_scrollbar_thumb_proportional, "-moz-scrollbar-thumb-proportional")
 GK_ATOM(_moz_images_in_menus, "-moz-images-in-menus")
 GK_ATOM(_moz_images_in_buttons, "-moz-images-in-buttons")
 GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme")
 GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme")
+GK_ATOM(_moz_mac_lion_theme, "-moz-mac-lion-theme")
 GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor")
 GK_ATOM(_moz_windows_classic, "-moz-windows-classic")
 GK_ATOM(_moz_windows_theme, "-moz-windows-theme")
 GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
 GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
 GK_ATOM(_moz_menubar_drag, "-moz-menubar-drag")
 GK_ATOM(_moz_device_pixel_ratio, "-moz-device-pixel-ratio")
 GK_ATOM(_moz_device_orientation, "-moz-device-orientation")
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1103,16 +1103,21 @@ InitSystemMetrics()
     sSystemMetrics->AppendElement(nsGkAtoms::windows_default_theme);
   }
 
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MacGraphiteTheme, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::mac_graphite_theme);
   }
 
+  rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MacLionTheme, metricResult);
+  if (NS_SUCCEEDED(rv) && metricResult) {
+    sSystemMetrics->AppendElement(nsGkAtoms::mac_lion_theme);
+  }
+
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DWMCompositor, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::windows_compositor);
   }
 
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_WindowsClassic, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::windows_classic);
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -517,16 +517,23 @@ nsMediaFeatures::features[] = {
     {
         &nsGkAtoms::_moz_mac_graphite_theme,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::mac_graphite_theme },
         GetSystemMetric
     },
     {
+        &nsGkAtoms::_moz_mac_lion_theme,
+        nsMediaFeature::eMinMaxNotAllowed,
+        nsMediaFeature::eBoolInteger,
+        { &nsGkAtoms::mac_lion_theme },
+        GetSystemMetric
+    },
+    {
         &nsGkAtoms::_moz_windows_compositor,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::windows_compositor },
         GetSystemMetric
     },
     {
         &nsGkAtoms::_moz_windows_classic,
--- a/layout/style/test/test_media_queries.html
+++ b/layout/style/test/test_media_queries.html
@@ -545,72 +545,77 @@ function run() {
   expression_should_be_parseable("-moz-scrollbar-start-forward");
   expression_should_be_parseable("-moz-scrollbar-end-backward");
   expression_should_be_parseable("-moz-scrollbar-end-forward");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional");
   expression_should_be_parseable("-moz-images-in-menus");
   expression_should_be_parseable("-moz-images-in-buttons");
   expression_should_be_parseable("-moz-windows-default-theme");
   expression_should_be_parseable("-moz-mac-graphite-theme");
+  expression_should_be_parseable("-moz-mac-lion-theme");
   expression_should_be_parseable("-moz-windows-compositor");
   expression_should_be_parseable("-moz-windows-classic");
   expression_should_be_parseable("-moz-touch-enabled");
   expression_should_be_parseable("-moz-maemo-classic");
 
   expression_should_be_parseable("-moz-scrollbar-start-backward: 0");
   expression_should_be_parseable("-moz-scrollbar-start-forward: 0");
   expression_should_be_parseable("-moz-scrollbar-end-backward: 0");
   expression_should_be_parseable("-moz-scrollbar-end-forward: 0");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional: 0");
   expression_should_be_parseable("-moz-images-in-menus: 0");
   expression_should_be_parseable("-moz-images-in-buttons: 0");
   expression_should_be_parseable("-moz-windows-default-theme: 0");
   expression_should_be_parseable("-moz-mac-graphite-theme: 0");
+  expression_should_be_parseable("-moz-mac-lion-theme: 0");
   expression_should_be_parseable("-moz-windows-compositor: 0");
   expression_should_be_parseable("-moz-windows-classic: 0");
   expression_should_be_parseable("-moz-touch-enabled: 0");
   expression_should_be_parseable("-moz-maemo-classic: 0");
 
   expression_should_be_parseable("-moz-scrollbar-start-backward: 1");
   expression_should_be_parseable("-moz-scrollbar-start-forward: 1");
   expression_should_be_parseable("-moz-scrollbar-end-backward: 1");
   expression_should_be_parseable("-moz-scrollbar-end-forward: 1");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional: 1");
   expression_should_be_parseable("-moz-images-in-menus: 1");
   expression_should_be_parseable("-moz-images-in-buttons: 1");
   expression_should_be_parseable("-moz-windows-default-theme: 1");
   expression_should_be_parseable("-moz-mac-graphite-theme: 1");
+  expression_should_be_parseable("-moz-mac-lion-theme: 1");
   expression_should_be_parseable("-moz-windows-compositor: 1");
   expression_should_be_parseable("-moz-windows-classic: 1");
   expression_should_be_parseable("-moz-touch-enabled: 1");
   expression_should_be_parseable("-moz-maemo-classic: 1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-end-forward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-thumb-proportional: -1");
   expression_should_not_be_parseable("-moz-images-in-menus: -1");
   expression_should_not_be_parseable("-moz-images-in-buttons: -1");
   expression_should_not_be_parseable("-moz-windows-default-theme: -1");
   expression_should_not_be_parseable("-moz-mac-graphite-theme: -1");
+  expression_should_not_be_parseable("-moz-mac-lion-theme: -1");
   expression_should_not_be_parseable("-moz-windows-compositor: -1");
   expression_should_not_be_parseable("-moz-windows-classic: -1");
   expression_should_not_be_parseable("-moz-touch-enabled: -1");
   expression_should_not_be_parseable("-moz-maemo-classic: -1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-forward: true");
   expression_should_not_be_parseable("-moz-scrollbar-thumb-proportional: true");
   expression_should_not_be_parseable("-moz-images-in-menus: true");
   expression_should_not_be_parseable("-moz-images-in-buttons: true");
   expression_should_not_be_parseable("-moz-windows-default-theme: true");
   expression_should_not_be_parseable("-moz-mac-graphite-theme: true");
+  expression_should_not_be_parseable("-moz-mac-lion-theme: true");
   expression_should_not_be_parseable("-moz-windows-compositor: true");
   expression_should_not_be_parseable("-moz-windows-classic: true");
   expression_should_not_be_parseable("-moz-touch-enabled: true");
   expression_should_not_be_parseable("-moz-maemo-classic: true");
 
   // windows theme media queries
   expression_should_be_parseable("-moz-windows-theme: aero");
   expression_should_be_parseable("-moz-windows-theme: luna-blue");
--- a/widget/public/nsILookAndFeel.h
+++ b/widget/public/nsILookAndFeel.h
@@ -245,16 +245,26 @@ public:
      * being used.
      *
      * The value of this metric is not used on other platforms. These platforms
      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
      */
     eMetric_MacGraphiteTheme,
 
     /*
+     * A Boolean value to determine whether the Mac OS X Lion-specific theming
+     * should be used.
+     *
+     * The value of this metric is not used on non-Mac platforms. These
+     * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
+     * metric.
+     */
+    eMetric_MacLionTheme,
+
+    /*
      * A Boolean value to determine whether Mameo is using the new Fremantle
      * theme.
      *
      * The value of this metric is not used on other platforms. These platforms
      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
      */
     eMetric_MaemoClassic,
 
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -384,16 +384,19 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
     case eMetric_MaemoClassic:
     case eMetric_WindowsThemeIdentifier:
       aMetric = 0;
       res = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eMetric_MacGraphiteTheme:
       aMetric = [NSColor currentControlTint] == NSGraphiteControlTint;
       break;
+    case eMetric_MacLionTheme:
+      aMetric = nsToolkit::OnLionOrLater();
+      break;
     case eMetric_TabFocusModel:
     {
       // we should probably cache this
       CFPropertyListRef fullKeyboardAccessProperty;
       fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"),
                                                             kCFPreferencesAnyApplication,
                                                             kCFPreferencesCurrentUser,
                                                             kCFPreferencesAnyHost);
--- a/widget/src/gtk2/nsLookAndFeel.cpp
+++ b/widget/src/gtk2/nsLookAndFeel.cpp
@@ -544,16 +544,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
             }
         }
 #else
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
 #endif
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
         break;
     case eMetric_IMESelectedRawTextUnderlineStyle:
--- a/widget/src/os2/nsLookAndFeel.cpp
+++ b/widget/src/os2/nsLookAndFeel.cpp
@@ -326,16 +326,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
     case eMetric_WindowsClassic:
     case eMetric_WindowsDefaultTheme:
     case eMetric_TouchEnabled:
     case eMetric_WindowsThemeIdentifier:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
     case eMetric_MaemoClassic:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
         break;
--- a/widget/src/windows/nsLookAndFeel.cpp
+++ b/widget/src/windows/nsLookAndFeel.cpp
@@ -414,16 +414,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
         break;
     case eMetric_WindowsDefaultTheme:
         aMetric = nsUXThemeData::IsDefaultWindowTheme();
         break;
     case eMetric_WindowsThemeIdentifier:
         aMetric = nsUXThemeData::GetNativeThemeId();
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
     case eMetric_MaemoClassic:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_DWMCompositor:
         aMetric = nsUXThemeData::CheckForCompositor();
         break;
     case eMetric_AlertNotificationOrigin: