Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.605
diff -u -p -r1.605 theme.inc
--- includes/theme.inc	8 Aug 2010 19:35:48 -0000	1.605
+++ includes/theme.inc	18 Aug 2010 21:36:06 -0000
@@ -140,6 +140,7 @@ function _drupal_theme_initialize($theme
   // We work it this way so that we can have child themes override parent
   // theme stylesheets easily.
   $final_stylesheets = array();
+  $final_stylesheets_conditional = array();
 
   // Grab stylesheets from base theme
   foreach ($base_theme as $base) {
@@ -150,6 +151,15 @@ function _drupal_theme_initialize($theme
         }
       }
     }
+    if (!empty($base->stylesheets_conditional)) {
+      foreach ($base->stylesheets_conditional as $condition => $stylesheets_conditional) {
+        foreach ($stylesheets_conditional as $media => $stylesheets) {
+          foreach ($stylesheets as $name => $stylesheet) {
+            $final_stylesheets_conditional[$condition][$media][$name] = $stylesheet;
+          }
+        }
+      }
+    }
   }
 
   // Add stylesheets used by this theme.
@@ -161,6 +171,17 @@ function _drupal_theme_initialize($theme
     }
   }
 
+  // Add conditional stylesheets used by this theme.
+  if (!empty($theme->stylesheets_conditional)) {
+    foreach ($theme->stylesheets_conditional as $condition => $stylesheets_conditional) {
+      foreach ($stylesheets_conditional as $media => $stylesheets) {
+        foreach ($stylesheets as $name => $stylesheet) {
+          $final_stylesheets_conditional[$condition][$media][$name] = $stylesheet;
+        }
+      }
+    }
+  }
+
   // And now add the stylesheets properly
   foreach ($final_stylesheets as $media => $stylesheets) {
     foreach ($stylesheets as $stylesheet) {
@@ -168,6 +189,15 @@ function _drupal_theme_initialize($theme
     }
   }
 
+  // And now add the conditional stylesheets properly.
+  foreach ($final_stylesheets_conditional as $condition => $stylesheets_conditional) {
+    foreach ($stylesheets_conditional as $media => $stylesheets) {
+      foreach ($stylesheets as $name => $stylesheet) {
+        drupal_add_css($stylesheet, array('weight' => CSS_THEME, 'media' => $media, 'browsers' => array('IE' => $condition, '!IE' => FALSE)));
+      }
+    }
+  }
+
   // Do basically the same as the above for scripts
   $final_scripts = array();
 
@@ -601,6 +631,13 @@ function list_themes($refresh = FALSE) {
           $theme->stylesheets[$media][$stylesheet] = $path;
         }
       }
