From 8b221266daf043902750da9788484e410b985ab6 Mon Sep 17 00:00:00 2001
From: JohnAlbin <virtually.johnalbin@gmail.com>
Date: Mon, 11 Feb 2013 16:59:52 +0800
Subject: [PATCH] Issue #1924436: Remove separate CSS_AGGREGATE_SYSTEM
 aggregate file.

---
 core/includes/common.inc                                    | 13 +++----------
 .../Drupal/system/Tests/Common/CascadingStylesheetsTest.php |  9 +++++----
 core/modules/system/system.module                           |  8 ++++----
 3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 617d27b..7aea1e3 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -68,11 +68,6 @@
 const SAVED_DELETED = 3;
 
 /**
- * The default aggregation group for system CSS files added to the page.
- */
-const CSS_AGGREGATE_SYSTEM = -100;
-
-/**
  * The default aggregation group for CSS files added to the page.
  */
 const CSS_AGGREGATE_DEFAULT = 0;
@@ -2523,7 +2518,6 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
  *     would be 'node.js.css'.
  *   - 'group': A number identifying the aggregation group in which to add the
  *     stylesheet. Available constants are:
- *     - CSS_AGGREGATE_SYSTEM: Any system-layer CSS.
  *     - CSS_AGGREGATE_DEFAULT: (default) Any module-layer CSS.
  *     - CSS_AGGREGATE_THEME: Any theme-layer CSS.
  *     The aggregate group number affects load order and the CSS cascade.
@@ -2748,10 +2742,9 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
  * @see drupal_add_js()
  */
 function drupal_sort_css_js($a, $b) {
-  // First order by group, so that, for example, all items in the
-  // CSS_AGGREGATE_SYSTEM group appear before items in the CSS_AGGREGATE_DEFAULT
-  // group, which appear before all items in the CSS_AGGREGATE_THEME group.
-  // Modules may create additional groups by defining their own constants.
+  // First order by group, so that all items in the CSS_AGGREGATE_DEFAULT group
+  // appear before items in the CSS_AGGREGATE_THEME group. Modules may create
+  // additional groups by defining their own constants.
   if ($a['group'] < $b['group']) {
     return -1;
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
index 746ab99..4289f56 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
@@ -152,12 +152,13 @@ function testRenderInlineFullPage() {
    * Tests CSS ordering.
    */
   function testRenderOrder() {
-    // A module CSS file.
+    // Load a module CSS file.
     drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
-    // A few system CSS files, ordered in a strange way.
+    // Load a few system CSS files in a custom, early-loading aggregate group.
+    $test_aggregate_group = -100;
     $system_path = drupal_get_path('module', 'system');
-    drupal_add_css($system_path . '/system.base.css', array('group' => CSS_AGGREGATE_SYSTEM, 'weight' => -10));
-    drupal_add_css($system_path . '/system.theme.css', array('group' => CSS_AGGREGATE_SYSTEM));
+    drupal_add_css($system_path . '/system.base.css', array('group' => $test_aggregate_group, 'weight' => -10));
+    drupal_add_css($system_path . '/system.theme.css', array('group' => $test_aggregate_group));
 
     $expected = array(
       $system_path . '/system.base.css',
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 70b8dab..8db88e7 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2563,12 +2563,12 @@ function system_init() {
  */
 function system_page_build(&$page) {
   $path = drupal_get_path('module', 'system');
-  // Use the CSS_AGGREGATE_SYSTEM group to load these early.
-  $page['#attached']['css'][$path . '/system.base.css'] = array('group' => CSS_AGGREGATE_SYSTEM, 'every_page' => TRUE);
+  // Adjust the weights to load these early.
+  $page['#attached']['css'][$path . '/css/system.module.css'] = array('weight' => CSS_COMPONENT - 10, 'every_page' => TRUE);
+  $page['#attached']['css'][$path . '/css/system.skin.css'] = array('weight' => CSS_SKIN - 10, 'every_page' => TRUE);
   if (path_is_admin(current_path())) {
-    $page['#attached']['css'][$path . '/system.admin.css'] = array('group' => CSS_AGGREGATE_SYSTEM);
+    $page['#attached']['css'][$path . '/css/system.admin.css'] = array('weight' => CSS_COMPONENT - 10);
   }
-  $page['#attached']['css'][$path . '/system.theme.css'] = array('group' => CSS_AGGREGATE_SYSTEM, 'every_page' => TRUE);
 }
 
 /**
-- 
1.8.2.1

