blib/lib/CSS/Compressor.pm

filter: Statementstmt 100% 72 / 72 Branchbran 100% 8 / 8 Conditioncond 69.5% 16 / 23 MC/DCmcdc 27.2% 3 / 11 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 87.5% 105 / 120 SCAR 24.9
CC
12
Cov
93%
css_compress
12.1
BEGIN
1.0
BEGIN
1.0
CRAP 12.0
↑ Summary
1 package CSS::Compressor;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our @EXPORT_OK = qw( css_compress );
9  
10 3 our $VERSION = '0.02';
11  
12 3 our $MARKER;
13  
14 # take package name, replace double colons with underscore and use that as
15 # marker for search and replace operations
16 BEGIN {
17 3 ▶ $MARKER = uc __PACKAGE__;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 $MARKER =~ tr!:!_!s;
19 }
20  
21 # build optimized regular expression variables ( foo -> [Ff][Oo][Oo] )
22 my (
23 3 ▶ $RE_BACKGROUND_POSITION,
Branch: 1 branch
BranchTrueFalseTotal
/[a-zA-Z]/ ? : 642 57 699
24 $RE_TRANSFORM_ORIGIN_MOZ,
25 $RE_TRANSFORM_ORIGIN_MS,
26 $RE_TRANSFORM_ORIGIN_O,
27 $RE_TRANSFORM_ORIGIN_WEBKIT,
28 $RE_TRANSFORM_ORIGIN,
29 $RE_BORDER,
30 $RE_BORDER_TOP,
31 $RE_BORDER_RIGHT,
32 $RE_BORDER_BOTTOM,
33 $RE_BORDER_LEFT,
34 $RE_OUTLINE,
35 $RE_BACKGROUND,
36 $RE_ALPHA_FILTER,
37 ) = map +(
38 join '' => map m![a-zA-Z]!
39 ? '['.ucfirst($_).lc($_).']'
40 : '\\'.$_,
41 split m//
42 ) => qw[
43 background-position
44 moz-transform-origin
45 ms-transform-origin
46 o-transform-origin
47 webkit-transform-origin
48 transform-origin
49 border
50 border-top
51 border-right
52 border-bottom
53 border-right
54 outline
55 background
56 progid:DXImageTransform.Microsoft.Alpha(Opacity=
57 ];
58  
59 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60 # compress
61 #
62 # IN: 1 uncompressed CSS
63 # OUT: 1 compressed CSS
64  
65 sub css_compress {
66 29 ▶ my ( $css ) = @_;
Subroutine css_compress: called CC=12 SCAR=24.9
Pod documented
67 29 my @comments,
68 my @tokens;
69  
70 # collect all comment blocks...
71 29 $css =~ s! /\* (.*?) \*/
72 38 ! '/*___'.$MARKER.'_PRESERVE_CANDIDATE_COMMENT_'.
73 ( -1 + push @comments => $1 ).'___*/'
74 !sogex;
75  
76 # preserve strings so their content doesn't get accidentally minified
77 29 $css =~ s! " ( [^"\\]*(?:\\.[^"\\]*)* ) " !
78 14 $_ = $1,
79  
80 # maybe the string contains a comment-like substring?
81 # one, maybe more? put'em back then
82 s/___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___/$comments[$1]/go,
83  
84 # minify alpha opacity in filter strings
85 s/$RE_ALPHA_FILTER/alpha(opacity=/go,
86  
87 '"___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_).'___"'
88 !sgxe;
89 29 $css =~ s! ' ( [^'\\]*(?:\\.[^'\\]*)* ) ' !
90 7 $_ = $1,
91  
92 s/___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___/$comments[$1]/go,
93  
94 s/$RE_ALPHA_FILTER/alpha(opacity=/go,
95  
96 '\'___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_).'___\''
97 !sgxe;
98  
99 # strings are safe, now wrestle the comments
100  
101 # ! in the first position of the comment means preserve
102 # so push to the preserved tokens while stripping the !
103 0 == index $_->[1] => '!'
104 and
105 $css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
106 10 ▶ '___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_->[1]).'___'!e
Condition100%3/3
0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e
!ll&&!rl&&r
2611
MC/DC100%2/2
0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e
0 == length $_->[1] $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e
Truth table100%3/3
A and B
A= 0 == length $_->[1]B= $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e
ABresult
0X0
100
111
107  
108 # keep empty comments after child selectors (IE7 hack)
109 # e.g. html >/**/ body
110 or 0 == length $_->[1]
111 and
112 $css =~ s!>/\*___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
113 1 ▶ '>/*___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '').'___'!e
Condition44%4/9
"\\" eq substr($_->[1], -1) and ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e and ++$_->[0] and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e)
!ll&&!rl&&r
2520
$css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e and ++$_->[0] and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e
!ll&&!rl&&r
020
$css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e and ++$_->[0]
!ll&&!rl&&r
002
MC/DC0%0/4
"\\" eq substr($_->[1], -1) and ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e and ++$_->[0] and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e)
"\\" eq substr($_->[1], -1) $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e ++$_->[0] $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e
Truth table0%0/5
A and B and C and D
A= "\\" eq substr($_->[1], -1)B= $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/eC= ++$_->[0]D= $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e
ABCDresult
0XXX0
10XX0
110X0
11100
11111
114  
115 # \ in the last position looks like hack for Mac/IE5
116 # shorten that to /*\*/ and the next one to /**/
117 or '\\' eq substr $_->[1] => -1
118 and
119 $css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
120 2 '___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '\\').'___'!e &&
121 # attention: inline modification
122 ++$_->[0] &&
123 $css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
124 2 '___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '').'___'!e
125  
126 29 ▶ for map +[ $_, $comments[$_] ], 0..$#comments;
Branch: 1 branch
BranchTrueFalseTotal
0 == index($_->[1], "!") and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e or 0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e or "\\" eq substr($_->[1], -1) and ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "\\")) . '___';/e and ++$_->[0] and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';/e) 27 11 38
Condition77%7/9
0 == index($_->[1], '!') && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e || 0 == length $_->[1] && $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';]e || '\\' eq substr($_->[1], -1) && ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '\\')) . '___';/e && ++$_->[0] && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';/e)
l!l&&r!l&&!r
11270
0 == index($_->[1], "!") and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e or 0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e
l!l&&r!l&&!r
10325
0 == index($_->[1], "!") and $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e
!ll&&!rl&&r
28010
MC/DC0%0/4
0 == index($_->[1], '!') && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e || 0 == length $_->[1] && $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';]e || '\\' eq substr($_->[1], -1) && ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '\\')) . '___';/e && ++$_->[0] && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';/e)
0 == index($_->[1], "!") $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/e 0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]e '\\' eq substr($_->[1], -1) && ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '\\')) . '___';/e && ++$_->[0] && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';/e)
Truth table14%1/7
A and B or C || D
A= 0 == index($_->[1], "!")B= $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, $_->[1])) . '___';/eC= 0 == length $_->[1] and $css =~ s[>/\*___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___]['>/*___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, "")) . '___';]eD= '\\' eq substr($_->[1], -1) && ($css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '\\')) . '___';/e && ++$_->[0] && $css =~ s/___$CSS::Compressor::MARKER_PRESERVE_CANDIDATE_COMMENT_$_->[0]___/'___' . $CSS::Compressor::MARKER . '_PRESERVED_TOKEN_' . (-1 + push(@tokens, '')) . '___';/e)
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
127  
128 # in all other cases kill the comment
129 29 $css =~ s!/\*___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___\*/!!g;
130  
131 # Normalize all whitespace strings to single spaces. Easier to work with that way.
132 29 $css =~ s!\s+! !g;
133  
134  
135 # From here on all white space is just space - no more multi line matches!
136  
137  
138 # Remove the spaces before the things that should not have spaces before them.
139 # But, be careful not to turn "p :link {...}" into "p:link{...}"
140 # Swap out any pseudo-class colons with the token, and then swap back.
141 29 $css =~ s! ( \} [^{:]+ (?:: [^{:]+)+ \{ ) !
142 6 $_ = $1,
143 s/:/___${MARKER}_PSEUDOCLASSCOLON___/go,
144 s/\\([\\\$])/\\$1/g,
145 $_
146 !gxe;
147 29 $css =~ s! ( ^ [^{:]+ (?:: [^{:]+)+ \{ ) !
148 6 $_ = $1,
149 s/:/___${MARKER}_PSEUDOCLASSCOLON___/go,
150 s/\\([\\\$])/\\$1/g,
151 $_
152 !xe;
153  
154 # Remove spaces before the things that should not have spaces before them.
155 29 $css =~ s/ +([!{};:>+()\],])/$1/g;
156  
157 # bring back the colon
158 29 $css =~ s!___${MARKER}_PSEUDOCLASSCOLON___!:!go;
159  
160 # retain space for special IE6 cases
161 29 $css =~ s!:first\-(line|letter)([{,])!:first-$1 $2!g;
162  
163 # no space after the end of a preserved comment
164 29 $css =~ s!\*/ !*/!g;
165  
166 # If there is a @charset, then only allow one, and push to the top of the file.
167 29 $css =~ s!^(.*)(\@charset "[^"]*";)!$2$1!g;
168 29 $css =~ s!^( *\@charset [^;]+; *)+!$1!g;
169  
170 # Put the space back in some cases, to support stuff like
171 # @media screen and (-webkit-min-device-pixel-ratio:0){
172 29 $css =~ s! \b and \( !and (!gx;
173  
174 # Remove the spaces after the things that should not have spaces after them.
175 29 $css =~ s/([!{},;:>+(\[]) +/$1/g;
176  
177 # Replace 0.6 to .6, but only when preceded by :
178 29 $css =~ s!:0+\.([0-9]+)!:.$1!g;
179  
180 # remove unnecessary semicolons
181 29 $css =~ s!;+\}!}!g;
182  
183 # Replace 0(px,em,%) with 0
184 29 $css =~ s!([ :]0)(?:px|em|%|in|cm|mm|pc|pt|ex)!$1!g;
185  
186 # Replace 0 0 0 0; with 0.
187 29 $css =~ s!:0(?: 0){0,3}(;|})!:0$1!g;
188  
189 # Replace background-position:0; with background-position:0 0;
190 # same for transform-origin
191 29 $css =~ s! $RE_BACKGROUND_POSITION :0 ( [;}] ) !background-position:0 0$1!gox;
192 29 $css =~ s! $RE_TRANSFORM_ORIGIN_MOZ :0 ( [;}] ) !moz-transform-origin:0 0$1!gox;
193 29 $css =~ s! $RE_TRANSFORM_ORIGIN_MS :0 ( [;}] ) !ms-transform-origin:0 0$1!gox;
194 29 $css =~ s! $RE_TRANSFORM_ORIGIN_O :0 ( [;}] ) !o-transform-origin:0 0$1!gox;
195 29 $css =~ s! $RE_TRANSFORM_ORIGIN_WEBKIT :0 ( [;}] ) !webkit-transform-origin:0 0$1!gox;
196 29 $css =~ s! $RE_TRANSFORM_ORIGIN :0 ( [;}] ) !transform-origin:0 0$1!gox;
197  
198 # Replace 0.6 to .6, but only when preceded by : or a white-space
199 29 $css =~ s! 0+\.([0-9]+)! .$1!g;
200  
201 # Shorten colors from rgb(51,102,153) to #336699
202 # This makes it more likely that it'll get further compressed in the next step.
203 29 $css =~ s!rgb *\( *([0-9, ]+) *\)!
204 2 sprintf('#%02x%02x%02x',
205 split(m/ *, */, $1, 3) )
206 !ge;
207  
208 # Shorten colors from #AABBCC to #ABC. Note that we want to make sure
209 # the color is not preceded by either ", " or =. Indeed, the property
210 # filter: chroma(color="#FFFFFF");
211 # would become
212 # filter: chroma(color="#FFF");
213 # which makes the filter break in IE.
214 # We also want to make sure we're only compressing #AABBCC patterns inside
215 # { }, not id selectors ( #FAABAC {} ).
216 # Further we want to avoid compressing invalid values (e.g. #AABBCCD to #ABCD).
217 29 $css =~ s!
218 (=[ ]*?["']?)?
219 \#
220 ([0-9a-fA-F]) # a
221 ([0-9a-fA-F]) # a
222 ([0-9a-fA-F]) # b
223 ([0-9a-fA-F]) # b
224 ([0-9a-fA-F]) # c
225 ([0-9a-fA-F]) # c
226 \b
227 ([^{.])
228 !
229 26 ▶ ( $1 || '' ) ne ''
Branch: 2 branches
BranchTrueFalseTotal
($1 || '') ne '' ? : 2 24 26
lc $2 . $4 . $6 eq lc $3 . $5 . $7 ? : 19 5 24
Condition100%2/2
$1 || ''
l!l
224
MC/DC100%1/1
$1 || ''
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
230 # keep as compression will break filters
231 ? $1.'#'.$2.$3.$4.$5.$6.$7.$8
232 # not a filter, safe to compress
233 : '#'.lc(
234 lc $2.$4.$6 eq lc $3.$5.$7
235 ? $2.$4.$6
236 : $2.$3.$4.$5.$6.$7
237 ).$8
238 !gex;
239  
240 # border: none -> border:0
241 29 $css =~ s! $RE_BORDER :none ( [;}] ) !border:0$1!gox;
242 29 $css =~ s! $RE_BORDER_TOP :none ( [;}] ) !border-top:0$1!gox;
243 29 $css =~ s! $RE_BORDER_RIGHT :none ( [;}] ) !border-right:0$1!gox;
244 29 $css =~ s! $RE_BORDER_BOTTOM :none ( [;}] ) !border-bottom:0$1!gox;
245 29 $css =~ s! $RE_BORDER_LEFT :none ( [;}] ) !border-left:0$1!gox;
246 29 $css =~ s! $RE_OUTLINE :none ( [;}] ) !outline:0$1!gox;
247 29 $css =~ s! $RE_BACKGROUND :none ( [;}] ) !background:0$1!gox;
248  
249 # shorter opacity IE filter
250 29 $css =~ s!$RE_ALPHA_FILTER!alpha(opacity=!go;
251  
252 # Remove empty rules.
253 29 $css =~ s![^{}/;]+\{\}!!g;
254  
255 # Replace multiple semi-colons in a row by a single one
256 # See SF bug #1980989
257 29 $css =~ s!;;+!;!g;
258  
259 # restore preserved comments and strings
260 29 $css =~ s!___${MARKER}_PRESERVED_TOKEN_([0-9]+)___!$tokens[$1]!go;
261  
262 # Trim the final string (for any leading or trailing white spaces)
263 29 $css =~ s!\A +!!;
264 29 $css =~ s! +\z!!;
265  
266 29 $css;
267 }
268  
269 3 1;
270  
271 __END__
↑ Summary