Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: Source/core/css/make-css-file-arrays.pl

Issue 107713007: Improve user agent stylesheet minification Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/make-css-file-arrays.pl
diff --git a/Source/core/css/make-css-file-arrays.pl b/Source/core/css/make-css-file-arrays.pl
index 66eb7dfb0e4cd9f8215eff72a47ac4618f8704b7..811d7f958fcca6d7ca7c821d6fc95d0cdf7d265d 100755
--- a/Source/core/css/make-css-file-arrays.pl
+++ b/Source/core/css/make-css-file-arrays.pl
@@ -65,10 +65,13 @@ for my $in (@ARGV) {
# Crunch whitespace just to make it a little smaller.
# Could do work to avoid doing this inside quote marks but our files don't have runs of spaces in quotes.
- # Could crunch further based on places where whitespace is optional.
- $text =~ s|\s+| |gs;
- $text =~ s|^ ||;
- $text =~ s| $||;
+ # FIXME: Use a proper css minifier to crunch this further.
+ $text =~ s|^[\s]+||gm; # remove optional leading spaces.
+ $text =~ s|[\s]*:[\s]*|:|gm; # remove optional spaces around colons.
+ $text =~ s|[\s]*{[\s]*|{|gm; # remove optional spaces around open braces.
+ $text =~ s|[\s;]*}[\s]*|}|gm; # remove optional spaces around end braces and semicolons before end braces.
+ $text =~ s|[\s]*,[\s]*|,|gm; # remove optional spaces around commas.
+ $text =~ s|\R||g; # remove newlines.
# Write out a C array of the characters.
my $length = length $text;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698