W3C home > Mailing lists > Public > www-validator-cvs@w3.org > February 2009

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

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 06 Feb 2009 15:17:50 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1LVSSk-0004Pv-HX@lionel-hutz.w3.org>

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

Modified Files:
	CssBackgroundPositionCSS21.java 
Log Message:
fixes bug 6090
http://www.w3.org/Bugs/Public/show_bug.cgi?id=6090
(most of the class was duplicated code)


Index: CssBackgroundPositionCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundPositionCSS21.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssBackgroundPositionCSS21.java	25 Mar 2008 18:43:11 -0000	1.4
+++ CssBackgroundPositionCSS21.java	6 Feb 2009 15:17:48 -0000	1.5
@@ -35,139 +35,7 @@
      */
     public CssBackgroundPositionCSS21(ApplContext ac, CssExpression expression,
 	    boolean check) throws InvalidParamException {
-
-	if(check && expression.getCount() > 2) {
-	    throw new InvalidParamException("unrecognize", ac);
-	}
-
-	setByUser();
-	CssValue val = expression.getValue();
-	char op  = expression.getOperator();
-	if (op != SPACE)
-	    throw new  InvalidParamException("operator",
-					     ((new Character(op)).toString()),
-					     ac);
-
-	if (inherit.equals(val)) {
-	    if(expression.getCount() > 1) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    setFirst(inherit);
-	    setSecond(inherit);
-	    expression.next();
-	    return;
-	}
-
-	CssValue next = expression.getNextValue();
-
-	if(val instanceof CssIdent) {
-	    int index1 = IndexOfIdent((String) val.get());
-	    if(index1 == -1) {
-		throw new InvalidParamException("value", val, "background-position", ac);
-	    }
-	    // two keywords
-	    if(next instanceof CssIdent) {
-		int index2 = IndexOfIdent((String) next.get());
-		if(index2 == -1 && check) {
-		    throw new InvalidParamException("value", next, "background-position", ac);
-		}
-		// one is vertical, the other is horizontal
-		// or the two are 'center'
-		if((isHorizontal(index1) && isVertical(index2)) ||
-			(isHorizontal(index2) && isVertical(index1))) {
-		    setFirst(val);
-		    setSecond(next);
-		}
-		// both are horizontal or vertical but not 'center'
-		else if(check){
-		    throw new InvalidParamException("incompatible",
-			    val, next, ac);
-		}
-		else {
-		    setFirst(val);
-		}
-	    }
-	    // a keyword and a percentage/length
-	    else if(next instanceof CssLength || next instanceof CssPercentage
-		    || next instanceof CssNumber) {
-		if(isHorizontal(index1)) {
-		    if(next instanceof CssNumber) {
-			next = ((CssNumber) next).getLength();
-		    }
-		    setFirst(val);
-		    setSecond(next);
-		}
-		// if the keyword is the first value, it can only be an
-		// horizontal one
-		else {
-		    throw new InvalidParamException("incompatible",
-			    val, next, ac);
-		}
-	    }
-	    // only one value
-	    else if(next == null) {
-		setFirst(val);
-	    }
-	    // the second value is invalid
-	    else if(check) {
-		throw new InvalidParamException("value", next,
-			getPropertyName(), ac);
-	    }
-	    else {
-		setFirst(val);
-	    }
-	}
-	else if(val instanceof CssLength || val instanceof CssPercentage ||
-		val instanceof CssNumber) {
-	    if(val instanceof CssNumber) {
-		val = ((CssNumber) val).getLength();
-	    }
-	    // a percentage/length and an keyword
-	    if(next instanceof CssIdent) {
-		int index = IndexOfIdent((String) next.get());
-		if(check && index == -1) {
-		    throw new InvalidParamException("value", next, "background-position", ac);
-		}
-		// the keyword must be a vertical one
-		if(isVertical(index)) {
-		    setFirst(val);
-		    setSecond(next);
-		}
-		else if(check) {
-		    throw new InvalidParamException("incompatible",
-			    val, next, ac);
-		}
-		else {
-		    setFirst(val);
-		}
-	    }
-	    else if(next instanceof CssLength || next instanceof CssPercentage
-		    || next instanceof CssNumber) {
-		if(next instanceof CssNumber) {
-		    next = ((CssNumber) next).getLength();
-		}
-		setFirst(val);
-		setSecond(next);
-	    }
-	    else if(next == null || !check) {
-		setFirst(val);
-	    }
-	    else {
-		throw new InvalidParamException("incompatible", val, next, ac);
-	    }
-	}
-	else if(check){
-	    throw new InvalidParamException("value", expression.getValue(),
-		    getPropertyName(), ac);
-	}
-
-	// we only move the cursor if we found valid values
-	if(getFirst() != null) {
-	    expression.next();
-	}
-	if(getSecond() != null) {
-	    expression.next();
-	}
+	super(ac, expression, check);
     }
 
     public CssBackgroundPositionCSS21(ApplContext ac, CssExpression expression)
Received on Friday, 6 February 2009 15:17:58 GMT

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