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

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

Modified Files:
	CssBackground.java 
Log Message:
added extra state (this should be rewritten) to cope with the new grammar <position> [ / <size> ]?, bumped the spec link

Index: CssBackground.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackground.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssBackground.java	18 Oct 2012 09:46:03 -0000	1.6
+++ CssBackground.java	23 Oct 2012 10:22:31 -0000	1.7
@@ -21,7 +21,7 @@
 import static org.w3c.css.values.CssOperator.SPACE;
 
 /**
- * @spec http://www.w3.org/TR/2012/WD-css3-background-20120214/#the-background
+ * @spec http://www.w3.org/TR/2012/CR-css3-background-20120724/#the-background
  * @see org.w3c.css.properties.css.CssBackgroundColor
  * @see org.w3c.css.properties.css.CssBackgroundImage
  * @see org.w3c.css.properties.css.CssBackgroundRepeat
@@ -126,7 +126,6 @@
 		CssExpression exp = new CssExpression();
 
 		exp.addValue(expression.getValue());
-		CssBackgroundRepeat bg_size;
 		repeat = new CssBackgroundRepeat(ac, exp, check);
 		// now check if we can add a second value ;)
 		if ((op == SPACE) && !expression.end()) {
@@ -240,11 +239,12 @@
 		char op;
 		CssExpression exp;
 		CssBackgroundValue v = new CssBackgroundValue();
-		boolean next_is_size, got_size;
+		boolean next_is_size, got_size, prev_is_position;
 		Object res;
 
 		next_is_size = false;
 		got_size = false;
+		prev_is_position = false;
 		while (!expression.end()) {
 			val = expression.getValue();
 			op = expression.getOperator();
@@ -252,6 +252,7 @@
 			switch (val.getType()) {
 				case CssTypes.CSS_HASH_IDENT:
 				case CssTypes.CSS_COLOR:
+					prev_is_position = false;
 					// we already got one, fail...
 					if (v.color != null || next_is_size || !is_final) {
 						throw new InvalidParamException("value", val,
@@ -266,6 +267,7 @@
 					break;
 
 				case CssTypes.CSS_URL:
+					prev_is_position = false;
 					// we already got one, fail...
 					if (v.bg_image != null || next_is_size) {
 						throw new InvalidParamException("value", val,
@@ -288,6 +290,7 @@
 				case CssTypes.CSS_NUMBER:
 				case CssTypes.CSS_LENGTH:
 				case CssTypes.CSS_PERCENTAGE:
+					prev_is_position = false;
 					// ok, so now we have a background position or size.
 					// and...
 					// in <bg_layer>: where '<bg-position>' must occur before
@@ -321,7 +324,8 @@
 						}
 						res = getCssBackgroundPositionValue(ac, expression, check);
 						op = expression.getOperator();
-						// we only have one vale so it should always be the case
+						prev_is_position = true;
+						// we only have one value so it should always be the case
 						if (res instanceof CssValue) {
 							v.bg_position = (CssValue) res;
 						} else {
@@ -332,6 +336,7 @@
 					}
 					break;
 				case CssTypes.CSS_IDENT:
+					prev_is_position = false;
 					// inherit is already taken care of...
 					CssIdent ident_val = (CssIdent) val;
 					if (CssBackgroundAttachment.isMatchingIdent(ident_val)) {
@@ -468,6 +473,7 @@
 							}
 							res = getCssBackgroundPositionValue(ac, expression, check);
 							op = expression.getOperator();
+							prev_is_position = true;
 							// we only have one vale so it should always be the case
 							if (res instanceof CssValue) {
 								v.bg_position = (CssValue) res;
@@ -494,6 +500,7 @@
 					// unrecognized or unwanted ident
 					// let it fail now
 				case CssTypes.CSS_FUNCTION:
+					prev_is_position = false;
 					// function can only be a value here
 					// we already got one, fail...
 					if (v.color != null || next_is_size || !is_final) {
@@ -509,6 +516,10 @@
 				// the infamous switch...
 				// note that we should check that we got something first.
 				case CssTypes.CSS_SWITCH:
+					if (!prev_is_position){
+						throw new InvalidParamException("operator", val,
+								getPropertyName(), ac);
+					}
 					next_is_size = true;
 					break;
 				default:
@@ -517,7 +528,7 @@
 			}
 
 			if (op != SPACE) {
-				throw new InvalidParamException("operator", val,
+				throw new InvalidParamException("operator", op,
 						getPropertyName(), ac);
 			}
 			expression.next();

Received on Tuesday, 23 October 2012 10:22:35 UTC