W3C home > Mailing lists > Public > www-validator-cvs@w3.org > March 2008

2002/css-validator/org/w3c/css/properties/css21 CssBackgroundCSS21.java,1.3,1.4 CssBackgroundPositionCSS21.java,1.3,1.4

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 25 Mar 2008 18:43:13 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1JeE77-0001te-4w@lionel-hutz.w3.org>

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

Modified Files:
	CssBackgroundCSS21.java CssBackgroundPositionCSS21.java 
Log Message:
background: red foo was validated as background: red 0% 0%, now it fails, as it should

Index: CssBackgroundPositionCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundPositionCSS21.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBackgroundPositionCSS21.java	19 Apr 2006 11:28:06 -0000	1.3
+++ CssBackgroundPositionCSS21.java	25 Mar 2008 18:43:11 -0000	1.4
@@ -43,13 +43,12 @@
 	setByUser();
 	CssValue val = expression.getValue();
 	char op  = expression.getOperator();
-
 	if (op != SPACE)
 	    throw new  InvalidParamException("operator",
 					     ((new Character(op)).toString()),
 					     ac);
 
-	if (val.equals(inherit)) {
+	if (inherit.equals(val)) {
 	    if(expression.getCount() > 1) {
 		throw new InvalidParamException("unrecognize", ac);
 	    }

Index: CssBackgroundCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundCSS21.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBackgroundCSS21.java	17 Mar 2008 18:23:13 -0000	1.3
+++ CssBackgroundCSS21.java	25 Mar 2008 18:43:10 -0000	1.4
@@ -1,6 +1,7 @@
 // $Id$
 // Author: Jean-Guilhem Rouel
-// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
+// Revised by: Yves Lafon
+// (c) COPYRIGHT MIT, ERCIM and Keio, 2005-2008.
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css21;
 
@@ -11,8 +12,11 @@
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssIdent;
 import org.w3c.css.values.CssValue;
 import org.w3c.css.values.CssString;
+import org.w3c.css.values.CssTypes;
+import org.w3c.css.values.CssURL;
 
 /**
  * CssBackgroundCSS21<br />
@@ -49,75 +53,109 @@
 	boolean manyValues = (expression.getCount() > 1);
 
 	while (find) {
-	    find = false;
 	    val = expression.getValue();
-	    op = expression.getOperator();
-
 	    if (val == null) {
 		break;
 	    }
-
+	    op = expression.getOperator();
+	    
 	    // if there are many values, we can't have inherit as one of them
-	    if(manyValues && val != null && val.equals(inherit)) {
+	    if(manyValues && val.equals(inherit)) {
 		throw new InvalidParamException("unrecognize", null, null, ac);
 	    }
-	    if(check && (val instanceof CssString)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
 
-	    if (getColor2() == null) {
-		try {
-		    setColor(new CssBackgroundColorCSS21(ac, expression));
-		    find = true;
-		} catch (InvalidParamException e) {
-		    // nothing to do, image will test this value
+	    switch (val.getType()) {
+	    case CssTypes.CSS_STRING:
+		if (check) {
+		    throw new InvalidParamException("unrecognize", ac);
 		}
-	    }
-	    if (!find && getImage() == null) {
-		try {
+		find = false;
+		break;
+	    case CssTypes.CSS_URL:
+		if (getImage() == null) {
 		    setImage(new CssBackgroundImageCSS2(ac, expression));
-		    find = true;
-		} catch (InvalidParamException e) {
-		    // nothing to do, repeat will test this value
+		    continue;
 		}
-	    }
-	    if (!find && getRepeat() == null) {
-		try {
-		    setRepeat(new CssBackgroundRepeatCSS2(ac, expression));
-		    find = true;
-		} catch (InvalidParamException e) {
-		    // nothing to do, attachment will test this value
+		find = false;
+		break;
+	    case CssTypes.CSS_COLOR:
+		if (getColor2() == null) {
+		    setColor(new CssBackgroundColorCSS21(ac, expression));
+		    continue;
 		}
-	    }
-	    if (!find && getAttachment() == null) {
-		try {
-		    setAttachment(new CssBackgroundAttachmentCSS2(ac, expression));
-		    find = true;
-		} catch (InvalidParamException e) {
-		    // nothing to do, position will test this value
+		find = false;
+		break;
+	    case CssTypes.CSS_NUMBER:
+	    case CssTypes.CSS_PERCENTAGE:
+	    case CssTypes.CSS_LENGTH:
+		if (getPosition() == null) {
+		    setPosition(new CssBackgroundPositionCSS21(ac,expression));
+		    continue;
 		}
-	    }
-	    if (!find && getPosition() == null) {
-		try {
-		    setPosition(new CssBackgroundPositionCSS21(ac, expression));
-		    find = true;
-		} catch (InvalidParamException e) {
-		    // nothing to do
+		find = false;
+		break;
+	    case CssTypes.CSS_IDENT:
+		// the hard part, as ident can be from different subproperties
+		find = false;
+		CssIdent identval = (CssIdent) val;
+		// check background-image ident
+		if (CssBackgroundImageCSS2.checkMatchingIdent(identval)) {
+		    if (getImage() == null) {
+			setImage(new CssBackgroundImageCSS2(ac, expression));
+			find = true;
+		    } 
+		    break;
 		}
+		// check background-repeat ident
+		if (CssBackgroundRepeatCSS2.checkMatchingIdent(identval)) {
+		    if (getRepeat() == null) {
+			setRepeat(new CssBackgroundRepeatCSS2(ac, expression));
+			find = true;
+		    }
+		    break;
+		}
+		// check background-attachment ident
+		if (CssBackgroundAttachmentCSS2.checkMatchingIdent(identval)) {
+		    if (getAttachment() == null) {
+			setAttachment(new CssBackgroundAttachmentCSS2(ac, expression));
+			find = true;
+		    }
+		    break;
+		}		
+		// check backgorund-position ident
+		if (CssBackgroundPositionCSS21.checkMatchingIdent(identval)) {
+		    if (getPosition() == null) {
+			setPosition(new CssBackgroundPositionCSS21(ac, expression));
+			find = true;
+		    }
+		    break;
+		}
+
+		if (getColor2() == null) {
+		    try {
+			setColor(new CssBackgroundColorCSS21(ac, expression));
+			find = true;
+			break;
+		    } catch (InvalidParamException e) {
+			// nothing to do, image will test this value
+		    }
+		}	
+
+	    default:
+		if (check) {
+		    throw new InvalidParamException("unrecognize", ac);
+		}
+		find = false;
 	    }
-	    if(check && val != null && !find) {
+	    if(check && !find) {
 		throw new InvalidParamException("unrecognize", ac);
 	    }
 	    if (op != SPACE) {
 		throw new InvalidParamException("operator",
-						((new Character(op)).toString()),
+						Character.toString(op),
 						ac);
 	    }
-	    if(check && !find && val != null) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
 	}
-
     }
 
     public CssBackgroundCSS21(ApplContext ac, CssExpression expression)
Received on Tuesday, 25 March 2008 18:43:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:00 GMT