- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 29 Sep 2011 09:09:02 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv25474/org/w3c/css/values
Modified Files:
CssColor.java CssColorCSS1.java CssColorCSS2.java
CssColorCSS21.java HSLA.java RGBA.java
Added Files:
CssColorCSS3.java
Removed Files:
ATSCColor.java CssColorConstants.java
Log Message:
getting rid of multiple classes for Color value
Index: RGBA.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGBA.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- RGBA.java 6 Jan 2010 09:27:45 -0000 1.8
+++ RGBA.java 29 Sep 2011 09:09:00 -0000 1.9
@@ -16,6 +16,9 @@
import org.w3c.css.util.Util;
public class RGBA {
+ static final String functionname = "rgba";
+
+ String fname;
String output = null;
int r, g, b;
float fr, fg, fb, a;
@@ -92,6 +95,15 @@
* Create a new RGBA
*/
public RGBA() {
+ fname = functionname;
+ }
+
+ /**
+ * Create a RGBA and with a specific function name
+ * (like astc-rgba http://www.atsc.org/cms/standards/a100/a_100_2.pdf #5.2.1.8.4.1
+ */
+ public RGBA(String fname) {
+ this.fname = fname;
}
/**
@@ -130,7 +142,8 @@
*/
public String toString() {
if (output == null) {
- StringBuilder sb = new StringBuilder("rgba(");
+ StringBuilder sb = new StringBuilder();
+ sb.append(fname).append('(');
if (isPercent()) {
sb.append(Util.displayFloat(fr)).append("%, ");
sb.append(Util.displayFloat(fg)).append("%, ");
Index: CssColorCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS2.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CssColorCSS2.java 5 Jan 2010 13:50:00 -0000 1.14
+++ CssColorCSS2.java 29 Sep 2011 09:09:00 -0000 1.15
@@ -6,259 +6,75 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import org.w3c.css.util.ApplContext;
-import org.w3c.css.util.InvalidParamException;
-
import java.util.HashMap;
/**
- * <H3>
- * Color units
- * </H3>
- * <p/>
- * A color is a either a keyword or a numerical RGB specification.
- * <p/>
- * The suggested list of keyword color names is: aqua, black, blue, fuchsia,
- * gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white,
- * and yellow. These 16 colors are taken from the Windows VGA palette, and their
- * RGB values are not defined in this specification.
- * <PRE>
- * BODY {color: black; background: white }
- * H1 { color: maroon }
- * H2 { color: olive }
- * </PRE>
- * <p/>
- * The RGB color model is being used in numerical color specifications. These
- * examples all specify the same color:
- * <PRE>
- * EM { color: #f00 } / * #rgb * /
- * EM { color: #ff0000 } / * #rrggbb * /
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(100%, 0%, 0%) } / * float range 0.0% - 100.0% * /
- * </PRE>
- * <p/>
- * The format of an RGB value in hexadecimal notation is a '#' immediately followed
- * by either three or six hexadecimal characters. The three-digit RGB notation
- * (#rgb) is converted into six-digit form (#rrggbb) by replicating digits,
- * not by adding zeros. For example, #fb0 expands to #ffbb00. This makes sure
- * that white (#ffffff) can be specified with the short notation (#fff) and
- * removes any dependencies on the color depth of the display.
- * <p/>
- * The format of an RGB value in the functional notation is 'rgb(' followed
- * by a comma-separated list of three numerical values (either three integer
- * values in the range of 0-255, or three percentage values in the range of
- * 0.0% to 100.0%) followed by ')'. Whitespace characters are allowed around
- * the numerical values.
- * <p/>
- * Values outside the numerical ranges should be clipped. The three rules below
- * are therefore equivalent:
- * <PRE>
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(300,0,0) } / * clipped to 255 * /
- * EM { color: rgb(110%, 0%, 0%) } / * clipped to 100% * /
- * </PRE>
- * <p/>
- * RGB colors are specified in the sRGB color space <A HREF="#ref9">[9]</A>.
- * UAs may vary in the fidelity with which they represent these colors, but
- * use of sRGB provides an unambiguous and objectively measurable definition
- * of what the color should be, which can be related to international standards
- * <A HREF="#ref10">[10]</A>.
- * <p/>
- * UAs may limit their efforts in displaying colors to performing a gamma-correction
- * on them. sRGB specifies a display gamma of 2.2 under specified viewing
- * conditions. UAs adjust the colors given in CSS such that, in combination
- * with an output device's "natural" display gamma, an effective display gamma
- * of 2.2 is produced. <A HREF="#appendix-d">Appendix D</A> gives further details
- * of this. Note that only colors specified in CSS are affected; e.g., images
- * are expected to carry their own color information.
- * <p/>
- * <p/>
- * <H2>
- * <A NAME="appendix-d">Appendix D: Gamma correction</A>
- * </H2>
- * <p/>
- * (This appendix is informative, not normative)
- * <p/>
- * See the <A href="http://www.w3.org/pub/WWW/TR/PNG-GammaAppendix">Gamma
- * Tutorial</A> in the PNG specification <A href="#ref12">[12]</A> if you aren't
- * already familiar with gamma issues.
- * <p/>
- * In the computation, UAs displaying on a CRT may assume an ideal CRT and ignore
- * any effects on apparent gamma caused by dithering. That means the minimal
- * handling they need to do on current platforms is:
- * <DL>
- * <DT>
- * PC using MS-Windows
- * <DD>
- * none
- * <DT>
- * Unix using X11
- * <DD>
- * none
- * <DT>
- * Mac using QuickDraw
- * <DD>
- * apply gamma 1.39 <A HREF="#ref13">[13]</A> (ColorSync-savvy applications
- * may simply pass the sRGB ICC profile <A HREF="#ref14">[14]</A> to ColorSync
- * to perform correct color correction)
- * <DT>
- * SGI using X
- * <DD>
- * apply the gamma value from <TT>/etc/config/system.glGammaVal</TT> (the default
- * value being 1.70; applications running on Irix 6.2 or above may simply pass
- * the sRGB ICC profile to the color management system)
- * <DT>
- * NeXT using NeXTStep
- * <DD>
- * apply gamma 2.22
- * </DL>
- * <p/>
- * "Applying gamma" means that each of the three R, G and B must be converted
- * to R'=R<SUP>gamma</SUP>, G'=G<SUP>gamma</SUP>, G'=B<SUP>gamma</SUP>, before
- * handing to the OS.
- * <p/>
- * This may rapidly be done by building a 256-element lookup table once per
- * browser invocation thus:
- * <PRE>
- * for i := 0 to 255 do
- * raw := i / 255;
- * corr := pow (raw, gamma);
- * table[i] := trunc (0.5 + corr * 255.0)
- * end
- * </PRE>
- * <p/>
- * which then avoids any need to do transcendental math per color attribute,
- * far less per pixel.
- * <p/>
- * See also
- * <p/>
- * <A NAME="ref9">[9]</A> M Anderson, R Motta, S Chandrasekar, M Stokes:
- * "<A HREF="http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm">Proposal
- * for a Standard Color Space for the Internet - sRGB</A>"
- * (http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm)
- * <p/>
- * <A NAME="ref10">[10]</A> CIE Publication 15.2-1986,
- * "<A HREF="http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html">Colorimetry,
- * Second Edition</A>", ISBN 3-900-734-00-3
- * (http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html)
- * <p/>
- * <A NAME="ref12">[12]</A>
- * "<A href="http://www.w3.org/pub/WWW/TR/REC-png-multi.html">PNG (Portable
- * Network Graphics) Specification, Version 1.0 specification</A>"
- * (http://www.w3.org/pub/WWW/TR/REC-png-multi.html)
- * <p/>
- * <A NAME="ref13">[13]</A> Charles A. Poynton:
- * "<A HREF="ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf">Gamma
- * correction on the Macintosh Platform</A>"
- * (ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf)
- * <p/>
- * <A NAME="ref14">[14]</A> International Color Consortium:
- * "<A HREF="ftp://sgigate.sgi.com/pub/icc/ICC32.pdf">ICC Profile Format
- * Specification, version 3.2</A>", 1995 (ftp://sgigate.sgi.com/pub/icc/ICC32.pdf)
- *
+ @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#color-units
* @version $Revision$
*/
-public class CssColorCSS2 extends CssColor {
-
- static HashMap<String, Object> definedColorsCSS2;
+public class CssColorCSS2 {
- /**
- * Create a new CssColorCSS2.
- */
- public CssColorCSS2() {
- //color = new CssIdent("");
- }
+ protected static final HashMap<String, RGB> definedRGBColorsCSS2;
+ protected static final HashMap<String, String> definedSystemColorsCSS2;
- /**
- * Create a new CssColorCSS2 with a color name.
- *
- * @param ac The context
- * @param s The name color.
- * @throws InvalidParamException the color is incorrect
- */
- public CssColorCSS2(ApplContext ac, String s) throws InvalidParamException {
- // setIdentColor(s.toLowerCase(), ac);
- setIdentColor(s, ac);
+ public static RGB getRGB(String ident) {
+ return definedRGBColorsCSS2.get(ident);
}
- /**
- * Parse an ident color.
- *
- * @param s the color name as a <EM>String<EM>
- * @param ac The context
- * @throws org.w3c.css.util.InvalidParamException
- * when the color definition is invalid
- */
- private void setIdentColor(String s, ApplContext ac)
- throws InvalidParamException {
- String lower_s = s.toLowerCase();
- if (!computeIdentColor(definedColorsCSS2, lower_s)) {
- throw new InvalidParamException("value", s, "color", ac);
- }
+ public static String getSystem(String ident) {
+ return definedSystemColorsCSS2.get(ident);
}
static {
- definedColorsCSS2 = new HashMap<String, Object>();
- definedColorsCSS2.put("black",
- new RGB(0, 0, 0));
- definedColorsCSS2.put("silver",
- new RGB(192, 192, 192));
- definedColorsCSS2.put("gray",
- new RGB(128, 128, 128));
- definedColorsCSS2.put("white",
- new RGB(255, 255, 255));
- definedColorsCSS2.put("maroon",
- new RGB(128, 0, 0));
- definedColorsCSS2.put("red",
- new RGB(255, 0, 0));
- definedColorsCSS2.put("purple",
- new RGB(128, 0, 128));
- definedColorsCSS2.put("fuchsia",
- new RGB(255, 0, 255));
- definedColorsCSS2.put("green",
- new RGB(0, 128, 0));
- definedColorsCSS2.put("lime",
- new RGB(0, 255, 0));
- definedColorsCSS2.put("olive",
- new RGB(128, 128, 0));
- definedColorsCSS2.put("yellow",
- new RGB(255, 255, 0));
- definedColorsCSS2.put("navy",
- new RGB(0, 0, 128));
- definedColorsCSS2.put("blue",
- new RGB(0, 0, 255));
- definedColorsCSS2.put("teal",
- new RGB(0, 128, 128));
- definedColorsCSS2.put("aqua",
- new RGB(0, 255, 255));
- definedColorsCSS2.put("activeborder", "ActiveBorder");
- definedColorsCSS2.put("activecaption", "ActiveCaption");
- definedColorsCSS2.put("appworkspace", "AppWorkspace");
- definedColorsCSS2.put("background", "Background");
- definedColorsCSS2.put("buttonface", "ButtonFace");
- definedColorsCSS2.put("buttonhighlight", "ButtonHighlight");
- definedColorsCSS2.put("buttonshadow", "ButtonShadow");
- definedColorsCSS2.put("buttontext", "ButtonText");
- definedColorsCSS2.put("captiontext", "CaptionText");
- definedColorsCSS2.put("graytext", "GrayText");
- definedColorsCSS2.put("highlight", "Highlight");
- definedColorsCSS2.put("highlighttext", "HighlightText");
- definedColorsCSS2.put("inactiveborder", "InactiveBorder");
- definedColorsCSS2.put("inactivecaption", "InactiveCaption");
- definedColorsCSS2.put("inactivecaptiontext", "InactiveCaptionText");
- definedColorsCSS2.put("infobackground", "InfoBackground");
- definedColorsCSS2.put("infotext", "InfoText");
- definedColorsCSS2.put("menu", "Menu");
- definedColorsCSS2.put("menutext", "MenuText");
- definedColorsCSS2.put("scrollbar", "Scrollbar");
- definedColorsCSS2.put("threeddarkshadow", "ThreeDDarkShadow");
- definedColorsCSS2.put("threedface", "ThreeDFace");
- definedColorsCSS2.put("threedhighlight", "ThreeDHighlight");
- definedColorsCSS2.put("threedlightshadow", "ThreeDLightShadow");
- definedColorsCSS2.put("threedshadow", "ThreeDShadow");
- definedColorsCSS2.put("window", "Window");
- definedColorsCSS2.put("windowframe", "WindowFrame");
- definedColorsCSS2.put("windowtext", "WindowText");
+ // http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#color-units
+ definedRGBColorsCSS2 = new HashMap<String, RGB>();
+ definedRGBColorsCSS2.put("black", new RGB(0, 0, 0));
+ definedRGBColorsCSS2.put("silver", new RGB(192, 192, 192));
+ definedRGBColorsCSS2.put("gray", new RGB(128, 128, 128));
+ definedRGBColorsCSS2.put("white", new RGB(255, 255, 255));
+ definedRGBColorsCSS2.put("maroon", new RGB(128, 0, 0));
+ definedRGBColorsCSS2.put("red", new RGB(255, 0, 0));
+ definedRGBColorsCSS2.put("purple", new RGB(128, 0, 128));
+ definedRGBColorsCSS2.put("fuchsia", new RGB(255, 0, 255));
+ definedRGBColorsCSS2.put("green", new RGB(0, 128, 0));
+ definedRGBColorsCSS2.put("lime", new RGB(0, 255, 0));
+ definedRGBColorsCSS2.put("olive", new RGB(128, 128, 0));
+ definedRGBColorsCSS2.put("yellow", new RGB(255, 255, 0));
+ definedRGBColorsCSS2.put("navy", new RGB(0, 0, 128));
+ definedRGBColorsCSS2.put("blue", new RGB(0, 0, 255));
+ definedRGBColorsCSS2.put("teal", new RGB(0, 128, 128));
+ definedRGBColorsCSS2.put("aqua", new RGB(0, 255, 255));
+
+ // http://www.w3.org/TR/2008/REC-CSS2-20080411/ui.html#system-colors
+ definedSystemColorsCSS2 = new HashMap<String, String>();
+ definedSystemColorsCSS2.put("activeborder", "ActiveBorder");
+ definedSystemColorsCSS2.put("activecaption", "ActiveCaption");
+ definedSystemColorsCSS2.put("appworkspace", "AppWorkspace");
+ definedSystemColorsCSS2.put("background", "Background");
+ definedSystemColorsCSS2.put("buttonface", "ButtonFace");
+ definedSystemColorsCSS2.put("buttonhighlight", "ButtonHighlight");
+ definedSystemColorsCSS2.put("buttonshadow", "ButtonShadow");
+ definedSystemColorsCSS2.put("buttontext", "ButtonText");
+ definedSystemColorsCSS2.put("captiontext", "CaptionText");
+ definedSystemColorsCSS2.put("graytext", "GrayText");
+ definedSystemColorsCSS2.put("highlight", "Highlight");
+ definedSystemColorsCSS2.put("highlighttext", "HighlightText");
+ definedSystemColorsCSS2.put("inactiveborder", "InactiveBorder");
+ definedSystemColorsCSS2.put("inactivecaption", "InactiveCaption");
+ definedSystemColorsCSS2.put("inactivecaptiontext", "InactiveCaptionText");
+ definedSystemColorsCSS2.put("infobackground", "InfoBackground");
+ definedSystemColorsCSS2.put("infotext", "InfoText");
+ definedSystemColorsCSS2.put("menu", "Menu");
+ definedSystemColorsCSS2.put("menutext", "MenuText");
+ definedSystemColorsCSS2.put("scrollbar", "Scrollbar");
+ definedSystemColorsCSS2.put("threeddarkshadow", "ThreeDDarkShadow");
+ definedSystemColorsCSS2.put("threedface", "ThreeDFace");
+ definedSystemColorsCSS2.put("threedhighlight", "ThreeDHighlight");
+ definedSystemColorsCSS2.put("threedlightshadow", "ThreeDLightShadow");
+ definedSystemColorsCSS2.put("threedshadow", "ThreeDShadow");
+ definedSystemColorsCSS2.put("window", "Window");
+ definedSystemColorsCSS2.put("windowframe", "WindowFrame");
+ definedSystemColorsCSS2.put("windowtext", "WindowText");
}
}
--- NEW FILE: CssColorCSS3.java ---
// $Id: CssColorCSS3.java,v 1.1 2011/09/29 09:09:00 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
import java.util.HashMap;
/**
* @spec http://www.w3.org/TR/2011/REC-css3-color-20110607/
*/
public class CssColorCSS3 {
protected static final HashMap<String, RGB> definedRGBColorsCSS3;
private static final RGBA trans;
public static RGB getRGB(String ident) {
return definedRGBColorsCSS3.get(ident);
}
public static RGBA getRGBA(String ident) {
if ("transparent".equalsIgnoreCase(ident)) {
return trans;
}
return null;
}
// those are the same as CSS2, let's use that
// and note that they are deprecated...
public static String getSystem(String ident) {
return CssColorCSS2.definedSystemColorsCSS2.get(ident);
}
static {
trans = new RGBA(0,0,0,0.f);
// http://www.w3.org/TR/2011/REC-css3-color-20110607/#svg-color
definedRGBColorsCSS3 = new HashMap<String, RGB>();
definedRGBColorsCSS3.put("aliceblue", new RGB(240, 248, 255));
definedRGBColorsCSS3.put("antiquewhite", new RGB(250, 235, 215));
definedRGBColorsCSS3.put("aqua", new RGB(0, 255, 255));
definedRGBColorsCSS3.put("aquamarine", new RGB(127, 255, 212));
definedRGBColorsCSS3.put("azure", new RGB(240, 255, 255));
definedRGBColorsCSS3.put("beige", new RGB(245, 245, 220));
definedRGBColorsCSS3.put("bisque", new RGB(255, 228, 196));
definedRGBColorsCSS3.put("black", new RGB(0, 0, 0));
definedRGBColorsCSS3.put("blanchedalmond", new RGB(255, 235, 205));
definedRGBColorsCSS3.put("blue", new RGB(0, 0, 255));
definedRGBColorsCSS3.put("blueviolet", new RGB(138, 43, 226));
definedRGBColorsCSS3.put("brown", new RGB(165, 42, 42));
definedRGBColorsCSS3.put("burlywood", new RGB(222, 184, 135));
definedRGBColorsCSS3.put("cadetblue", new RGB(95, 158, 160));
definedRGBColorsCSS3.put("chartreuse", new RGB(127, 255, 0));
definedRGBColorsCSS3.put("chocolate", new RGB(210, 105, 30));
definedRGBColorsCSS3.put("coral", new RGB(255, 127, 80));
definedRGBColorsCSS3.put("cornflowerblue", new RGB(100, 149, 237));
definedRGBColorsCSS3.put("cornsilk", new RGB(255, 248, 220));
definedRGBColorsCSS3.put("crimson", new RGB(220, 20, 60));
definedRGBColorsCSS3.put("cyan", new RGB(0, 255, 255));
definedRGBColorsCSS3.put("darkblue", new RGB(0, 0, 139));
definedRGBColorsCSS3.put("darkcyan", new RGB(0, 139, 139));
definedRGBColorsCSS3.put("darkgoldenrod", new RGB(184, 134, 11));
definedRGBColorsCSS3.put("darkgray", new RGB(169, 169, 169));
definedRGBColorsCSS3.put("darkgreen", new RGB(0, 100, 0));
definedRGBColorsCSS3.put("darkgrey", new RGB(169, 169, 169));
definedRGBColorsCSS3.put("darkkhaki", new RGB(189, 183, 107));
definedRGBColorsCSS3.put("darkmagenta", new RGB(139, 0, 139));
definedRGBColorsCSS3.put("darkolivegreen", new RGB(85, 107, 47));
definedRGBColorsCSS3.put("darkorange", new RGB(255, 140, 0));
definedRGBColorsCSS3.put("darkorchid", new RGB(153, 50, 204));
definedRGBColorsCSS3.put("darkred", new RGB(139, 0, 0));
definedRGBColorsCSS3.put("darksalmon", new RGB(233, 150, 122));
definedRGBColorsCSS3.put("darkseagreen", new RGB(143, 188, 143));
definedRGBColorsCSS3.put("darkslateblue", new RGB(72, 61, 139));
definedRGBColorsCSS3.put("darkslategray", new RGB(47, 79, 79));
definedRGBColorsCSS3.put("darkslategrey", new RGB(47, 79, 79));
definedRGBColorsCSS3.put("darkturquoise", new RGB(0, 206, 209));
definedRGBColorsCSS3.put("darkviolet", new RGB(148, 0, 211));
definedRGBColorsCSS3.put("deeppink", new RGB(255, 20, 147));
definedRGBColorsCSS3.put("deepskyblue", new RGB(0, 191, 255));
definedRGBColorsCSS3.put("dimgray", new RGB(105, 105, 105));
definedRGBColorsCSS3.put("dimgrey", new RGB(105, 105, 105));
definedRGBColorsCSS3.put("dodgerblue", new RGB(30, 144, 255));
definedRGBColorsCSS3.put("firebrick", new RGB(178, 34, 34));
definedRGBColorsCSS3.put("floralwhite", new RGB(255, 250, 240));
definedRGBColorsCSS3.put("forestgreen", new RGB(34, 139, 34));
definedRGBColorsCSS3.put("fuchsia", new RGB(255, 0, 255));
definedRGBColorsCSS3.put("gainsboro", new RGB(220, 220, 220));
definedRGBColorsCSS3.put("ghostwhite", new RGB(248, 248, 255));
definedRGBColorsCSS3.put("gold", new RGB(255, 215, 0));
definedRGBColorsCSS3.put("goldenrod", new RGB(218, 165, 32));
definedRGBColorsCSS3.put("gray", new RGB(128, 128, 128));
definedRGBColorsCSS3.put("green", new RGB(0, 128, 0));
definedRGBColorsCSS3.put("greenyellow", new RGB(173, 255, 47));
definedRGBColorsCSS3.put("grey", new RGB(128, 128, 128));
definedRGBColorsCSS3.put("honeydew", new RGB(240, 255, 240));
definedRGBColorsCSS3.put("hotpink", new RGB(255, 105, 180));
definedRGBColorsCSS3.put("indianred", new RGB(205, 92, 92));
definedRGBColorsCSS3.put("indigo", new RGB(75, 0, 130));
definedRGBColorsCSS3.put("ivory", new RGB(255, 255, 240));
definedRGBColorsCSS3.put("khaki", new RGB(240, 230, 140));
definedRGBColorsCSS3.put("lavender", new RGB(230, 230, 250));
definedRGBColorsCSS3.put("lavenderblush", new RGB(255, 240, 245));
definedRGBColorsCSS3.put("lawngreen", new RGB(124, 252, 0));
definedRGBColorsCSS3.put("lemonchiffon", new RGB(255, 250, 205));
definedRGBColorsCSS3.put("lightblue", new RGB(173, 216, 230));
definedRGBColorsCSS3.put("lightcoral", new RGB(240, 128, 128));
definedRGBColorsCSS3.put("lightcyan", new RGB(224, 255, 255));
definedRGBColorsCSS3.put("lightgoldenrodyellow", new RGB(250, 250, 210));
definedRGBColorsCSS3.put("lightgray", new RGB(211, 211, 211));
definedRGBColorsCSS3.put("lightgreen", new RGB(144, 238, 144));
definedRGBColorsCSS3.put("lightgrey", new RGB(211, 211, 211));
definedRGBColorsCSS3.put("lightpink", new RGB(255, 182, 193));
definedRGBColorsCSS3.put("lightsalmon", new RGB(255, 160, 122));
definedRGBColorsCSS3.put("lightseagreen", new RGB(32, 178, 170));
definedRGBColorsCSS3.put("lightskyblue", new RGB(135, 206, 250));
definedRGBColorsCSS3.put("lightslategray", new RGB(119, 136, 153));
definedRGBColorsCSS3.put("lightslategrey", new RGB(119, 136, 153));
definedRGBColorsCSS3.put("lightsteelblue", new RGB(176, 196, 222));
definedRGBColorsCSS3.put("lightyellow", new RGB(255, 255, 224));
definedRGBColorsCSS3.put("lime", new RGB(0, 255, 0));
definedRGBColorsCSS3.put("limegreen", new RGB(50, 205, 50));
definedRGBColorsCSS3.put("linen", new RGB(250, 240, 230));
definedRGBColorsCSS3.put("magenta", new RGB(255, 0, 255));
definedRGBColorsCSS3.put("maroon", new RGB(128, 0, 0));
definedRGBColorsCSS3.put("mediumaquamarine", new RGB(102, 205, 170));
definedRGBColorsCSS3.put("mediumblue", new RGB(0, 0, 205));
definedRGBColorsCSS3.put("mediumorchid", new RGB(186, 85, 211));
definedRGBColorsCSS3.put("mediumpurple", new RGB(147, 112, 219));
definedRGBColorsCSS3.put("mediumseagreen", new RGB(60, 179, 113));
definedRGBColorsCSS3.put("mediumslateblue", new RGB(123, 104, 238));
definedRGBColorsCSS3.put("mediumspringgreen", new RGB(0, 250, 154));
definedRGBColorsCSS3.put("mediumturquoise", new RGB(72, 209, 204));
definedRGBColorsCSS3.put("mediumvioletred", new RGB(199, 21, 133));
definedRGBColorsCSS3.put("midnightblue", new RGB(25, 25, 112));
definedRGBColorsCSS3.put("mintcream", new RGB(245, 255, 250));
definedRGBColorsCSS3.put("mistyrose", new RGB(255, 228, 225));
definedRGBColorsCSS3.put("moccasin", new RGB(255, 228, 181));
definedRGBColorsCSS3.put("navajowhite", new RGB(255, 222, 173));
definedRGBColorsCSS3.put("navy", new RGB(0, 0, 128));
definedRGBColorsCSS3.put("oldlace", new RGB(253, 245, 230));
definedRGBColorsCSS3.put("olive", new RGB(128, 128, 0));
definedRGBColorsCSS3.put("olivedrab", new RGB(107, 142, 35));
definedRGBColorsCSS3.put("orange", new RGB(255, 165, 0));
definedRGBColorsCSS3.put("orangered", new RGB(255, 69, 0));
definedRGBColorsCSS3.put("orchid", new RGB(218, 112, 214));
definedRGBColorsCSS3.put("palegoldenrod", new RGB(238, 232, 170));
definedRGBColorsCSS3.put("palegreen", new RGB(152, 251, 152));
definedRGBColorsCSS3.put("paleturquoise", new RGB(175, 238, 238));
definedRGBColorsCSS3.put("palevioletred", new RGB(219, 112, 147));
definedRGBColorsCSS3.put("papayawhip", new RGB(255, 239, 213));
definedRGBColorsCSS3.put("peachpuff", new RGB(255, 218, 185));
definedRGBColorsCSS3.put("peru", new RGB(205, 133, 63));
definedRGBColorsCSS3.put("pink", new RGB(255, 192, 203));
definedRGBColorsCSS3.put("plum", new RGB(221, 160, 221));
definedRGBColorsCSS3.put("powderblue", new RGB(176, 224, 230));
definedRGBColorsCSS3.put("purple", new RGB(128, 0, 128));
definedRGBColorsCSS3.put("red", new RGB(255, 0, 0));
definedRGBColorsCSS3.put("rosybrown", new RGB(188, 143, 143));
definedRGBColorsCSS3.put("royalblue", new RGB(65, 105, 225));
definedRGBColorsCSS3.put("saddlebrown", new RGB(139, 69, 19));
definedRGBColorsCSS3.put("salmon", new RGB(250, 128, 114));
definedRGBColorsCSS3.put("sandybrown", new RGB(244, 164, 96));
definedRGBColorsCSS3.put("seagreen", new RGB(46, 139, 87));
definedRGBColorsCSS3.put("seashell", new RGB(255, 245, 238));
definedRGBColorsCSS3.put("sienna", new RGB(160, 82, 45));
definedRGBColorsCSS3.put("silver", new RGB(192, 192, 192));
definedRGBColorsCSS3.put("skyblue", new RGB(135, 206, 235));
definedRGBColorsCSS3.put("slateblue", new RGB(106, 90, 205));
definedRGBColorsCSS3.put("slategray", new RGB(112, 128, 144));
definedRGBColorsCSS3.put("slategrey", new RGB(112, 128, 144));
definedRGBColorsCSS3.put("snow", new RGB(255, 250, 250));
definedRGBColorsCSS3.put("springgreen", new RGB(0, 255, 127));
definedRGBColorsCSS3.put("steelblue", new RGB(70, 130, 180));
definedRGBColorsCSS3.put("tan", new RGB(210, 180, 140));
definedRGBColorsCSS3.put("teal", new RGB(0, 128, 128));
definedRGBColorsCSS3.put("thistle", new RGB(216, 191, 216));
definedRGBColorsCSS3.put("tomato", new RGB(255, 99, 71));
definedRGBColorsCSS3.put("turquoise", new RGB(64, 224, 208));
definedRGBColorsCSS3.put("violet", new RGB(238, 130, 238));
definedRGBColorsCSS3.put("wheat", new RGB(245, 222, 179));
definedRGBColorsCSS3.put("white", new RGB(255, 255, 255));
definedRGBColorsCSS3.put("whitesmoke", new RGB(245, 245, 245));
definedRGBColorsCSS3.put("yellow", new RGB(255, 255, 0));
definedRGBColorsCSS3.put("yellowgreen", new RGB(154, 205, 50));
}
}
--- CssColorConstants.java DELETED ---
--- ATSCColor.java DELETED ---
Index: CssColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColor.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- CssColor.java 27 Sep 2011 08:15:46 -0000 1.21
+++ CssColor.java 29 Sep 2011 09:09:00 -0000 1.22
@@ -16,150 +16,6 @@
import static org.w3c.css.values.CssOperator.COMMA;
/**
- * <H3>
- * Color units
- * </H3>
- * <p/>
- * A color is a either a keyword or a numerical RGB specification.
- * <p/>
- * The suggested list of keyword color names is: aqua, black, blue, fuchsia,
- * gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white,
- * and yellow. These 16 colors are taken from the Windows VGA palette,
- * and their RGB values are not defined in this specification.
- * <PRE>
- * BODY {color: black; background: white }
- * H1 { color: maroon }
- * H2 { color: olive }
- * </PRE>
- * <p/>
- * The RGB color model is being used in numerical color specifications. These
- * examples all specify the same color:
- * <PRE>
- * EM { color: #f00 } / * #rgb * /
- * EM { color: #ff0000 } / * #rrggbb * /
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(100%, 0%, 0%) } / * float range 0.0% - 100.0% * /
- * </PRE>
- * <p/>
- * The format of an RGB value in hexadecimal notation is a '#' immediately followed
- * by either three or six hexadecimal characters. The three-digit RGB notation
- * (#rgb) is converted into six-digit form (#rrggbb) by replicating digits,
- * not by adding zeros. For example, #fb0 expands to #ffbb00. This makes sure
- * that white (#ffffff) can be specified with the short notation (#fff) and
- * removes any dependencies on the color depth of the display.
- * <p/>
- * The format of an RGB value in the functional notation is 'rgb(' followed
- * by a comma-separated list of three numerical values (either three integer
- * values in the range of 0-255, or three percentage values in the range of
- * 0.0% to 100.0%) followed by ')'. Whitespace characters are allowed around
- * the numerical values.
- * <p/>
- * Values outside the numerical ranges should be clipped. The three rules below
- * are therefore equivalent:
- * <PRE>
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(300,0,0) } / * clipped to 255 * /
- * EM { color: rgb(110%, 0%, 0%) } / * clipped to 100% * /
- * </PRE>
- * <p/>
- * RGB colors are specified in the sRGB color space <A HREF="#ref9">[9]</A>.
- * UAs may vary in the fidelity with which they represent these colors, but
- * use of sRGB provides an unambiguous and objectively measurable definition
- * of what the color should be, which can be related to international standards
- * <A HREF="#ref10">[10]</A>.
- * <p/>
- * UAs may limit their efforts in displaying colors to performing a gamma-correction
- * on them. sRGB specifies a display gamma of 2.2 under specified viewing
- * conditions. UAs adjust the colors given in CSS such that, in combination
- * with an output device's "natural" display gamma, an effective display gamma
- * of 2.2 is produced. <A HREF="#appendix-d">Appendix D</A> gives further details
- * of this. Note that only colors specified in CSS are affected; e.g., images
- * are expected to carry their own color information.
- * <p/>
- * <p/>
- * <H2>
- * <A NAME="appendix-d">Appendix D: Gamma correction</A>
- * </H2>
- * <p/>
- * (This appendix is informative, not normative)
- * <p/>
- * See the <A href="http://www.w3.org/pub/WWW/TR/PNG-GammaAppendix">Gamma
- * Tutorial</A> in the PNG specification <A href="#ref12">[12]</A> if you aren't
- * already familiar with gamma issues.
- * <p/>
- * In the computation, UAs displaying on a CRT may assume an ideal CRT and ignore
- * any effects on apparent gamma caused by dithering. That means the minimal
- * handling they need to do on current platforms is:
- * <DL>
- * <DT>
- * PC using MS-Windows
- * <DD>
- * none
- * <DT>
- * Unix using X11
- * <DD>
- * none
- * <DT>
- * Mac using QuickDraw
- * <DD>
- * apply gamma 1.39 <A HREF="#ref13">[13]</A> (ColorSync-savvy applications
- * may simply pass the sRGB ICC profile <A HREF="#ref14">[14]</A> to ColorSync
- * to perform correct color correction)
- * <DT>
- * SGI using X
- * <DD>
- * apply the gamma value from <TT>/etc/config/system.glGammaVal</TT> (the default
- * value being 1.70; applications running on Irix 6.2 or above may simply pass
- * the sRGB ICC profile to the color management system)
- * <DT>
- * NeXT using NeXTStep
- * <DD>
- * apply gamma 2.22
- * </DL>
- * <p/>
- * "Applying gamma" means that each of the three R, G and B must be converted
- * to R'=R<SUP>gamma</SUP>, G'=G<SUP>gamma</SUP>, G'=B<SUP>gamma</SUP>, before
- * handing to the OS.
- * <p/>
- * This may rapidly be done by building a 256-element lookup table once per
- * browser invocation thus:
- * <PRE>
- * for i := 0 to 255 do
- * raw := i / 255;
- * corr := pow (raw, gamma);
- * table[i] := trunc (0.5 + corr * 255.0)
- * end
- * </PRE>
- * <p/>
- * which then avoids any need to do transcendental math per color attribute,
- * far less per pixel.
- * <p/>
- * See also
- * <p/>
- * <A NAME="ref9">[9]</A> M Anderson, R Motta, S Chandrasekar, M Stokes:
- * "<A HREF="http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm">Proposal
- * for a Standard Color Space for the Internet - sRGB</A>"
- * (http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm)
- * <p/>
- * <A NAME="ref10">[10]</A> CIE Publication 15.2-1986,
- * "<A HREF="http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html">Colorimetry,
- * Second Edition</A>", ISBN 3-900-734-00-3
- * (http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html)
- * <p/>
- * <A NAME="ref12">[12]</A>
- * "<A href="http://www.w3.org/pub/WWW/TR/REC-png-multi.html">PNG (Portable
- * Network Graphics) Specification, Version 1.0 specification</A>"
- * (http://www.w3.org/pub/WWW/TR/REC-png-multi.html)
- * <p/>
- * <A NAME="ref13">[13]</A> Charles A. Poynton:
- * "<A HREF="ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf">Gamma
- * correction on the Macintosh Platform</A>"
- * (ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf)
- * <p/>
- * <A NAME="ref14">[14]</A> International Color Consortium:
- * "<A HREF="ftp://sgigate.sgi.com/pub/icc/ICC32.pdf">ICC Profile Format
- * Specification, version 3.2</A>", 1995 (ftp://sgigate.sgi.com/pub/icc/ICC32.pdf)
- *
* @version $Revision$
*/
public class CssColor extends CssValue {
@@ -176,15 +32,10 @@
HSL hsl = null;
HSLA hsla = null;
- protected static HashMap<String, Object> definedColors;
- private static HashMap<String, String> deprecatedColors;
- static CssIdent inherit;
-
/**
* Create a new CssColor.
*/
public CssColor() {
- color = inherit;
}
/**
@@ -217,34 +68,19 @@
*/
public Object get() {
if (color != null) {
- if (color == inherit) {
- return null;
- } else {
- return color;
- }
+ return color;
} else {
return rgb;
}
}
- /**
- * Returns <code>true</code> if the internal value is the default value
- * (e.g. 'inherited').
- */
- public boolean isDefault() {
- return color == inherit;
- }
/**
* Returns a string representation of the object.
*/
public String toString() {
if (color != null) {
- if (color == inherit) {
- return inherit.toString();
- } else {
- return color.toString();
- }
+ return color.toString();
} else if (rgba != null) {
return rgba.toString();
} else if (hsl != null) {
@@ -435,15 +271,58 @@
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;
- ac.getFrame().addWarning("deprecated", s);
- return;
+ switch (ac.getCssVersion()) {
+ case CSS1:
+ rgb = CssColorCSS1.getRGB(lower_s);
+ if (rgb == null) {
+ throw new InvalidParamException("value", s, "color", ac);
+ }
+ color = lower_s;
+ break;
+ case CSS2:
+ rgb = CssColorCSS2.getRGB(lower_s);
+ if (rgb == null) {
+ color = CssColorCSS2.getSystem(lower_s);
+ if (color == null) {
+ throw new InvalidParamException("value", s, "color", ac);
+ }
+ } else {
+ color = lower_s;
+ }
+ break;
+ case CSS21:
+ rgb = CssColorCSS21.getRGB(lower_s);
+ if (rgb == null) {
+ color = CssColorCSS21.getSystem(lower_s);
+ if (color == null) {
+ throw new InvalidParamException("value", s, "color", ac);
+ }
+ } else {
+ color = lower_s;
+ }
+ break;
+ case CSS3:
+ // test RGB colors, RGBA colors (transparent), deprecated system colors
+ rgb = CssColorCSS3.getRGB(lower_s);
+ if (rgb != null) {
+ color = lower_s;
+ break;
+ }
+ rgba = CssColorCSS3.getRGBA(lower_s);
+ if (rgba != null) {
+ color = lower_s;
+ break;
+ }
+ color = CssColorCSS3.getSystem(lower_s);
+ if (color != null) {
+ ac.getFrame().addWarning("deprecated", s);
+ break;
+ }
+ // inherit or current color will be handled in the property def
+ throw new InvalidParamException("value", s, "color", ac);
+ default:
+ throw new InvalidParamException("value", s, "color", ac);
}
-
- throw new InvalidParamException("value", s, "color", ac);
}
/**
@@ -471,12 +350,24 @@
return false;
}
+ public void setATSCRGBAColor(CssExpression exp, ApplContext ac)
+ throws InvalidParamException {
+ rgba = new RGBA("atsc-rgba");
+ __setRGBAColor(rgba, exp, ac);
+
+ }
+
public void setRGBAColor(CssExpression exp, ApplContext ac)
throws InvalidParamException {
+ rgba = new RGBA();
+ __setRGBAColor(rgba, exp, ac);
+ }
+
+ private void __setRGBAColor(RGBA rgba, CssExpression exp, ApplContext ac)
+ throws InvalidParamException {
CssValue val;
char op;
color = null;
- rgba = new RGBA();
val = exp.getValue();
op = exp.getOperator();
@@ -739,375 +630,5 @@
return p;
}
- /**
- * Gets the red component of this color.
- */
- // public Object getRed() {
- // return rgb.r;
- //}
-
- /**
- * Gets the green component of this color.
- */
- // public Object getGreen() {
- // return rgb.g;
- //}
-
- /**
- * Gets the blue component of this color.
- */
- //public Object getBlue() {
- // return rgb.b;
- //}
-
- static {
- inherit = CssIdent.getIdent("inherit");
- definedColors = new HashMap<String, Object>();
- deprecatedColors = new HashMap<String, String>();
-
- definedColors.put("aliceblue",
- new RGB(240, 248, 255));
- definedColors.put("antiquewhite",
- new RGB(250, 235, 215));
- definedColors.put("aqua",
- new RGB(0, 255, 255));
- definedColors.put("aquamarine",
- new RGB(127, 255, 212));
- definedColors.put("azure",
- new RGB(240, 255, 255));
- definedColors.put("beige",
- new RGB(245, 245, 220));
- definedColors.put("bisque",
- new RGB(255, 228, 196));
- definedColors.put("black",
- new RGB(0, 0, 0));
- definedColors.put("blanchedalmond",
- new RGB(255, 235, 205));
- definedColors.put("blue",
- new RGB(0, 0, 255));
- definedColors.put("blueviolet",
- new RGB(138, 43, 226));
- definedColors.put("brown",
- new RGB(165, 42, 42));
- definedColors.put("burlywood",
- new RGB(222, 184, 135));
- definedColors.put("cadetBlue",
- new RGB(95, 158, 160));
- definedColors.put("chartreuse",
- new RGB(127, 255, 0));
- definedColors.put("chocolate",
- new RGB(210, 105, 30));
- definedColors.put("coral",
- new RGB(255, 127, 80));
- definedColors.put("cornflowerblue",
- new RGB(100, 149, 237));
- definedColors.put("cornsilk",
- new RGB(255, 248, 220));
- definedColors.put("crimson",
- new RGB(220, 20, 60));
- definedColors.put("cyan",
- new RGB(0, 255, 255));
- definedColors.put("darkblue",
- new RGB(0, 0, 139));
- definedColors.put("darkcyan",
- new RGB(0, 139, 139));
- definedColors.put("darkgoldenrod",
- new RGB(184, 134, 11));
- definedColors.put("darkgray",
- new RGB(169, 169, 169));
- definedColors.put("darkgreen",
- new RGB(0, 100, 0));
- definedColors.put("darkkhaki",
- new RGB(189, 183, 107));
- definedColors.put("darkmagenta",
- new RGB(139, 0, 139));
- definedColors.put("darkolivegreen",
- new RGB(85, 107, 47));
- definedColors.put("darkorange",
- new RGB(255, 140, 0));
- definedColors.put("darkorchid",
- new RGB(153, 50, 204));
- definedColors.put("darkred",
- new RGB(139, 0, 0));
- definedColors.put("darksalmon",
- new RGB(233, 150, 122));
- definedColors.put("darkseagreen",
- new RGB(143, 188, 143));
- definedColors.put("darkslateblue",
- new RGB(72, 61, 139));
- definedColors.put("darkslategray",
- new RGB(47, 79, 79));
- definedColors.put("darkturquoise",
- new RGB(0, 206, 209));
- definedColors.put("darkviolet",
- new RGB(148, 0, 211));
- definedColors.put("deeppink",
- new RGB(255, 20, 147));
- definedColors.put("deepskyblue",
- new RGB(0, 191, 255));
- definedColors.put("dimgray",
- new RGB(105, 105, 105));
- definedColors.put("dodgerblue",
- new RGB(30, 144, 255));
- definedColors.put("firebrick",
- new RGB(178, 34, 34));
- definedColors.put("floralwhite",
- new RGB(255, 250, 240));
- definedColors.put("forestgreen",
- new RGB(34, 139, 34));
- definedColors.put("fuchsia",
- new RGB(255, 0, 255));
- definedColors.put("gainsboro",
- new RGB(220, 220, 220));
- definedColors.put("ghostwhite",
- new RGB(248, 248, 255));
- definedColors.put("gold",
- new RGB(255, 215, 0));
- definedColors.put("goldenrod",
- new RGB(218, 165, 32));
- definedColors.put("gray",
- new RGB(128, 128, 128));
- definedColors.put("green",
- new RGB(0, 128, 0));
- definedColors.put("greenyellow",
- new RGB(173, 255, 47));
- definedColors.put("honeydew",
- new RGB(240, 255, 240));
- definedColors.put("hotpink",
- new RGB(255, 105, 180));
- definedColors.put("indianred",
- new RGB(205, 92, 92));
- definedColors.put("indigo",
- new RGB(75, 0, 130));
- definedColors.put("ivory",
- new RGB(255, 255, 240));
- definedColors.put("khaki",
- new RGB(240, 230, 140));
- definedColors.put("lavender",
- new RGB(230, 230, 250));
- definedColors.put("lavenderblush",
- new RGB(255, 240, 245));
- definedColors.put("lawngreen",
- new RGB(124, 252, 0));
- definedColors.put("lemonchiffon",
- new RGB(255, 250, 205));
- definedColors.put("lightblue",
- new RGB(173, 216, 230));
- definedColors.put("lightcoral",
- new RGB(240, 128, 128));
- definedColors.put("lightcyan",
- new RGB(224, 255, 255));
- definedColors.put("lightgoldenrodyellow",
- new RGB(250, 250, 210));
- definedColors.put("lightgreen",
- new RGB(144, 238, 144));
- definedColors.put("lightgrey",
- new RGB(211, 211, 211));
- definedColors.put("lightpink",
- new RGB(255, 182, 193));
- definedColors.put("lightsalmon",
- new RGB(255, 160, 122));
- definedColors.put("lightseagreen",
- new RGB(32, 178, 170));
- definedColors.put("lightskyblue",
- new RGB(135, 206, 250));
- definedColors.put("lightslategray",
- new RGB(119, 136, 153));
- definedColors.put("lightsteelblue",
- new RGB(176, 196, 222));
- definedColors.put("lightyellow",
- new RGB(255, 255, 224));
- definedColors.put("lime",
- new RGB(0, 255, 0));
- definedColors.put("limegreen",
- new RGB(50, 205, 50));
- definedColors.put("linen",
- new RGB(250, 240, 230));
- definedColors.put("magenta",
- new RGB(255, 0, 255));
- definedColors.put("maroon",
- new RGB(128, 0, 0));
- definedColors.put("mediumaquamarine",
- new RGB(102, 205, 170));
- definedColors.put("mediumblue",
- new RGB(0, 0, 205));
- definedColors.put("mediumorchid",
- new RGB(186, 85, 211));
- definedColors.put("mediumpurple",
- new RGB(147, 112, 219));
- definedColors.put("mediumseagreen",
- new RGB(60, 179, 113));
- definedColors.put("mediumslateblue",
- new RGB(123, 104, 238));
- definedColors.put("mediumspringgreen",
- new RGB(0, 250, 154));
- definedColors.put("mediumturquoise",
- new RGB(72, 209, 204));
- definedColors.put("mediumvioletred",
- new RGB(199, 21, 133));
- definedColors.put("midnightblue",
- new RGB(25, 25, 112));
- definedColors.put("mintcream",
- new RGB(245, 255, 250));
- definedColors.put("mistyrose",
- new RGB(255, 228, 225));
- definedColors.put("moccasin",
- new RGB(255, 228, 181));
- definedColors.put("navajowhite",
- new RGB(255, 222, 173));
- definedColors.put("navy",
- new RGB(0, 0, 128));
- definedColors.put("oldlace",
- new RGB(253, 245, 230));
- definedColors.put("olive",
- new RGB(128, 128, 0));
- definedColors.put("olivedrab",
- new RGB(107, 142, 35));
- definedColors.put("orange",
- new RGB(255, 165, 0));
- definedColors.put("orangered",
- new RGB(255, 69, 0));
- definedColors.put("orchid",
- new RGB(218, 112, 214));
- definedColors.put("palegoldenrod",
- new RGB(238, 232, 170));
- definedColors.put("palegreen",
- new RGB(152, 251, 152));
- definedColors.put("paleturquoise",
- new RGB(175, 238, 238));
- definedColors.put("palevioletred",
- new RGB(219, 112, 147));
- definedColors.put("papayawhip",
- new RGB(255, 239, 213));
- definedColors.put("peachpuff",
- new RGB(255, 218, 185));
- definedColors.put("peru",
- new RGB(205, 133, 63));
- definedColors.put("pink",
- new RGB(255, 192, 203));
- definedColors.put("plum",
- new RGB(221, 160, 221));
- definedColors.put("powderBlue",
- new RGB(176, 224, 230));
- definedColors.put("purple",
- new RGB(128, 0, 128));
- definedColors.put("red",
- new RGB(255, 0, 0));
- definedColors.put("rosybrown",
- new RGB(188, 143, 143));
- definedColors.put("royalblue",
- new RGB(65, 105, 225));
- definedColors.put("saddlebrown",
- new RGB(139, 69, 19));
- definedColors.put("salmon",
- new RGB(250, 128, 114));
- definedColors.put("sandybrown",
- new RGB(244, 164, 96));
- definedColors.put("seagreen",
- new RGB(46, 139, 87));
- definedColors.put("seashell",
- new RGB(255, 245, 238));
- definedColors.put("sienna",
- new RGB(160, 82, 45));
- definedColors.put("silver",
- new RGB(192, 192, 192));
- definedColors.put("skyblue",
- new RGB(135, 206, 235));
- definedColors.put("slateblue",
- new RGB(106, 90, 205));
- definedColors.put("slategray",
- new RGB(112, 128, 144));
- definedColors.put("snow",
- new RGB(255, 250, 250));
- definedColors.put("springgreen",
- new RGB(0, 255, 127));
- definedColors.put("steelblue",
- new RGB(70, 130, 180));
- definedColors.put("tan",
- new RGB(210, 180, 140));
- definedColors.put("teal",
- new RGB(0, 128, 128));
- definedColors.put("thistle",
- new RGB(216, 191, 216));
- definedColors.put("tomato",
- new RGB(255, 99, 71));
- definedColors.put("turquoise",
- new RGB(64, 224, 208));
- definedColors.put("violet",
- new RGB(238, 130, 238));
- definedColors.put("wheat",
- new RGB(245, 222, 179));
- definedColors.put("white",
- new RGB(255, 255, 255));
- definedColors.put("whitesmoke",
- new RGB(245, 245, 245));
- definedColors.put("yellow",
- new RGB(255, 255, 0));
- definedColors.put("yellowgreen",
- new RGB(154, 205, 50));
-
- definedColors.put("grey",
- new RGB(128, 128, 128));
- definedColors.put("darkslategrey",
- new RGB(47, 79, 79));
- definedColors.put("dimgrey",
- new RGB(105, 105, 105));
- definedColors.put("lightgray",
- new RGB(211, 211, 211));
- definedColors.put("lightslategrey",
- new RGB(119, 136, 153));
- definedColors.put("slategrey",
- new RGB(112, 128, 144));
- definedColors.put("transparent",
- new RGBA(0, 0, 0, (float) 0.0));
-
- //CSS2 System colors deprecated
- deprecatedColors.put("activeborder", "ActiveBorder");
- deprecatedColors.put("activecaption", "ActiveCaption");
- deprecatedColors.put("appworkspace", "AppWorkspace");
- deprecatedColors.put("background", "Background");
- deprecatedColors.put("buttonface", "ButtonFace");
- deprecatedColors.put("buttonhighlight", "ButtonHighlight");
- deprecatedColors.put("buttonshadow", "ButtonShadow");
- deprecatedColors.put("buttontext", "ButtonText");
- deprecatedColors.put("captiontext", "CaptionText");
- deprecatedColors.put("graytext", "GrayText");
- deprecatedColors.put("highlight", "Highlight");
- deprecatedColors.put("highlighttext", "HighlightText");
- deprecatedColors.put("inactiveborder", "InactiveBorder");
- deprecatedColors.put("inactivecaption", "InactiveCaption");
- deprecatedColors.put("inactivecaptiontext", "InactiveCaptionText");
- deprecatedColors.put("infobackground", "InfoBackground");
- deprecatedColors.put("infotext", "InfoText");
- deprecatedColors.put("menu", "Menu");
- deprecatedColors.put("menutext", "MenuText");
- deprecatedColors.put("scrollbar", "Scrollbar");
- deprecatedColors.put("threeddarkshadow", "ThreeDDarkShadow");
- deprecatedColors.put("threedface", "ThreeDFace");
- deprecatedColors.put("threedhighlight", "ThreeDHighlight");
- deprecatedColors.put("threedlightshadow", "ThreeDLightShadow");
- deprecatedColors.put("threedshadow", "ThreeDShadow");
- deprecatedColors.put("window", "Window");
- deprecatedColors.put("windowframe", "WindowFrame");
- deprecatedColors.put("windowtext", "WindowText");
-
- // CSS3 user preferences for hyperlink colors -> removed from spec
- /*
- 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");
-
- }
-
}
Index: CssColorCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS21.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssColorCSS21.java 5 Jan 2010 19:49:51 -0000 1.7
+++ CssColorCSS21.java 29 Sep 2011 09:09:00 -0000 1.8
@@ -4,70 +4,42 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import org.w3c.css.util.ApplContext;
-import org.w3c.css.util.InvalidParamException;
-
-import static org.w3c.css.values.CssColorConstants.SYSTEMCOLORS;
-import static org.w3c.css.values.CssColorConstants.COLORNAME_CSS21;
+import java.util.HashMap;
/**
- * CssColorCSS21<br />
- * Created: Aug 30, 2005 1:53:59 PM<br />
+ * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#color-units
*/
-public class CssColorCSS21 extends CssColorCSS2 {
-
- private static int[] tableColorHash;
- private static int[] tableSystemColorHash;
-
- static {
- // We create the two table containing hashvalues of each color
- tableColorHash = new int[COLORNAME_CSS21.length];
- for (int i = 0; i < COLORNAME_CSS21.length; i++) {
- tableColorHash[i] = COLORNAME_CSS21[i].toLowerCase().hashCode();
- }
-
- tableSystemColorHash = new int[SYSTEMCOLORS.length];
- for (int i = 0; i < tableSystemColorHash.length; i++) {
- tableSystemColorHash[i] = SYSTEMCOLORS[i].toLowerCase().hashCode();
- }
- }
+public class CssColorCSS21 {
+ protected static final HashMap<String, RGB> definedRGBColorsCSS21;
- public CssColorCSS21(ApplContext ac, String s)
- throws InvalidParamException {
- setIdentColor(s, ac);
+ public static RGB getRGB(String ident) {
+ return definedRGBColorsCSS21.get(ident);
}
- /**
- * Parse an ident color.
- */
- private void setIdentColor(String s, ApplContext ac)
- throws InvalidParamException {
- String lower_s = s.toLowerCase();
- int hash = lower_s.hashCode();
-
- int indexOfColor = searchColor(hash, tableColorHash);
-
- 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) {
- computeIdentColor(definedColors, SYSTEMCOLORS[indexOfColor]);
- } else {
- // the color does not exist in this profile, this is an error
- throw new InvalidParamException("value", s, "color", ac);
- }
- }
+ // those are the same as CSS2, let's use that
+ public static String getSystem(String ident) {
+ return CssColorCSS2.definedSystemColorsCSS2.get(ident);
}
- private int searchColor(int colorHash, int[] tableColorHash) {
- for (int i = 0; i < tableColorHash.length; i++) {
- if (tableColorHash[i] == colorHash) {
- return i;
- }
- }
- return -1;
+ static {
+ // http://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#color-units
+ definedRGBColorsCSS21 = new HashMap<String, RGB>();
+ definedRGBColorsCSS21.put("orange", new RGB(255, 165, 0));
+ definedRGBColorsCSS21.put("black", new RGB(0, 0, 0));
+ definedRGBColorsCSS21.put("silver", new RGB(192, 192, 192));
+ definedRGBColorsCSS21.put("gray", new RGB(128, 128, 128));
+ definedRGBColorsCSS21.put("white", new RGB(255, 255, 255));
+ definedRGBColorsCSS21.put("maroon", new RGB(128, 0, 0));
+ definedRGBColorsCSS21.put("red", new RGB(255, 0, 0));
+ definedRGBColorsCSS21.put("purple", new RGB(128, 0, 128));
+ definedRGBColorsCSS21.put("fuchsia", new RGB(255, 0, 255));
+ definedRGBColorsCSS21.put("green", new RGB(0, 128, 0));
+ definedRGBColorsCSS21.put("lime", new RGB(0, 255, 0));
+ definedRGBColorsCSS21.put("olive", new RGB(128, 128, 0));
+ definedRGBColorsCSS21.put("yellow", new RGB(255, 255, 0));
+ definedRGBColorsCSS21.put("navy", new RGB(0, 0, 128));
+ definedRGBColorsCSS21.put("blue", new RGB(0, 0, 255));
+ definedRGBColorsCSS21.put("teal", new RGB(0, 128, 128));
+ definedRGBColorsCSS21.put("aqua", new RGB(0, 255, 255));
}
-
}
Index: CssColorCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS1.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- CssColorCSS1.java 26 Sep 2011 14:32:16 -0000 1.16
+++ CssColorCSS1.java 29 Sep 2011 09:09:00 -0000 1.17
@@ -6,235 +6,38 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import org.w3c.css.util.ApplContext;
-import org.w3c.css.util.InvalidParamException;
-
import java.util.HashMap;
/**
- * <H3>
- * Color units
- * </H3>
- * <P>
- * A color is a either a keyword or a numerical RGB specification.
- * <P>
- * The suggested list of keyword color names is: aqua, black, blue, fuchsia,
- * gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white,
- * and yellow. These 16 colors are taken from the Windows VGA palette, and their
- * RGB values are not defined in this specification.
- * <PRE>
- * BODY {color: black; background: white }
- * H1 { color: maroon }
- * H2 { color: olive }
- * </PRE>
- * <P>
- * The RGB color model is being used in numerical color specifications. These
- * examples all specify the same color:
- * <PRE>
- * EM { color: #f00 } / * #rgb * /
- * EM { color: #ff0000 } / * #rrggbb * /
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(100%, 0%, 0%) } / * float range 0.0% - 100.0% * /
- * </PRE>
- * <P>
- * The format of an RGB value in hexadecimal notation is a '#' immediately followed
- * by either three or six hexadecimal characters. The three-digit RGB notation
- * (#rgb) is converted into six-digit form (#rrggbb) by replicating digits,
- * not by adding zeros. For example, #fb0 expands to #ffbb00. This makes sure
- * that white (#ffffff) can be specified with the short notation (#fff) and
- * removes any dependencies on the color depth of the display.
- * <P>
- * The format of an RGB value in the functional notation is 'rgb(' followed
- * by a comma-separated list of three numerical values (either three integer
- * values in the range of 0-255, or three percentage values in the range of
- * 0.0% to 100.0%) followed by ')'. Whitespace characters are allowed around
- * the numerical values.
- * <P>
- * Values outside the numerical ranges should be clipped. The three rules below
- * are therefore equivalent:
- * <PRE>
- * EM { color: rgb(255,0,0) } / * integer range 0 - 255 * /
- * EM { color: rgb(300,0,0) } / * clipped to 255 * /
- * EM { color: rgb(110%, 0%, 0%) } / * clipped to 100% * /
- * </PRE>
- * <P>
- * RGB colors are specified in the sRGB color space <A HREF="#ref9">[9]</A>.
- * UAs may vary in the fidelity with which they represent these colors, but
- * use of sRGB provides an unambiguous and objectively measurable definition
- * of what the color should be, which can be related to international standards
- * <A HREF="#ref10">[10]</A>.
- * <P>
- * UAs may limit their efforts in displaying colors to performing a gamma-correction
- * on them. sRGB specifies a display gamma of 2.2 under specified viewing
- * conditions. UAs adjust the colors given in CSS such that, in combination
- * with an output device's "natural" display gamma, an effective display gamma
- * of 2.2 is produced. <A HREF="#appendix-d">Appendix D</A> gives further details
- * of this. Note that only colors specified in CSS are affected; e.g., images
- * are expected to carry their own color information.
- *
- *
- * <H2>
- * <A NAME="appendix-d">Appendix D: Gamma correction</A>
- * </H2>
- * <P>
- * (This appendix is informative, not normative)
- * <P>
- * See the <A href="http://www.w3.org/pub/WWW/TR/PNG-GammaAppendix">Gamma
- * Tutorial</A> in the PNG specification <A href="#ref12">[12]</A> if you aren't
- * already familiar with gamma issues.
- * <P>
- * In the computation, UAs displaying on a CRT may assume an ideal CRT and ignore
- * any effects on apparent gamma caused by dithering. That means the minimal
- * handling they need to do on current platforms is:
- * <DL>
- * <DT>
- * PC using MS-Windows
- * <DD>
- * none
- * <DT>
- * Unix using X11
- * <DD>
- * none
- * <DT>
- * Mac using QuickDraw
- * <DD>
- * apply gamma 1.39 <A HREF="#ref13">[13]</A> (ColorSync-savvy applications
- * may simply pass the sRGB ICC profile <A HREF="#ref14">[14]</A> to ColorSync
- * to perform correct color correction)
- * <DT>
- * SGI using X
- * <DD>
- * apply the gamma value from <TT>/etc/config/system.glGammaVal</TT> (the default
- * value being 1.70; applications running on Irix 6.2 or above may simply pass
- * the sRGB ICC profile to the color management system)
- * <DT>
- * NeXT using NeXTStep
- * <DD>
- * apply gamma 2.22
- * </DL>
- * <P>
- * "Applying gamma" means that each of the three R, G and B must be converted
- * to R'=R<SUP>gamma</SUP>, G'=G<SUP>gamma</SUP>, G'=B<SUP>gamma</SUP>, before
- * handing to the OS.
- * <P>
- * This may rapidly be done by building a 256-element lookup table once per
- * browser invocation thus:
- * <PRE>
- * for i := 0 to 255 do
- * raw := i / 255;
- * corr := pow (raw, gamma);
- * table[i] := trunc (0.5 + corr * 255.0)
- * end
- * </PRE>
- * <P>
- * which then avoids any need to do transcendental math per color attribute,
- * far less per pixel.
-
- * See also
- * <P>
- * <A NAME="ref9">[9]</A> M Anderson, R Motta, S Chandrasekar, M Stokes:
- * "<A HREF="http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm">Proposal
- * for a Standard Color Space for the Internet - sRGB</A>"
- * (http://www.hpl.hp.com/personal/Michael_Stokes/srgb.htm)
- * <P>
- * <A NAME="ref10">[10]</A> CIE Publication 15.2-1986,
- * "<A HREF="http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html">Colorimetry,
- * Second Edition</A>", ISBN 3-900-734-00-3
- * (http://www.hike.te.chiba-u.ac.jp/ikeda/CIE/publ/abst/15-2-86.html)
- * <P>
- * <A NAME="ref12">[12]</A>
- * "<A href="http://www.w3.org/pub/WWW/TR/REC-png-multi.html">PNG (Portable
- * Network Graphics) Specification, Version 1.0 specification</A>"
- * (http://www.w3.org/pub/WWW/TR/REC-png-multi.html)
- * <P>
- * <A NAME="ref13">[13]</A> Charles A. Poynton:
- * "<A HREF="ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf">Gamma
- * correction on the Macintosh Platform</A>"
- * (ftp://ftp.inforamp.net/pub/users/poynton/doc/Mac/Mac_gamma.pdf)
- * <P>
- * <A NAME="ref14">[14]</A> International Color Consortium:
- * "<A HREF="ftp://sgigate.sgi.com/pub/icc/ICC32.pdf">ICC Profile Format
- * Specification, version 3.2</A>", 1995 (ftp://sgigate.sgi.com/pub/icc/ICC32.pdf)
- *
* @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#color-units
*/
-public class CssColorCSS1 extends CssColor {
-
- private static HashMap<String,RGB> definedColorsCSS1;
-
- /**
- * Create a new CssColorCSS1
- */
- public CssColorCSS1() {
- //color = new CssIdent("");
- }
-
- /**
- * Create a new CssColor with a color name.
- *
- * @param s The name color.
- * @exception InvalidParamException the color is incorrect
- */
- public CssColorCSS1(ApplContext ac, String s) throws InvalidParamException {
- // setIdentColor(s.toLowerCase(), ac);
- setIdentColor(s, ac);
- }
+public class CssColorCSS1 {
- /**
- * Parse an ident color.
- */
- private void setIdentColor(String s, ApplContext ac)
- throws InvalidParamException {
- String lower_s = s.toLowerCase();
- rgb = definedColorsCSS1.get(lower_s);
- if (rgb != null) {
- color = lower_s;
-// 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;
- }
+ protected static final HashMap<String, RGB> definedRGBColorsCSS1;
- throw new InvalidParamException("value", s, "color", ac);
+ static RGB getRGB(String ident) {
+ return definedRGBColorsCSS1.get(ident);
}
static {
- definedColorsCSS1 = new HashMap<String,RGB>();
- definedColorsCSS1.put("black",
- new RGB(0, 0, 0));
- definedColorsCSS1.put("silver",
- new RGB(192, 192, 192));
- definedColorsCSS1.put("gray",
- new RGB(128, 128, 128));
- definedColorsCSS1.put("white",
- new RGB(255, 255, 255));
- definedColorsCSS1.put("maroon",
- new RGB(128, 0, 0));
- definedColorsCSS1.put("red",
- new RGB(255, 0, 0));
- definedColorsCSS1.put("purple",
- new RGB(128, 0, 128));
- definedColorsCSS1.put("fuchsia",
- new RGB(255, 0, 255));
- definedColorsCSS1.put("green",
- new RGB(0, 128, 0));
- definedColorsCSS1.put("lime",
- new RGB(0, 255, 0));
- definedColorsCSS1.put("olive",
- new RGB(128, 128, 0));
- definedColorsCSS1.put("yellow",
- new RGB(255, 255, 0));
- definedColorsCSS1.put("navy",
- new RGB(0, 0, 128));
- definedColorsCSS1.put("blue",
- new RGB(0, 0, 255));
- definedColorsCSS1.put("teal",
- new RGB(0, 128, 128));
- definedColorsCSS1.put("aqua",
- new RGB(0, 255, 255));
+ definedRGBColorsCSS1 = new HashMap<String, RGB>();
+ definedRGBColorsCSS1.put("black", new RGB(0, 0, 0));
+ definedRGBColorsCSS1.put("silver", new RGB(192, 192, 192));
+ definedRGBColorsCSS1.put("gray", new RGB(128, 128, 128));
+ definedRGBColorsCSS1.put("white", new RGB(255, 255, 255));
+ definedRGBColorsCSS1.put("maroon", new RGB(128, 0, 0));
+ definedRGBColorsCSS1.put("red", new RGB(255, 0, 0));
+ definedRGBColorsCSS1.put("purple", new RGB(128, 0, 128));
+ definedRGBColorsCSS1.put("fuchsia", new RGB(255, 0, 255));
+ definedRGBColorsCSS1.put("green", new RGB(0, 128, 0));
+ definedRGBColorsCSS1.put("lime", new RGB(0, 255, 0));
+ definedRGBColorsCSS1.put("olive", new RGB(128, 128, 0));
+ definedRGBColorsCSS1.put("yellow", new RGB(255, 255, 0));
+ definedRGBColorsCSS1.put("navy", new RGB(0, 0, 128));
+ definedRGBColorsCSS1.put("blue", new RGB(0, 0, 255));
+ definedRGBColorsCSS1.put("teal", new RGB(0, 128, 128));
+ definedRGBColorsCSS1.put("aqua", new RGB(0, 255, 255));
}
}
Index: HSLA.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSLA.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- HSLA.java 6 Jan 2010 09:27:44 -0000 1.7
+++ HSLA.java 29 Sep 2011 09:09:00 -0000 1.8
@@ -65,7 +65,7 @@
*/
public String toString() {
if (output == null) {
- StringBuilder sb = new StringBuilder("hsl(");
+ StringBuilder sb = new StringBuilder("hsla(");
sb.append(Util.displayFloat(fh)).append(", ");
sb.append(Util.displayFloat(fs)).append("%, ");
sb.append(Util.displayFloat(fl)).append("%, ");
Received on Thursday, 29 September 2011 09:09:09 UTC