Merge branch 'wip-MDL-32081-m23' of git://github.com/samhemelryk/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 3 Apr 2012 08:08:18 +0000 (16:08 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 3 Apr 2012 08:08:18 +0000 (16:08 +0800)
lib/csslib.php
lib/simpletest/testcsslib.php

index 03d728c..5fc0f9b 100644 (file)
@@ -638,6 +638,13 @@ class css_optimiser {
                     }
                     switch ($char) {
                         case ';':
+                            if ($inparenthesis) {
+                                $buffer .= $char;
+                                // continue 1: The switch processing chars
+                                // continue 2: The switch processing the state
+                                // continue 3: The for loop
+                                continue 3;
+                            }
                             $currentrule->add_style($buffer);
                             $buffer = '';
                             $inquotes = false;
@@ -656,6 +663,21 @@ class css_optimiser {
                             $this->rawrules++;
                             $buffer = '';
                             $inquotes = false;
+                            $inparenthesis = false;
+                            // continue 1: The switch processing chars
+                            // continue 2: The switch processing the state
+                            // continue 3: The for loop
+                            continue 3;
+                        case '(':
+                            $inparenthesis = true;
+                            $buffer .= $char;
+                            // continue 1: The switch processing chars
+                            // continue 2: The switch processing the state
+                            // continue 3: The for loop
+                            continue 3;
+                        case ')':
+                            $inparenthesis = false;
+                            $buffer .= $char;
                             // continue 1: The switch processing chars
                             // continue 2: The switch processing the state
                             // continue 3: The for loop
index abe3e1b..cea549a 100644 (file)
@@ -112,6 +112,18 @@ class css_optimiser_test extends UnitTestCase {
                   .block_tree .collapsed .tree_item.branch {background-image: url([[pix:t/collapsed]]);}';
         $cssout = '.block_tree .tree_item.emptybranch{background:url([[pix:t/collapsed_empty]]) no-repeat 0% 5%;} .block_tree .collapsed .tree_item.branch{background-image:url([[pix:t/collapsed]]);}';
         $this->assertEqual($cssout, $optimiser->process($cssin));
+
+        $cssin = '#nextLink{background:url(data:image/gif;base64,AAAA);}';
+        $cssout = '#nextLink{background-image:url(data:image/gif;base64,AAAA);}';
+        $this->assertEqual($cssout, $optimiser->process($cssin));
+
+        $cssin = '#nextLink{background-image:url(data:image/gif;base64,AAAA);}';
+        $cssout = '#nextLink{background-image:url(data:image/gif;base64,AAAA);}';
+        $this->assertEqual($cssout, $optimiser->process($cssin));
+
+        $cssin = '.test {background: #123456 url(data:image/gif;base64,AAAA) no-repeat top left;}';
+        $cssout = '.test{background:#123456 url(data:image/gif;base64,AAAA) no-repeat top left;}';
+        $this->assertEqual($cssout, $optimiser->process($cssin));
     }
 
     /**
@@ -501,8 +513,8 @@ class css_optimiser_test extends UnitTestCase {
         $this->assertEqual($cssout, $optimiser->process($cssin));
 
         // Test complex CSS rules that don't really exist but mimic other CSS rules
-        $cssin  = '.one {master-of-destruction: explode(\' \', "What madness";}';
-        $cssout = '.one{master-of-destruction:explode(\' \', "What madness";}';
+        $cssin  = '.one {master-of-destruction: explode(\' \', "What madness");}';
+        $cssout = '.one{master-of-destruction:explode(\' \', "What madness");}';
         $this->assertEqual($cssout, $optimiser->process($cssin));
 
         // Test some complex IE css... I couldn't even think of a more complext solution