Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1214
diff -u -p -r1.1214 common.inc
--- includes/common.inc	5 Sep 2010 15:38:16 -0000	1.1214
+++ includes/common.inc	6 Sep 2010 23:58:40 -0000
@@ -2793,9 +2793,20 @@ function drupal_add_css($data = NULL, $o
         // key as $data could be a very long string of CSS.
         $css[] = $options;
         break;
+
+      case 'file':
+        // Local CSS files are keyed by basename; if a file with the same
+        // basename is added more than once, it gets overridden.
+        // By default, take over the filename as basename.
+        if (!isset($options['basename'])) {
+          $options['basename'] = basename($data);
+        }
+        $css[$options['basename']] = $options;
+        break;
+
       default:
-        // Local and external files must keep their name as the associative key
-        // so the same CSS file is not be added twice.
+        // External files are keyed by their full URI, so the same CSS file is
+        // not added twice.
         $css[$data] = $options;
     }
   }
@@ -2826,6 +2837,8 @@ function drupal_add_css($data = NULL, $o
  *   A string of XHTML CSS tags.
  */
 function drupal_get_css($css = NULL) {
+  global $theme_info;
+
   if (!isset($css)) {
     $css = drupal_add_css();
   }
@@ -2836,17 +2849,12 @@ function drupal_get_css($css = NULL) {
   // Sort CSS items according to their weights.
   uasort($css, 'drupal_sort_weight');
 
-  // Remove the overridden CSS files. Later CSS files override former ones.
-  $previous_item = array();
-  foreach ($css as $key => $item) {
-    if ($item['type'] == 'file') {
-      // If defined, force a unique basename for this file.
-      $basename = isset($item['basename']) ? $item['basename'] : basename($item['data']);
-      if (isset($previous_item[$basename])) {
-        // Remove the previous item that shared the same base name.
-        unset($css[$previous_item[$basename]]);
+  // Allow themes to conditionally override module CSS files by basename.
+  if (!empty($theme_info->stylesheets_override)) {
+    foreach ($css as $key => $options) {
+      if (isset($options['basename']) && isset($theme_info->stylesheets_override[$options['basename']])) {
+        $css[$key]['data'] = $theme_info->stylesheets_override[$options['basename']];
       }
-      $previous_item[$basename] = $key;
     }
   }
 
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.609
diff -u -p -r1.609 theme.inc
--- includes/theme.inc	5 Sep 2010 02:21:37 -0000	1.609
+++ includes/theme.inc	6 Sep 2010 23:58:40 -0000
@@ -140,6 +140,10 @@ 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();
+  // List of CSS file basenames to override, pointing to the theme name that
+  // holds the final override.
+  // @todo Try to prepare this in _system_rebuild_theme_data() already.
+  $theme->stylesheets_override = array();
 
   // Grab stylesheets from base theme
   foreach ($base_theme as $base) {
@@ -150,6 +154,12 @@ function _drupal_theme_initialize($theme
         }
       }
     }
+    if (!empty($base->info['stylesheets-override'])) {
+      $base_theme_path = dirname($base->filename);
+      foreach ($base->info['stylesheets-override'] as $basename) {
+        $theme->stylesheets_override[$basename] = $base_theme_path . '/' . $basename;
+      }
+    }
   }
 
   // Add stylesheets used by this theme.
@@ -160,6 +170,11 @@ function _drupal_theme_initialize($theme
       }
     }
   }
+  if (!empty($theme->info['stylesheets-override'])) {
+    foreach ($theme->info['stylesheets-override'] as $basename) {
+      $theme->stylesheets_override[$basename] = $theme_path . '/' . $basename;
+    }
+  }
 
   // And now add the stylesheets properly
   foreach ($final_stylesheets as $media => $stylesheets) {
Index: modules/color/color.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/color/color.module,v
retrieving revision 1.90
diff -u -p -r1.90 color.module
--- modules/color/color.module	17 Aug 2010 22:05:22 -0000	1.90
+++ modules/color/color.module	6 Sep 2010 23:58:40 -0000
@@ -79,7 +79,6 @@ function _color_html_alter(&$vars) {
   // Override stylesheets.
   $color_paths = variable_get('color_' . $theme_key . '_stylesheets', array());
   if (!empty($color_paths)) {
-
     foreach ($themes[$theme_key]->stylesheets['all'] as $base_filename => $old_path) {
       // Loop over the path array with recolored CSS files to find matching
       // paths which could replace the non-recolored paths.
@@ -89,7 +88,7 @@ function _color_html_alter(&$vars) {
         if (basename($old_path) == basename($color_path)) {
           // Replace the path to the new css file.
           // This keeps the order of the stylesheets intact.
-          $vars['css'][$old_path]['data'] = $color_path;
+          $vars['css'][basename($old_path)]['data'] = $color_path;
         }
       }
     }
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.124
diff -u -p -r1.124 common.test
--- modules/simpletest/tests/common.test	5 Sep 2010 02:21:38 -0000	1.124
+++ modules/simpletest/tests/common.test	6 Sep 2010 23:59:59 -0000
@@ -574,16 +574,13 @@ class CascadingStylesheetsTestCase exten
   }
 
   /**
-   * Check default stylesheets as empty.
+   * Tests adding stylesheet files.
    */
-  function testDefault() {
+  function testAdd() {
+    // Check default stylesheets as empty.
     $this->assertEqual(array(), drupal_add_css(), t('Default CSS is empty.'));
-  }
 
-  /**
-   * Test that stylesheets in module .info files are loaded.
-   */
-  function testModuleInfo() {
+    // Test that stylesheets in module .info files are loaded.
     $this->drupalGet('');
 
     // Verify common_test.css in a STYLE media="all" tag.
@@ -599,48 +596,32 @@ class CascadingStylesheetsTestCase exten
       ':filename' => 'tests/common_test.print.css',
     ));
     $this->assertTrue(count($elements), "Stylesheet with media 'print' in module .info file found.");
-  }
 
-  /**
-   * Tests adding a file stylesheet.
-   */
-  function testAddFile() {
+    // Tests adding a file stylesheet.
     $path = drupal_get_path('module', 'simpletest') . '/simpletest.css';
     $css = drupal_add_css($path);
-    $this->assertEqual($css[$path]['data'], $path, t('Adding a CSS file caches it properly.'));
-  }
+    $this->assertEqual($css[basename($path)]['data'], $path, t('Adding a CSS file caches it properly.'));
 
-  /**
-   * Tests adding an external stylesheet.
-   */
-  function testAddExternal() {
+    // Tests adding an external stylesheet.
     $path = 'http://example.com/style.css';
     $css = drupal_add_css($path, 'external');
     $this->assertEqual($css[$path]['type'], 'external', t('Adding an external CSS file caches it properly.'));
-  }
 
-  /**
-   * Makes sure that reseting the CSS empties the cache.
-   */
-  function testReset() {
+    // Makes sure that reseting the CSS empties the cache.
     drupal_static_reset('drupal_add_css');
     $this->assertEqual(array(), drupal_add_css(), t('Resetting the CSS empties the cache.'));
   }
 
   /**
-   * Tests rendering the stylesheets.
+   * Tests stylesheet rendering.
    */
-  function testRenderFile() {
+  function testRender() {
     $css = drupal_get_path('module', 'simpletest') . '/simpletest.css';
     drupal_add_css($css);
     $styles = drupal_get_css();
     $this->assertTrue(strpos($styles, $css) > 0, t('Rendered CSS includes the added stylesheet.'));
-  }
 
-  /**
-   * Tests rendering an external stylesheet.
-   */
-  function testRenderExternal() {
+    // Tests rendering an external stylesheet.
     $css = 'http://example.com/style.css';
     drupal_add_css($css, 'external');
     $styles = drupal_get_css();
Index: themes/bartik/bartik.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/bartik/bartik.info,v
retrieving revision 1.4
diff -u -p -r1.4 bartik.info
--- themes/bartik/bartik.info	5 Sep 2010 02:21:38 -0000	1.4
+++ themes/bartik/bartik.info	6 Sep 2010 23:58:40 -0000
@@ -1,5 +1,4 @@
 ; $Id: bartik.info,v 1.4 2010/09/05 02:21:38 dries Exp $
-
 name = Bartik
 description = A flexible, recolorable theme with many regions.
 package = Core
@@ -34,4 +33,3 @@ regions[footer_fourthcolumn] = Footer fo
 regions[footer] = Footer
 
 settings[shortcut_module_link] = 0
-
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	6 Sep 2010 23:58:40 -0000
@@ -7,6 +7,8 @@ core = 7.x
 engine = phptemplate
 stylesheets[screen][] = reset.css
 stylesheets[screen][] = style.css
+stylesheets-override[] = vertical-tabs.css
+stylesheets-override[] = jquery.ui.theme.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	6 Sep 2010 23:58:40 -0000
@@ -89,16 +89,3 @@ function seven_tablesort_indicator($vari
   }
 }
 
-/**
- * Implements hook_css_alter().
- */
-function seven_css_alter(&$css) {
-  // Use Seven's vertical tabs style instead of the default one.
-  if (isset($css['misc/vertical-tabs.css'])) {
-    $css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';
-  }
-  // Use Seven's jQuery UI theme style instead of the default one.
-  if (isset($css['misc/ui/jquery.ui.theme.css'])) {
-    $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
-  }
-}