+      foreach ($theme->info['stylesheets-conditional'] as $condition => $stylesheets_conditional) {
+        foreach ($stylesheets_conditional as $media => $stylesheets) {
+          foreach ($stylesheets as $stylesheet => $path) {
+            $theme->stylesheets_conditional[$condition][$media][$stylesheet] = $path;
+          }
+        }
+      }
       foreach ($theme->info['scripts'] as $script => $path) {
         if (file_exists($path)) {
           $theme->scripts[$script] = $path;
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.122
diff -u -p -r1.122 common.test
--- modules/simpletest/tests/common.test	17 Aug 2010 21:31:13 -0000	1.122
+++ modules/simpletest/tests/common.test	18 Aug 2010 21:36:06 -0000
@@ -753,6 +753,18 @@ class CascadingStylesheetsTestCase exten
     $this->assertRaw(drupal_get_path('module', 'node') . '/node.css?' . $query_string, t('Query string was appended correctly to css.'));
     $this->assertRaw(drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&amp;arg2=value2', t('Query string not escaped on a URI.'));
   }
+
+  /**
+   * Test 'browsers' option in drupal_add_css().
+   */
+  function testConditionalStyles() {
+    // Create user with permission to access content.
+    $web_user = $this->drupalCreateUser(array('access content'));
+    $this->drupalLogin($web_user);
+    $this->drupalGet('conditional-styles');
+    $pattern = '/<!--\[if\ lt\ IE\ 5\]>.*simpletest.css.*<!\[endif\]-->/simx';
+    $this->assertPattern($pattern, t('Condition stylesheet added by drupal_add_css() was found.'));
+  }
 }
 
 /**
Index: modules/simpletest/tests/common_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common_test.module,v
retrieving revision 1.13
diff -u -p -r1.13 common_test.module
--- modules/simpletest/tests/common_test.module	17 Aug 2010 21:31:13 -0000	1.13
+++ modules/simpletest/tests/common_test.module	18 Aug 2010 21:36:06 -0000
@@ -53,6 +53,12 @@ function common_test_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
+  $items['conditional-styles'] = array(
+    'title' => 'Conditional styles test',
+    'page callback' => 'common_test_conditional_styles',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -226,3 +232,11 @@ function common_test_js_and_css_querystr
    drupal_add_css('/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2');
    return '';
 }
+
+/**
+ * Function to test 'browsers' option for drupal_add_css().
+ */
+function common_test_conditional_styles() {
+  drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css', array('browsers' => array('IE' => 'lt IE 5', '!IE' => FALSE)));
+  return 'Add conditional style';
+}
Index: modules/simpletest/tests/theme.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/theme.test,v
retrieving revision 1.19
diff -u -p -r1.19 theme.test
--- modules/simpletest/tests/theme.test	8 Aug 2010 19:35:49 -0000	1.19
+++ modules/simpletest/tests/theme.test	18 Aug 2010 21:36:06 -0000
@@ -66,6 +66,15 @@ class ThemeUnitTest extends DrupalWebTes
     $_GET['q'] = $q;
     $this->assertTrue(in_array('page__front', $suggestions), t('Front page template was suggested.'));
   }
