Commits

Joey Smith committed b84ad5e Merge

Merge pull request #93 from khaliy/master

Fix https://github.com/yui/yuicompressor/issues/64

Comments (0)

Files changed (3)

src/com/yahoo/platform/yui/compressor/CssCompressor.java

 
         return sb.toString();
     }
+    
+    private String preserveOldIESpecificMatrixDefinition(String css, ArrayList preservedTokens) {
+        StringBuffer sb = new StringBuffer();
+        Pattern p = Pattern.compile("\\s*filter:\\s*progid:DXImageTransform.Microsoft.Matrix\\(([^\\)]+)\\);");
+        Matcher m = p.matcher(css);
+        while (m.find()) {
+            String token = m.group(1);
+            preservedTokens.add(token);
+            String preserver = "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___";
+            m.appendReplacement(sb, "filter:progid:DXImageTransform.Microsoft.Matrix(" + preserver + ");");
+        }
+        m.appendTail(sb);
+        return sb.toString();
+    }
 
     public void compress(Writer out, int linebreakpos)
             throws IOException {
         // Normalize all whitespace strings to single spaces. Easier to work with that way.
         css = css.replaceAll("\\s+", " ");
 
+        css = this.preserveOldIESpecificMatrixDefinition(css, preservedTokens);
+
         // Remove the spaces before the things that should not have spaces before them.
         // But, be careful not to turn "p :link {...}" into "p:link{...}"
         // Swap out any pseudo-class colons with the token, and then swap back.
         css = css.replaceAll(";;+", ";");
 
         // restore preserved comments and strings
-        for(i = 0, max = preservedTokens.size(); i < max; i++) {
+        for(i = preservedTokens.size() - 1; i >= 0 ; i--) {
             css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens.get(i).toString());
         }
 

tests/old-ie-filter-matrix.css

+.a {
+filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');
+}
+.b {
+    display: none;
+    filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');
+    vertical-align: bottom;
+}

tests/old-ie-filter-matrix.css.min

+.a{filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand')}.b{display:none;filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.9914448613738104, M12=-0.13052619222005157, M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');vertical-align:bottom}