2002/css-validator/org/w3c/css/properties/css CssBackground.java,1.5,1.6

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css
In directory hutz:/tmp/cvs-serv14741/properties/css

Modified Files:
	CssBackground.java 
Log Message:
added mark/reset to navigate in the CssExpression, modified parsing of background-position in CSS3 background

Index: CssBackground.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css/CssBackground.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBackground.java	8 Jan 2010 21:38:01 -0000	1.5
+++ CssBackground.java	9 Jan 2010 10:36:47 -0000	1.6
@@ -235,26 +235,36 @@
         CssExpression exp = new CssExpression();
         char op = expression.getOperator();
         exp.addValue(expression.getValue());
+        int last_val = -1;
 
         CssBackgroundPosition bg_pos;
         bg_pos = new CssBackgroundPosition(ac, exp, check);
         // good we have a valid value, try something better..
-        try {
-            for (int i = 0; i < 3; i++) {
-                if ((op == SPACE) && !expression.end()) {
-                    expression.next();
-                    if (expression.end()) {
-                        break;
-                    }
-                    exp.addValue(expression.getValue());
-                    exp.starts();
+        expression.mark();
+        // we MUST try all the cases, as we can have something
+        // invalid using 3 values (incompatible definitions)
+        // but valid using 4 values...
+        // example top 12% is invalid, top 12% center is valid...
+        for (int i = 0; i < 3; i++) {
+            if ((op == SPACE) && !expression.end()) {
+                expression.next();
+                if (expression.end()) {
+                    break;
+                }
+                exp.addValue(expression.getValue());
+                exp.starts();
+                try {
                     bg_pos = new CssBackgroundPosition(ac, exp, check);
-
+                    last_val = i;
+                } catch (InvalidParamException ipe) {
                 }
+
             }
-        } catch (InvalidParamException ipe) {
-            // roll back
-            expression.precedent();
+        }
+        expression.reset();
+        while (last_val >= 0) {
+            expression.next();
+            last_val--;
         }
         return bg_pos.get();
     }

Received on Saturday, 9 January 2010 10:36:51 UTC