- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 29 Aug 2005 12:36:49 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv17593 Modified Files: CssColor.java CssColorCSS1.java CssColorCSS2.java HSL.java HSLA.java RGB.java RGBA.java Log Message: refined error message for RGB value checks Index: RGBA.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGBA.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RGBA.java 26 Aug 2005 14:09:50 -0000 1.2 +++ RGBA.java 29 Aug 2005 12:36:47 -0000 1.3 @@ -20,6 +20,22 @@ Object b; Object a; + boolean percent = false; + + /** + * @return Returns the percent. + */ + public boolean isPercent() { + return percent; + } + + /** + * @param percent The percent to set. + */ + public void setPercent(boolean percent) { + this.percent = percent; + } + /** * Create a new RGBA */ @@ -41,7 +57,9 @@ */ public String toString() { if (output == null) { - return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")"; + String unit = (isPercent()) ? "%" : ""; + return "rgba(" + r + unit + ", " + g + unit + ", " + b + unit + + ", " + a + unit + ")"; } else { return output; } Index: CssColorCSS2.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS2.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssColorCSS2.java 26 Aug 2005 14:09:50 -0000 1.5 +++ CssColorCSS2.java 29 Aug 2005 12:36:47 -0000 1.6 @@ -6,6 +6,9 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.6 2005/08/29 12:36:47 ylafon + * refined error message for RGB value checks + * * Revision 1.5 2005/08/26 14:09:50 ylafon * All changes made by Jean-Guilhem Rouel: * @@ -289,7 +292,6 @@ char op = exp.getOperator(); color = null; rgb = new RGB(); - boolean isPercent = false; if (val == null || op != COMMA) { throw new InvalidParamException("invalid-color", ac); @@ -298,10 +300,10 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; rgb.r = clippedIntValue(number.getInt(), ac); - isPercent = false; + rgb.setPercent(false); } else if (val instanceof CssPercentage) { rgb.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); - isPercent = true; + rgb.setPercent(true); } else { throw new InvalidParamException("rgb", val, ac); } @@ -316,12 +318,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgb.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgb.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); @@ -339,12 +341,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.b = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgb.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgb.b = clippedPercentValue(((Float) val.get()).floatValue(), ac); Index: HSL.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSL.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- HSL.java 26 Aug 2005 14:09:50 -0000 1.2 +++ HSL.java 29 Aug 2005 12:36:47 -0000 1.3 @@ -18,7 +18,7 @@ Object h; Object s; Object l; - + /** * Create a new HSL */ Index: RGB.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGB.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- RGB.java 26 Aug 2005 14:09:50 -0000 1.3 +++ RGB.java 29 Aug 2005 12:36:47 -0000 1.4 @@ -20,6 +20,22 @@ Object g; Object b; + boolean percent = false; + + /** + * @return Returns the percent. + */ + public boolean isPercent() { + return percent; + } + + /** + * @param percent The percent to set. + */ + public void setPercent(boolean percent) { + this.percent = percent; + } + /** * Create a new RGB */ @@ -40,7 +56,8 @@ */ public String toString() { if (output == null) { - return "rgb(" + r + ", " + g + ", " + b + ")"; + String unit = (isPercent()) ? "%" : ""; + return "rgb(" + r + unit + ", " + g + unit + ", " + b + unit + ")"; } else { return output; } Index: CssColorCSS1.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS1.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssColorCSS1.java 26 Aug 2005 14:09:50 -0000 1.5 +++ CssColorCSS1.java 29 Aug 2005 12:36:47 -0000 1.6 @@ -6,6 +6,9 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.6 2005/08/29 12:36:47 ylafon + * refined error message for RGB value checks + * * Revision 1.5 2005/08/26 14:09:50 ylafon * All changes made by Jean-Guilhem Rouel: * @@ -289,7 +292,6 @@ char op = exp.getOperator(); color = null; rgb = new RGB(); - boolean isPercent = false; if (val == null || op != COMMA) { throw new InvalidParamException("invalid-color", ac); @@ -298,10 +300,10 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; rgb.r = clippedIntValue(number.getInt(), ac); - isPercent = false; + rgb.setPercent(false); } else if (val instanceof CssPercentage) { rgb.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); - isPercent = true; + rgb.setPercent(true); } else { throw new InvalidParamException("rgb", val, ac); } @@ -316,12 +318,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgb.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgb.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); @@ -338,13 +340,13 @@ } if (val instanceof CssNumber) { - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.b = clippedIntValue(((Float) val.get()).intValue(), ac); } else if (val instanceof CssPercentage) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.b = clippedPercentValue(number.getInt(), ac); Index: HSLA.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSLA.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- HSLA.java 26 Aug 2005 14:09:50 -0000 1.2 +++ HSLA.java 29 Aug 2005 12:36:47 -0000 1.3 @@ -19,7 +19,7 @@ Object s; Object l; Object a; - + /** * Create a new HSLA */ Index: CssColor.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- CssColor.java 26 Aug 2005 14:09:50 -0000 1.9 +++ CssColor.java 29 Aug 2005 12:36:47 -0000 1.10 @@ -260,7 +260,6 @@ char op = exp.getOperator(); color = null; rgb = new RGB(); - boolean isPercent = false; if (val == null || op != COMMA) { throw new InvalidParamException("invalid-color", ac); @@ -269,10 +268,10 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; rgb.r = clippedIntValue(number.getInt(), ac); - isPercent = false; + rgb.setPercent(false); } else if (val instanceof CssPercentage) { rgb.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); - isPercent = true; + rgb.setPercent(true); } else { throw new InvalidParamException("rgb", val, ac); } @@ -287,12 +286,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgb.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgb.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); @@ -310,12 +309,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgb.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgb.b = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgb.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgb.b = clippedPercentValue(((Float) val.get()).floatValue(), ac); @@ -417,17 +416,15 @@ throws InvalidParamException { color = null; rgba = new RGBA(); - boolean isPercent = false; - CssValue val = (CssValue) exp.elementAt(0); if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; rgba.r = clippedIntValue(number.getInt(), ac); - isPercent = false; + rgba.setPercent(false); } else if (val instanceof CssPercentage) { rgba.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); - isPercent = true; + rgba.setPercent(true); } else { throw new InvalidParamException("rgb", val, ac); } @@ -436,12 +433,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgba.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgba.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgba.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgba.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); @@ -453,12 +450,12 @@ if (val instanceof CssNumber) { CssNumber number = (CssNumber) val; - if (isPercent) { + if (rgba.isPercent()) { throw new InvalidParamException("percent", val, ac); } rgba.b = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { + if (!rgba.isPercent()) { throw new InvalidParamException("integer", val, ac); } rgba.b = clippedPercentValue(((Float) val.get()).floatValue(), ac);
Received on Monday, 29 August 2005 12:36:53 UTC