+
+  /**
+   * Ensure conditional stylesheets are added.
+   */
+  function testThemeConditionalStylesheets() {
+    $this->drupalGet('theme-test/suggestion');
+    $pattern = '/<!--\[if\ lte\ IE\ 8\]>.*ie.css.*<!\[endif\]-->/simx';
+    $this->assertPattern($pattern, t('Conditional stylesheet added via theme .info file was found.'));
+  }
 }
 
 /**
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.954
diff -u -p -r1.954 system.module
--- modules/system/system.module	18 Aug 2010 18:41:30 -0000	1.954
+++ modules/system/system.module	18 Aug 2010 21:36:06 -0000
@@ -2422,6 +2422,17 @@ function _system_rebuild_theme_data() {
       }
     }
     $themes[$key]->info['stylesheets'] = $pathed_stylesheets;
+    $pathed_stylesheets_conditional = array();
+    if (isset($themes[$key]->info['stylesheets-conditional'])) {
+      foreach ($themes[$key]->info['stylesheets-conditional'] as $condition => $stylesheets_conditional) {
+        foreach ($stylesheets_conditional as $media => $stylesheets) {
+          foreach ($stylesheets as $stylesheet) {
+            $pathed_stylesheets_conditional[$condition][$media][$stylesheet] = dirname($themes[$key]->uri) . '/' . $stylesheet;
+          }
+        }
+      }
+    }
+    $themes[$key]->info['stylesheets-conditional'] = $pathed_stylesheets_conditional;
 
     // Give the scripts proper path information.
     $scripts = array();
Index: themes/bartik/bartik.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/bartik/bartik.info,v
retrieving revision 1.3
diff -u -p -r1.3 bartik.info
--- themes/bartik/bartik.info	28 Jul 2010 01:40:39 -0000	1.3
+++ themes/bartik/bartik.info	18 Aug 2010 21:36:06 -0000
@@ -12,6 +12,9 @@ stylesheets[all][] = css/style.css
 stylesheets[all][] = css/colors.css
 stylesheets[print][] = css/print.css
 
+stylesheets-conditional[lte IE 8][all][] = css/ie.css
+stylesheets-conditional[lt IE 7][all][] = css/ie6.css
+
 scripts[] = scripts/search.js
 
 regions[header] = Header
Index: themes/bartik/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/bartik/template.php,v
retrieving revision 1.4
diff -u -p -r1.4 template.php
--- themes/bartik/template.php	9 Aug 2010 16:54:50 -0000	1.4
+++ themes/bartik/template.php	18 Aug 2010 21:36:06 -0000
@@ -21,10 +21,6 @@ function bartik_preprocess_html(&$variab
     || !empty($variables['page']['footer_fourthcolumn'])) {
     $variables['classes_array'][] = 'footer-columns';
   }
-
-  // Add conditional stylesheets for IE
-  drupal_add_css(path_to_theme() . '/css/ie.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE)));
-  drupal_add_css(path_to_theme() . '/css/ie6.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE)));
 }
 
 /**
Index: themes/garland/garland.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/garland.info,v
retrieving revision 1.9
diff -u -p -r1.9 garland.info
--- themes/garland/garland.info	1 Dec 2009 15:57:40 -0000	1.9
+++ themes/garland/garland.info	18 Aug 2010 21:36:06 -0000
@@ -7,4 +7,5 @@ core = 7.x
 engine = phptemplate
 stylesheets[all][] = style.css
 stylesheets[print][] = print.css
+stylesheets-conditional[lt IE 7][all][] = fix-ie.css
 settings[garland_width] = fluid
Index: themes/garland/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/template.php,v
retrieving revision 1.41
diff -u -p -r1.41 template.php
--- themes/garland/template.php	30 Jul 2010 02:47:28 -0000	1.41
+++ themes/garland/template.php	18 Aug 2010 21:36:06 -0000
@@ -41,8 +41,6 @@ function garland_preprocess_html(&$vars)
   if (theme_get_setting('garland_width') == 'fluid') {
     $vars['classes_array'][] = 'fluid-width';
   }
-  // Add conditional CSS for IE6.
-  drupal_add_css(path_to_theme() . '/fix-ie.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE)));
 }
 
 /**
Index: themes/seven/seven.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/seven/seven.info,v
retrieving revision 1.5
diff -u -p -r1.5 seven.info
--- themes/seven/seven.info	14 Jan 2010 06:47:54 -0000	1.5
+++ themes/seven/seven.info	18 Aug 2010 21:36:06 -0000
@@ -7,6 +7,8 @@ core = 7.x
 engine = phptemplate
 stylesheets[screen][] = reset.css
 stylesheets[screen][] = style.css
+stylesheets-conditional[lte IE 8][all][] = ie.css
+stylesheets-conditional[lt IE 7][all][] = ie6.css
 settings[shortcut_module_link] = 1
 regions[content] = Content
 regions[help] = Help
Index: themes/seven/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/seven/template.php,v
retrieving revision 1.20
diff -u -p -r1.20 template.php
--- themes/seven/template.php	14 Aug 2010 00:43:24 -0000	1.20
+++ themes/seven/template.php	18 Aug 2010 21:36:06 -0000
@@ -14,16 +14,6 @@ function seven_preprocess_maintenance_pa
 }
 
 /**
- * Override or insert variables into the html template.
- */
-function seven_preprocess_html(&$vars) {
-  // Add conditional CSS for IE8 and below.
-  drupal_add_css(path_to_theme() . '/ie.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
-  // Add conditional CSS for IE6.
-  drupal_add_css(path_to_theme() . '/ie6.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE)));
-}
-
-/**
  * Override or insert variables into the page template.
  */
 function seven_preprocess_page(&$vars) {
Index: themes/tests/test_theme/test_theme.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/tests/test_theme/test_theme.info,v
retrieving revision 1.1
diff -u -p -r1.1 test_theme.info
--- themes/tests/test_theme/test_theme.info	21 Mar 2010 04:05:24 -0000	1.1
+++ themes/tests/test_theme/test_theme.info	18 Aug 2010 21:36:06 -0000
@@ -3,4 +3,7 @@ name = Test theme
 description = Theme for testing the theme system
 core = 7.x
 engine = phptemplate
-hidden = TRUE
\ No newline at end of file
+hidden = TRUE
+stylesheets-conditional[lte IE 8][all][] = ie.css
+stylesheets-conditional[+gte IE 8][all][] = ie-8-and-others.css
+stylesheets-conditional[+!IE][all][] = all-but-ie.css
