- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 26 Aug 2005 14:09:52 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv31827/org/w3c/css/values Modified Files: CssAngle.java CssColor.java CssColorCSS1.java CssColorCSS2.java CssNumber.java HSL.java HSLA.java RGB.java RGBA.java Log Message: All changes made by Jean-Guilhem Rouel: Fix for bugs: 1269, 979, 791, 777, 776, 767, 765, 763, 576, 363 Errors in font, the handling of 'transparent', CSS Parser reinits... http://www.w3.org/Bugs/Public/show_bug.cgi?id=1269 http://www.w3.org/Bugs/Public/show_bug.cgi?id=979 http://www.w3.org/Bugs/Public/show_bug.cgi?id=791 http://www.w3.org/Bugs/Public/show_bug.cgi?id=777 http://www.w3.org/Bugs/Public/show_bug.cgi?id=776 http://www.w3.org/Bugs/Public/show_bug.cgi?id=767 http://www.w3.org/Bugs/Public/show_bug.cgi?id=765 http://www.w3.org/Bugs/Public/show_bug.cgi?id=763 http://www.w3.org/Bugs/Public/show_bug.cgi?id=576 http://www.w3.org/Bugs/Public/show_bug.cgi?id=363 Index: RGBA.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGBA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RGBA.java 21 Jul 2002 13:10:31 -0000 1.1 +++ RGBA.java 26 Aug 2005 14:09:50 -0000 1.2 @@ -14,36 +14,36 @@ package org.w3c.css.values; public class RGBA { - String output = null; - Object r; - Object g; - Object b; - Object a; - + String output = null; + Object r; + Object g; + Object b; + Object a; + /** * Create a new RGBA */ public RGBA() { } - + /** * Create a new RGBA with default values */ public RGBA(Object r, Object g, Object b, Object a) { - this.r = r; - this.g = g; - this.b = b; - this.a = a; + this.r = r; + this.g = g; + this.b = b; + this.a = a; } - + /** * Returns a string representation of the object. */ public String toString() { - if (output == null) { - return "rgba("+((Float)r).intValue()+","+((Float)g).intValue()+","+((Float)b).intValue()+","+a+")"; - } else { - return output; - } + if (output == null) { + return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")"; + } else { + return output; + } } } \ No newline at end of file Index: CssColorCSS2.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS2.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssColorCSS2.java 8 Aug 2005 13:19:47 -0000 1.4 +++ CssColorCSS2.java 26 Aug 2005 14:09:50 -0000 1.5 @@ -6,6 +6,24 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.5 2005/08/26 14:09:50 ylafon + * All changes made by Jean-Guilhem Rouel: + * + * Fix for bugs: 1269, 979, 791, 777, 776, 767, 765, 763, 576, 363 + * + * Errors in font, the handling of 'transparent', CSS Parser reinits... + * + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=1269 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=979 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=791 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=777 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=776 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=767 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=765 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=763 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=576 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=363 + * * Revision 1.4 2005/08/08 13:19:47 ylafon * All those changed made by Jean-Guilhem Rouel: * @@ -272,16 +290,17 @@ color = null; rgb = new RGB(); boolean isPercent = false; - + if (val == null || op != COMMA) { throw new InvalidParamException("invalid-color", ac); } if (val instanceof CssNumber) { - rgb.r = clippedValue(((Float) val.get()).intValue(), ac); + CssNumber number = (CssNumber) val; + rgb.r = clippedIntValue(number.getInt(), ac); isPercent = false; } else if (val instanceof CssPercentage) { - rgb.r = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); isPercent = true; } else { throw new InvalidParamException("rgb", val, ac); @@ -296,15 +315,16 @@ } if (val instanceof CssNumber) { + CssNumber number = (CssNumber) val; if (isPercent) { throw new InvalidParamException("percent", val, ac); } - rgb.g = clippedValue(((Float) val.get()).intValue(), ac); + rgb.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { if (!isPercent) { throw new InvalidParamException("integer", val, ac); } - rgb.g = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); } else { throw new InvalidParamException("rgb", val, ac); } @@ -318,15 +338,16 @@ } if (val instanceof CssNumber) { + CssNumber number = (CssNumber) val; if (isPercent) { throw new InvalidParamException("percent", val, ac); } - rgb.b = clippedValue(((Float) val.get()).intValue(), ac); + rgb.b = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { if (!isPercent) { throw new InvalidParamException("integer", val, ac); } - rgb.b = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.b = clippedPercentValue(((Float) val.get()).floatValue(), ac); } else { throw new InvalidParamException("rgb", val, ac); } @@ -335,7 +356,6 @@ if (exp.getValue() != null) { throw new InvalidParamException("rgb", exp.getValue(), ac); } - } /** @@ -395,33 +415,22 @@ } throw new InvalidParamException("value", s, "color", ac); - } + } - /** - * Clipped an integer. - */ - private static Integer clippedValue(int val, ApplContext ac) { - if (val < 0 || val > 255) { - ac.getFrame().addWarning("out-of-range", Integer.toString(val)); - return new Integer((val<0)?0:255); - } else { - return new Integer(val); + private static Integer clippedIntValue(int rgb, ApplContext ac) { + if (rgb < 0 || rgb > 255) { + ac.getFrame().addWarning("out-of-range", Util.displayFloat(rgb)); + return new Integer((rgb<0)?0:255); } + else return(new Integer(rgb)); } - /** - * clipped a float. - */ - private static Object clippedValue(float v, ApplContext ac) { - if (v < 0 || v > 100) { - ac.getFrame().addWarning("out-of-range", Util.displayFloat(v)); - return new Integer((v<0)?0:255); - } else { - if (v == 0 | v == 100) { - return new Integer((v==0)?0:255); - } - return new CssPercentage(v); + private static Float clippedPercentValue(float p, ApplContext ac) { + if (p < 0. || p > 100.) { + ac.getFrame().addWarning("out-of-range", Util.displayFloat(p)); + return new Float((p<0.)?0.:100.); } + else return(new Float(p)); } /** Index: HSL.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSL.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- HSL.java 21 Jul 2002 13:12:20 -0000 1.1 +++ HSL.java 26 Aug 2005 14:09:50 -0000 1.2 @@ -14,34 +14,34 @@ package org.w3c.css.values; public class HSL { - String output = null; - Object h; - Object s; - Object l; - + String output = null; + Object h; + Object s; + Object l; + /** * Create a new HSL */ public HSL() { } - + /** * Create a new HSL with default values */ public HSL(Object h, Object s, Object l) { - this.h = h; - this.s = s; - this.l = l; - } - + this.h = h; + this.s = s; + this.l = l; + } + /** * Returns a string representation of the object. */ public String toString() { - if (output == null) { - return "hsl("+h+","+s+","+l+")"; - } else { - return output; - } + if (output == null) { + return "hsl(" + h + ", " + s + ", " + l + ")"; + } else { + return output; + } } } \ No newline at end of file Index: CssAngle.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssAngle.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssAngle.java 8 Aug 2005 13:19:46 -0000 1.3 +++ CssAngle.java 26 Aug 2005 14:09:50 -0000 1.4 @@ -6,6 +6,24 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.4 2005/08/26 14:09:50 ylafon + * All changes made by Jean-Guilhem Rouel: + * + * Fix for bugs: 1269, 979, 791, 777, 776, 767, 765, 763, 576, 363 + * + * Errors in font, the handling of 'transparent', CSS Parser reinits... + * + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=1269 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=979 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=791 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=777 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=776 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=767 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=765 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=763 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=576 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=363 + * * Revision 1.3 2005/08/08 13:19:46 ylafon * All those changed made by Jean-Guilhem Rouel: * @@ -89,7 +107,7 @@ s = s.toLowerCase(); int length = s.length(); String unit; - float v; + //float v; if (s.indexOf("grad") == -1) { unit = s.substring(length-3, length); value = new Float(s.substring(0, length-3)); @@ -168,25 +186,38 @@ } + private float normalize(float degree) { + while (degree < 0) { + degree += 360; + } + while (degree > 360) { + degree -= 360; + } + return degree; + } + //@@FIXME I should return the remainder for all ... public float getDegree() { - float deg = value.floatValue(); + float angle = value.floatValue(); switch (unit) { - case 0: - // deg % 360 - return deg; - case 1: - return (deg * (180 / ((float) Math.PI))); - case 2: - return (deg * (9 / 5)); - default: + case 0: + // angle % 360 + return normalize(angle); + case 1: + return normalize(angle * (9.f / 10.f)); + case 2: + return normalize(angle * (180.f / ((float) Math.PI))); + default: System.err.println("[ERROR] in org.w3c.css.values.CssAngle"); System.err.println("[ERROR] Please report (" + unit + ")"); return (float) 0; } } - +/* + // These functions are not used, don't normalize angles, and are false + // (int operations instead of float ones) + public float getGradian() { float grad = value.floatValue(); switch (unit) { @@ -218,7 +249,7 @@ return (float) 0; } } - +*/ public boolean isDegree() { return unit == 0; } Index: RGB.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGB.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RGB.java 8 Apr 2002 21:19:46 -0000 1.2 +++ RGB.java 26 Aug 2005 14:09:50 -0000 1.3 @@ -40,7 +40,7 @@ */ public String toString() { if (output == null) { - return "rgb("+r+","+g+","+b+")"; + return "rgb(" + r + ", " + g + ", " + b + ")"; } else { return output; } Index: CssNumber.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssNumber.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssNumber.java 8 Aug 2005 13:19:47 -0000 1.3 +++ CssNumber.java 26 Aug 2005 14:09:50 -0000 1.4 @@ -6,6 +6,24 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.4 2005/08/26 14:09:50 ylafon + * All changes made by Jean-Guilhem Rouel: + * + * Fix for bugs: 1269, 979, 791, 777, 776, 767, 765, 763, 576, 363 + * + * Errors in font, the handling of 'transparent', CSS Parser reinits... + * + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=1269 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=979 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=791 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=777 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=776 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=767 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=765 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=763 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=576 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=363 + * * Revision 1.3 2005/08/08 13:19:47 ylafon * All those changed made by Jean-Guilhem Rouel: * @@ -47,6 +65,7 @@ ApplContext ac; Float value; + boolean isInt = false; /** * Create a new CssNumber @@ -73,7 +92,16 @@ * @param frame For errors and warnings reports. */ public void set(String s, ApplContext ac) { - value = new Float(s); + try { + new Integer(s); + isInt = true; + } + catch(NumberFormatException e) { + isInt = false; + } + finally { + value = new Float(s); + } this.ac = ac; } @@ -91,9 +119,17 @@ return value.floatValue(); } + public int getInt() throws InvalidParamException { + if(isInt) { + return value.intValue(); + } + else { + throw new InvalidParamException("invalid-color", ac); + } + } + public boolean isInteger() { - float f = (float) value.intValue(); - return (f == value.floatValue()); + return isInt; } /** Index: CssColorCSS1.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS1.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssColorCSS1.java 8 Aug 2005 13:19:46 -0000 1.4 +++ CssColorCSS1.java 26 Aug 2005 14:09:50 -0000 1.5 @@ -6,6 +6,24 @@ // Please first read the full copyright statement in file COPYRIGHT.html /* * $Log$ + * Revision 1.5 2005/08/26 14:09:50 ylafon + * All changes made by Jean-Guilhem Rouel: + * + * Fix for bugs: 1269, 979, 791, 777, 776, 767, 765, 763, 576, 363 + * + * Errors in font, the handling of 'transparent', CSS Parser reinits... + * + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=1269 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=979 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=791 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=777 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=776 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=767 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=765 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=763 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=576 + * http://www.w3.org/Bugs/Public/show_bug.cgi?id=363 + * * Revision 1.4 2005/08/08 13:19:46 ylafon * All those changed made by Jean-Guilhem Rouel: * @@ -278,10 +296,11 @@ } if (val instanceof CssNumber) { - rgb.r = clippedValue(((Float) val.get()).intValue(), ac); + CssNumber number = (CssNumber) val; + rgb.r = clippedIntValue(number.getInt(), ac); isPercent = false; } else if (val instanceof CssPercentage) { - rgb.r = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.r = clippedPercentValue(((Float) val.get()).floatValue(), ac); isPercent = true; } else { throw new InvalidParamException("rgb", val, ac); @@ -296,15 +315,16 @@ } if (val instanceof CssNumber) { + CssNumber number = (CssNumber) val; if (isPercent) { throw new InvalidParamException("percent", val, ac); } - rgb.g = clippedValue(((Float) val.get()).intValue(), ac); + rgb.g = clippedIntValue(number.getInt(), ac); } else if (val instanceof CssPercentage) { if (!isPercent) { throw new InvalidParamException("integer", val, ac); } - rgb.g = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.g = clippedPercentValue(((Float) val.get()).floatValue(), ac); } else { throw new InvalidParamException("rgb", val, ac); } @@ -321,12 +341,13 @@ if (isPercent) { throw new InvalidParamException("percent", val, ac); } - rgb.b = clippedValue(((Float) val.get()).intValue(), ac); + rgb.b = clippedIntValue(((Float) val.get()).intValue(), ac); } else if (val instanceof CssPercentage) { - if (!isPercent) { - throw new InvalidParamException("integer", val, ac); + CssNumber number = (CssNumber) val; + if (isPercent) { + throw new InvalidParamException("percent", val, ac); } - rgb.b = clippedValue(((Float) val.get()).floatValue(), ac); + rgb.b = clippedPercentValue(number.getInt(), ac); } else { throw new InvalidParamException("rgb", val, ac); } @@ -396,31 +417,20 @@ throw new InvalidParamException("value", s, "color", ac); } - /** - * Clipped an integer. - */ - private static Integer clippedValue(int val, ApplContext ac) { - if (val < 0 || val > 255) { - ac.getFrame().addWarning("out-of-range", Integer.toString(val)); - return new Integer((val<0)?0:255); - } else { - return new Integer(val); + private static Integer clippedIntValue(int rgb, ApplContext ac) { + if (rgb < 0 || rgb > 255) { + ac.getFrame().addWarning("out-of-range", Util.displayFloat(rgb)); + return new Integer((rgb<0)?0:255); } + else return(new Integer(rgb)); } - /** - * clipped a float. - */ - private static Object clippedValue(float v, ApplContext ac) { - if (v < 0 || v > 100) { - ac.getFrame().addWarning("out-of-range", Util.displayFloat(v)); - return new Integer((v<0)?0:255); - } else { - if (v == 0 | v == 100) { - return new Integer((v==0)?0:255); - } - return new CssPercentage(v); + private static Float clippedPercentValue(float p, ApplContext ac) { + if (p < 0. || p > 100.) { + ac.getFrame().addWarning("out-of-range", Util.displayFloat(p)); + return new Float((p<0.)?0.:100.); } + else return(new Float(p)); } /** Index: HSLA.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSLA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- HSLA.java 21 Jul 2002 13:12:45 -0000 1.1 +++ HSLA.java 26 Aug 2005 14:09:50 -0000 1.2 @@ -14,36 +14,36 @@ package org.w3c.css.values; public class HSLA { - String output = null; - Object h; - Object s; - Object l; - Object a; - + String output = null; + Object h; + Object s; + Object l; + Object a; + /** * Create a new HSLA */ public HSLA() { } - + /** * Create a new RGBA with default values */ public HSLA(Object h, Object s, Object l, Object a) { - this.h = h; - this.s = s; - this.l = l; - this.a = a; - } - + this.h = h; + this.s = s; + this.l = l; + this.a = a; + } + /** * Returns a string representation of the object. */ public String toString() { - if (output == null) { - return "hsla("+h+","+s+","+l+","+a+")"; - } else { - return output; - } + if (output == null) { + return "hsla(" + h + ", " + s + ", " + l + ", " + a + ")"; + } else { + return output; + } } } \ No newline at end of file Index: CssColor.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- CssColor.java 8 Aug 2005 13:19:46 -0000 1.8 +++ CssColor.java 26 Aug 2005 14:09:50 -0000 1.9 @@ -254,88 +254,74 @@ * Parse a RGB color. * format rgb(<num>%?, <num>%?, <num>%?) */ - public void setRGBColor(CssExpression exp, ApplContext ac) - throws InvalidParamException { + public void setRGBColor(CssExpression exp, ApplContext ac) + throws InvalidParamException { CssValue val = exp.getValue(); char op = exp.getOperator(); color = null; rgb = new RGB(); [...1419 lines suppressed...] + /* + definedColors.put("ActiveHyperlink", "ActiveHyperlink"); + definedColors.put("ActiveHyperlinkText", "ActiveHyperlinkText"); + definedColors.put("HoverHyperlink", "HoverHyperlink"); + definedColors.put("HoverHyperlinkText", "HoverHyperlinkText"); + definedColors.put("Hyperlink", "Hyperlink"); + definedColors.put("HyperlinkText", "HyperlinkText"); + definedColors.put("VisitedHyperlink", "VisitedHyperlink"); + definedColors.put("VisitedHyperlinkText", "VisitedHyperlinkText"); + */ + + //Flavor system color + definedColors.put("flavor","flavor"); + definedColors.put("currentcolor","currentColor"); + } - + }
Received on Friday, 26 August 2005 14:10:02 UTC