diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-06-21 01:35:25 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-06-21 01:35:25 +0000 |
commit | 34dbad55c589b8c1f3c3fc1eadfb88d989516695 (patch) | |
tree | d7be6b0f6b0ceab19910886b65dbc37902526508 /includes | |
parent | 605362393ddef1472d25705647326002b68992d5 (diff) | |
download | brdo-34dbad55c589b8c1f3c3fc1eadfb88d989516695.tar.gz brdo-34dbad55c589b8c1f3c3fc1eadfb88d989516695.tar.bz2 |
#444228 follow-up by Tri, ridgerunner, Damien Tournoud, et al: Improve Optimize CSS performance by removing support for Mac IE 5.5 comment hacks, and add tests. (Apologies; some of this went in with a previous commit http://drupal.org/cvs?commit=382522)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/includes/common.inc b/includes/common.inc index 639861cd9..a170ee1bb 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3266,14 +3266,21 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) { if ($optimize) { // Perform some safe CSS optimizations. - $contents = preg_replace('{ - (?<=\\\\\*/)([^/\*]+/\*)([^\*/]+\*/) # Add a backslash also at the end ie-mac hack comment, so the next pass will not touch it. - # The added backslash does not affect the effectiveness of the hack. - }x', '\1\\\\\2', $contents); - $contents = preg_replace('< - \s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses. - /\*[^*\\\\]*\*+([^/*][^*]*\*+)*/ | # Remove comments that are not CSS hacks. - >x', '\1', $contents); + // Regexp to match comment blocks. + $comment = '/\*[^*]*\*+(?:[^/*][^*]*\*+)*/'; + // Regexp to match double quoted strings. + $double_quot = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"'; + // Regexp to match single quoted strings. + $single_quot = "'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'"; + $contents = preg_replace( + "<($double_quot|$single_quot)|$comment>Sus", // Strip all comment blocks + "$1", // but keep double/single + $contents); // quoted strings. + $contents = preg_replace( + '<\s*([@{}:;,]|\)\s|\s\()\s*>S', // Remove whitespace around separators, + '\1', $contents); // but keep space around parentheses. + // End the file with a new line. + $contents .= "\n"; } // Replaces @import commands with the actual stylesheet content. |