- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 09 Mar 2009 17:17:50 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv11704
Modified Files:
CssColor.java CssColorCSS2.java CssColorCSS21.java
Log Message:
modified identColor to generate in all cases the RGB/RGBA equivalent to be able to check that blue and #0000FF are indeed conflicting
Index: CssColorCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS21.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssColorCSS21.java 25 Mar 2008 18:30:11 -0000 1.4
+++ CssColorCSS21.java 9 Mar 2009 17:17:48 -0000 1.5
@@ -45,26 +45,18 @@
int indexOfColor = searchColor(hash, tableColorHash);
- if(indexOfColor != -1) {
- color = COLORNAME_CSS21[indexOfColor];
- }
- // the color has not been found, search it the system colors
- else {
+ if (indexOfColor != -1) {
+ computeIdentColor(definedColors, COLORNAME_CSS21[indexOfColor]);
+ } else {
+ // the color has not been found, search it the system colors
indexOfColor = searchColor(hash, tableSystemColorHash);
if(indexOfColor != -1) {
- color = SYSTEMCOLORS[indexOfColor];
- }
+ computeIdentColor(definedColors, SYSTEMCOLORS[indexOfColor]);
+ } else {
// the color does not exist in this profile, this is an error
- else {
throw new InvalidParamException("value", s, "color", ac);
}
}
-// 2007-05 - this warning on color string capitalization is plain silly,
-// commenting it out-- ot@w3.org
-// if(!s.equals(color)) {
-// ac.getFrame().addWarning("color.mixed-capitalization", s);
-// }
-
}
private int searchColor(int colorHash, int[] tableColorHash) {
Index: CssColorCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS2.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- CssColorCSS2.java 5 Mar 2009 23:23:28 -0000 1.12
+++ CssColorCSS2.java 9 Mar 2009 17:17:48 -0000 1.13
@@ -187,24 +187,9 @@
private void setIdentColor(String s, ApplContext ac)
throws InvalidParamException {
String lower_s = s.toLowerCase();
- Object obj = definedColorsCSS2.get(lower_s);
- if (obj != null) {
- if (obj instanceof RGB) {
- color = lower_s;
- rgb = (RGB) obj;
- } else if (obj instanceof String) {
- color = (String) obj;
-// 2007-05 - this warning on color string capitalization is plain silly,
-// commenting it out-- ot@w3.org
-// if (!obj.equals(s)) {
-// ac.getFrame().addWarning("color.mixed-capitalization",
-// s);
-// }
- }
- return;
+ if (!computeIdentColor(definedColorsCSS2, lower_s)) {
+ throw new InvalidParamException("value", s, "color", ac);
}
-
- throw new InvalidParamException("value", s, "color", ac);
}
static {
Index: CssColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColor.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- CssColor.java 5 Mar 2009 22:59:00 -0000 1.17
+++ CssColor.java 9 Mar 2009 17:17:48 -0000 1.18
@@ -411,30 +411,32 @@
rgb.output = s;
}
- /**
- * Parse an ident color.
- */
- private void setIdentColor(String s, ApplContext ac)
- throws InvalidParamException
+ protected boolean computeIdentColor(HashMap<String,Object> definitions,
+ String s)
{
- String lower_s = s.toLowerCase();
- Object obj = definedColors.get(lower_s);
+ Object obj = definitions.get(s);
if (obj != null) {
if (obj instanceof RGB) {
- color = lower_s;
+ color = s;
rgb = (RGB) obj;
} else if (obj instanceof RGBA) {
- color = lower_s;
+ color = s;
rgba = (RGBA) obj;
} else if (obj instanceof String) {
color = (String) obj;
-// 2007-05 - this warning on color string capitalization is plain silly,
-// commenting it out-- ot@w3.org
-// if (!obj.equals(s)) {
-// ac.getFrame().addWarning("color.mixed-capitalization",
-// s);
-// }
}
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Parse an ident color.
+ */
+ private void setIdentColor(String s, ApplContext ac)
+ throws InvalidParamException
+ {
+ String lower_s = s.toLowerCase();
+ if (computeIdentColor(definedColors, lower_s)) {
return;
} else if (deprecatedColors.get(lower_s) != null) {
color = lower_s;
@@ -454,16 +456,18 @@
if (!(cssColor instanceof CssColor)) {
return false;
}
- if (color != null) {
- return color.equals(((CssColor)cssColor).color);
- } else if (rgb != null) {
- return rgb.equals(((CssColor)cssColor).rgb);
- } else if (rgba != null) {
- return rgba.equals(((CssColor)cssColor).rgba);
- } else if (hsl != null) {
- return hsl.equals(((CssColor)cssColor).hsl);
- } else if (hsla != null) {
- return hsla.equals(((CssColor)cssColor).hsla);
+ CssColor otherColor = (CssColor) cssColor;
+ // FIXME we can have rgba(a,b,c,1) == rgb(a,b,c)
+ if ((color != null) && (otherColor.color != null)) {
+ return color.equals(otherColor.color);
+ } else if ((rgb != null) && (otherColor.rgb != null)) {
+ return rgb.equals(otherColor.rgb);
+ } else if ((rgba != null) && (otherColor.rgba != null)) {
+ return rgba.equals(otherColor.rgba);
+ } else if ((hsl != null) && (otherColor.hsl != null)) {
+ return hsl.equals(otherColor.hsl);
+ } else if ((hsla != null) && (otherColor.hsla != null)) {
+ return hsla.equals(otherColor.hsla);
}
return false;
}
Received on Monday, 9 March 2009 17:18:05 UTC