- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 05 Jan 2010 13:50:03 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv25562/org/w3c/css/values
Modified Files:
ATSCColor.java CssAngle.java CssColor.java CssColorCSS1.java
CssColorCSS2.java CssColorCSS21.java CssColorConstants.java
CssDate.java CssExpression.java CssFrequency.java
CssFunction.java CssIdent.java CssLength.java CssNumber.java
CssOperator.java CssPercentage.java CssResolution.java
CssString.java CssTypes.java CssURL.java CssUnicodeRange.java
CssValue.java CssValueFloat.java HSL.java HSLA.java RGB.java
RGBA.java
Added Files:
CssValueList.java
Log Message:
Implementation of css3-background (partial, missing background-color and background, also borders not done)
cf. http://www.w3.org/TR/2009/CR-css3-background-20091217/
moved and corrected implementation of css3-multicol
cf. http://www.w3.org/TR/2009/CR-css3-multicol-20091217/
Some reorganization of code.
Index: CssResolution.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssResolution.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssResolution.java 25 Mar 2008 18:30:11 -0000 1.4
+++ CssResolution.java 5 Jan 2010 13:50:00 -0000 1.5
@@ -41,7 +41,7 @@
* Set the value of this Resolution.
*
* @param s the string representation of the Resolution.
- * @param frame For errors and warnings reports.
+ * @param ac For errors and warnings reports.
* @exception InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
@@ -79,7 +79,7 @@
}
/**
- * Returns the current value
+ * @return the current value
*/
public String getUnit() {
return unit;
@@ -89,7 +89,7 @@
* Returns a string representation of the object.
*/
public String toString() {
- if (value.floatValue() != 0) {
+ if (value.floatValue() != 0.0) {
return Util.displayFloat(value) + getUnit();
} else {
return Util.displayFloat(value);
@@ -104,7 +104,7 @@
public boolean equals(Object value) {
return (value instanceof CssResolution &&
this.value.equals(((CssResolution) value).value) &&
- unit == ((CssResolution) value).unit);
+ unit.equals(((CssResolution) value).unit));
}
private Float value;
Index: CssDate.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssDate.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssDate.java 25 Mar 2008 18:30:11 -0000 1.4
+++ CssDate.java 5 Jan 2010 13:50:00 -0000 1.5
@@ -38,7 +38,7 @@
* Set the value of this date.
*
* @param s the string representation of the time.
- * @param frame For errors and warnings reports.
+ * @param ac For errors and warnings reports.
* @exception InvalidParamException The date format is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
@@ -69,7 +69,8 @@
throw new InvalidParamException("value", s, ac);
}
- if (d.intValue() > 31 || d.intValue() < 0 || m.intValue() > 12 || m.intValue() < 0 || y.intValue() < 0) {
+ if (d.intValue() > 31 || d.intValue() < 0 || m.intValue() > 12 ||
+ m.intValue() < 0 || y.intValue() < 0) {
throw new InvalidParamException("value", s, ac);
}
}
Index: CssFrequency.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssFrequency.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssFrequency.java 25 Mar 2008 18:30:11 -0000 1.6
+++ CssFrequency.java 5 Jan 2010 13:50:00 -0000 1.7
@@ -54,7 +54,7 @@
* Set the value of this frequency.
*
* @param s the string representation of the frequency.
- * @param frame For errors and warnings reports.
+ * @param ac For errors and warnings reports.
* @exception InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
@@ -64,10 +64,10 @@
float v;
if (s.charAt(length-3) == 'k') {
unit = s.substring(length-3, length);
- v = new Float(s.substring(0, length-3)).floatValue();
+ v = Float.parseFloat(s.substring(0, length - 3));
} else {
unit = s.substring(length-2, length);
- v = new Float(s.substring(0, length-2)).floatValue();
+ v = Float.parseFloat(s.substring(0, length - 2));
}
int hash = unit.hashCode();
Index: CssLength.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssLength.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssLength.java 25 Mar 2008 18:30:11 -0000 1.6
+++ CssLength.java 5 Jan 2010 13:50:00 -0000 1.7
@@ -12,156 +12,155 @@
import org.w3c.css.util.Util;
/**
- * <H3>
- * Length units
- * </H3>
- * <P>
- * The format of a length value is an optional sign character ('+' or '-', with
- * '+' being the default) immediately followed by a number (with or without
- * a decimal point) immediately followed by a unit identifier (a two-letter
- * abbreviation). After a '0' number, the unit identifier is optional.
- * <P>
- * Some properties allow negative length units, but this may complicate the
- * formatting model and there may be implementation-specific limits. If a negative
- * length value cannot be supported, it should be clipped to the nearest value
- * that can be supported.
- * <P>
- * There are two types of length units: relative and absolute. Relative units
- * specify a length relative to another length property. Style sheets that use
- * relative units will more easily scale from one medium to another (e.g. from
- * a computer display to a laser printer). Percentage
- * units (described below) and keyword values (e.g. 'x-large') offer similar
- * advantages.
- * <P>
- * These relative units are supported:
- * <PRE>
- * H1 { margin: 0.5em } /* ems, the height of the element's font * /
- * H1 { margin: 1ex } /* x-height, ~ the height of the letter 'x' * /
- * P { font-size: 12px } /* pixels, relative to canvas * /
- * P { layout-grid: strict both 20 pt 15 pt; margin 1gd 3gd 1gd 2gd } /* grid units * /
- * </PRE>
- * <P>
- * The relative units 'em' and 'ex' are relative to the font size of the element
- * itself. The only exception to this rule in CSS1 is the 'font-size' property
- * where 'em' and 'ex' values refer to the font size of the parent element.
- * <P>
- * The existence of a grid in an element makes it possible and very useful to express various
- * measurements in that element in terms of grid units. Grid units are used very frequently
- * in East Asian typography, especially for the left, right, top and bottom element margins.
- * Therefore a new length unit is necessary: gd to enable the author to specify the various
- * measurements in terms of the grid.
- * <P>
- * Pixel units, as used in the last rule, are relative to the resolution of
- * the canvas, i.e. most often a computer display. If the pixel density of the
- * output device is very different from that of a typical computer display,
- * the UA should rescale pixel values. The suggested <EM>reference pixel</EM>
- * is the visual angle of one pixel on a device with a pixel density of 90dpi
- * and a distance from the reader of an arm's length. For a nominal arm's length
- * of 28 inches, the visual angle is about 0.0227 degrees.
- * <P>
- * Child elements inherit the computed value, not the relative value:
- * <PRE>
- * BODY {
- * font-size: 12pt;
- * text-indent: 3em; /* i.e. 36pt * /
- * }
- * H1 { font-size: 15pt }
+ * <H3>
+ * Length units
+ * </H3>
+ * <p/>
+ * The format of a length value is an optional sign character ('+' or '-', with
+ * '+' being the default) immediately followed by a number (with or without
+ * a decimal point) immediately followed by a unit identifier (a two-letter
+ * abbreviation). After a '0' number, the unit identifier is optional.
+ * <p/>
+ * Some properties allow negative length units, but this may complicate the
+ * formatting model and there may be implementation-specific limits. If a negative
+ * length value cannot be supported, it should be clipped to the nearest value
+ * that can be supported.
+ * <p/>
+ * There are two types of length units: relative and absolute. Relative units
+ * specify a length relative to another length property. Style sheets that use
+ * relative units will more easily scale from one medium to another (e.g. from
+ * a computer display to a laser printer). Percentage
+ * units (described below) and keyword values (e.g. 'x-large') offer similar
+ * advantages.
+ * <p/>
+ * These relative units are supported:
+ * <PRE>
+ * H1 { margin: 0.5em } /* ems, the height of the element's font * /
+ * H1 { margin: 1ex } /* x-height, ~ the height of the letter 'x' * /
+ * P { font-size: 12px } /* pixels, relative to canvas * /
+ * P { layout-grid: strict both 20 pt 15 pt; margin 1gd 3gd 1gd 2gd } /* grid units * /
* </PRE>
- * <P>
- * In the example above, the 'text-indent' value of 'H1' elements will be 36pt,
- * not 45pt.
- * <P>
- * Absolute length units are only useful when the physical properties of the
- * output medium are known. These absolute units are supported:
- * <PRE>
- * H1 { margin: 0.5in } /* inches, 1in = 2.54cm * /
- * H2 { line-height: 3cm } /* centimeters * /
- * H3 { word-spacing: 4mm } /* millimeters * /
- * H4 { font-size: 12pt } /* points, 1pt = 1/72 in * /
- * H4 { font-size: 1pc } /* picas, 1pc = 12pt * /
+ * <p/>
+ * The relative units 'em' and 'ex' are relative to the font size of the element
+ * itself. The only exception to this rule in CSS1 is the 'font-size' property
+ * where 'em' and 'ex' values refer to the font size of the parent element.
+ * <p/>
+ * The existence of a grid in an element makes it possible and very useful to express various
+ * measurements in that element in terms of grid units. Grid units are used very frequently
+ * in East Asian typography, especially for the left, right, top and bottom element margins.
+ * Therefore a new length unit is necessary: gd to enable the author to specify the various
+ * measurements in terms of the grid.
+ * <p/>
+ * Pixel units, as used in the last rule, are relative to the resolution of
+ * the canvas, i.e. most often a computer display. If the pixel density of the
+ * output device is very different from that of a typical computer display,
+ * the UA should rescale pixel values. The suggested <EM>reference pixel</EM>
+ * is the visual angle of one pixel on a device with a pixel density of 90dpi
+ * and a distance from the reader of an arm's length. For a nominal arm's length
+ * of 28 inches, the visual angle is about 0.0227 degrees.
+ * <p/>
+ * Child elements inherit the computed value, not the relative value:
+ * <PRE>
+ * BODY {
+ * font-size: 12pt;
+ * text-indent: 3em; /* i.e. 36pt * /
+ * }
+ * H1 { font-size: 15pt }
* </PRE>
- * <P>
- * In cases where the specified length cannot be supported, UAs should try to
- * approximate. For all CSS1 properties, further computations and inheritance
- * should be based on the approximated value.
+ * <p/>
+ * In the example above, the 'text-indent' value of 'H1' elements will be 36pt,
+ * not 45pt.
+ * <p/>
+ * Absolute length units are only useful when the physical properties of the
+ * output medium are known. These absolute units are supported:
+ * <PRE>
+ * H1 { margin: 0.5in } /* inches, 1in = 2.54cm * /
+ * H2 { line-height: 3cm } /* centimeters * /
+ * H3 { word-spacing: 4mm } /* millimeters * /
+ * H4 { font-size: 12pt } /* points, 1pt = 1/72 in * /
+ * H4 { font-size: 1pc } /* picas, 1pc = 12pt * /
+ * </PRE>
+ * <p/>
+ * In cases where the specified length cannot be supported, UAs should try to
+ * approximate. For all CSS1 properties, further computations and inheritance
+ * should be based on the approximated value.
*
- * @see CssPercentage
* @version $Revision$
+ * @see CssPercentage
*/
public class CssLength extends CssValue {
public static final int type = CssTypes.CSS_LENGTH;
-
+
public final int getType() {
- return type;
+ return type;
}
-
+
/**
* Create a new CssLength
*/
public CssLength() {
- value = defaultValue;
+ value = defaultValue;
}
/**
* Set the value of this length.
*
- * @param s the string representation of the length.
- * @param frame For errors and warnings reports.
- * @exception InvalidParamException The unit is incorrect
+ * @param s the string representation of the length.
+ * @throws InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
- s = s.toLowerCase();
- int length = s.length();
- String unit = s.substring(length-2, length);
- this.value = new Float(s.substring(0, length-2));
+ s = s.toLowerCase();
+ int length = s.length();
+ String unit = s.substring(length - 2, length);
+ this.value = new Float(s.substring(0, length - 2));
- this.unit = 2; // there is no unit by default
+ this.unit = 2; // there is no unit by default
- if (unit.equals("gd") && (cssversion.equals("css2"))) {
- throw new InvalidParamException("unit", unit, ac);
- }
+ if (unit.equals("gd") && (cssversion.equals("css2"))) {
+ throw new InvalidParamException("unit", unit, ac);
+ }
- if (value.floatValue() != 0) {
- int hash = unit.hashCode();
- int i = 0;
- while (i<units.length) {
- if (hash == hash_units[i]) {
- this.unit = i;
- return;
- }
- i++;
- }
- } else {
- return;
- }
+ if (value.floatValue() != 0) {
+ int hash = unit.hashCode();
+ int i = 0;
+ while (i < units.length) {
+ if (hash == hash_units[i]) {
+ this.unit = i;
+ return;
+ }
+ i++;
+ }
+ } else {
+ return;
+ }
- throw new InvalidParamException("unit", unit, ac);
+ throw new InvalidParamException("unit", unit, ac);
}
/**
* Returns the current value
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns the current value
*/
public String getUnit() {
- return units[unit];
+ return units[unit];
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if (value.floatValue() != 0) {
- return Util.displayFloat(value) + getUnit();
- } else {
- return Util.displayFloat(value);
- }
+ if (value.floatValue() != 0) {
+ return Util.displayFloat(value) + getUnit();
+ } else {
+ return Util.displayFloat(value);
+ }
}
/**
@@ -170,22 +169,22 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return (value instanceof CssLength &&
- this.value.equals(((CssLength) value).value) &&
- unit == ((CssLength) value).unit);
+ return (value instanceof CssLength &&
+ this.value.equals(((CssLength) value).value) &&
+ unit == ((CssLength) value).unit);
}
private Float value;
private int unit;
- private static String[] units = { "mm", "cm", "pt", "pc", "em",
- "ex", "px", "in", "gd" };
+ private static String[] units = {"mm", "cm", "pt", "pc", "em",
+ "ex", "px", "in", "gd"};
private static int[] hash_units;
private static Float defaultValue = new Float(0);
static {
- hash_units = new int[units.length];
- for (int i=0; i<units.length; i++)
- hash_units[i] = units[i].hashCode();
+ hash_units = new int[units.length];
+ for (int i = 0; i < units.length; i++)
+ hash_units[i] = units[i].hashCode();
}
}
Index: CssColorCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS2.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- CssColorCSS2.java 9 Mar 2009 17:17:48 -0000 1.13
+++ CssColorCSS2.java 5 Jan 2010 13:50:00 -0000 1.14
@@ -6,226 +6,231 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import java.util.HashMap;
-
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.Util;
+
+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 }
+ * <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% * /
+ * <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% * /
+ * <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
+ * <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/>
+ * which then avoids any need to do transcendental math per color attribute,
+ * far less per pixel.
+ * <p/>
* See also
- * <P>
+ * <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>
+ * <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>
+ * <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>
+ * <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)
+ * Specification, version 3.2</A>", 1995 (ftp://sgigate.sgi.com/pub/icc/ICC32.pdf)
*
* @version $Revision$
*/
public class CssColorCSS2 extends CssColor {
- static HashMap<String,Object> definedColorsCSS2;
+ static HashMap<String, Object> definedColorsCSS2;
/**
* Create a new CssColorCSS2.
*/
public CssColorCSS2() {
- //color = new CssIdent("");
+ //color = new CssIdent("");
}
/**
* Create a new CssColorCSS2 with a color name.
*
- * @param s The name color.
- * @exception InvalidParamException the color is incorrect
+ * @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);
+ // setIdentColor(s.toLowerCase(), ac);
+ setIdentColor(s, ac);
}
/**
* 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);
- }
+ throws InvalidParamException {
+ String lower_s = s.toLowerCase();
+ if (!computeIdentColor(definedColorsCSS2, lower_s)) {
+ throw new InvalidParamException("value", s, "color", ac);
+ }
}
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 = 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");
Index: CssExpression.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssExpression.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- CssExpression.java 17 Dec 2009 16:09:58 -0000 1.8
+++ CssExpression.java 5 Jan 2010 13:50:00 -0000 1.9
@@ -6,7 +6,7 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import java.util.Vector;
+import java.util.ArrayList;
/**
* This class is used by the CSS1 parser to generate all expressions.
@@ -15,7 +15,7 @@
*/
public class CssExpression implements CssOperator {
- private Vector<ValueOperator> items = new Vector<ValueOperator>();
+ private ArrayList<ValueOperator> items = new ArrayList<ValueOperator>();
private int count = 0;
private int index = 0;
@@ -26,8 +26,8 @@
* @param value The value to append
*/
public void addValue(CssValue value) {
- items.addElement(new ValueOperator(value));
- count++;
+ items.add(new ValueOperator(value));
+ count++;
}
/**
@@ -38,7 +38,7 @@
* @see CssOperator
*/
public void setOperator(char operator) {
- (items.elementAt(count-1)).operator = operator;
+ (items.get(count - 1)).operator = operator;
}
/**
@@ -49,7 +49,7 @@
* @see CssOperator
*/
public void setCurrentOperator(char operator) {
- (items.elementAt(index)).operator = operator;
+ (items.get(index)).operator = operator;
}
/**
@@ -57,11 +57,11 @@
* don't change the position in the expression
*/
public CssValue getValue() {
- if (index == count) {
- return null;
- } else {
- return (items.elementAt(index)).value;
- }
+ if (index == count) {
+ return null;
+ } else {
+ return (items.get(index)).value;
+ }
}
/**
@@ -69,38 +69,39 @@
* don't change the position in the expression
*/
public CssValue getNextValue() {
- if (index+1 >= count) {
- return null;
- } else {
- return (items.elementAt(index+1)).value;
- }
+ if (index + 1 >= count) {
+ return null;
+ } else {
+ return (items.get(index + 1)).value;
+ }
}
/* Modified by Sijtsche de Jong */
+
/**
* Returns the operator <strong>after</strong> the current value
* don't change the position in the expression
*/
public char getOperator() {
- if (index == count) {
- return SPACE;
- } else {
- return (items.elementAt(index)).operator;
- }
+ if (index == count) {
+ return SPACE;
+ } else {
+ return (items.get(index)).operator;
+ }
}
/**
* Returns the number of elements
*/
public int getCount() {
- return count;
+ return count;
}
/**
* Returns the number of remaining elements
*/
public int getRemainingCount() {
- return count-index;
+ return count - index;
}
/**
@@ -109,95 +110,94 @@
* @param value The value to insert
*/
public void insert(CssValue value) {
- items.insertElementAt(new ValueOperator(value), index);
- count++;
+ items.add(index, new ValueOperator(value));
+ count++;
}
/**
* Removes the current value and his operator
*/
public void remove() {
- if (index != count) {
- items.removeElementAt(index);
- }
- count--;
+ if (index != count) {
+ items.remove(index);
+ }
+ count--;
}
/**
- * Returns true if there is no other element
+ * @return true if there is no other element
*/
public boolean end() {
- return index == count;
+ return (index == count);
}
/**
* Change the position to the beginning
*/
public void starts() {
- index = 0;
+ index = 0;
}
/**
* Change the position to the end
*/
public void ends() {
- index = count;
+ index = count;
}
/**
* Change the position to the next
*/
public void next() {
- if (index < count) {
- index++;
- }
+ if (index < count) {
+ index++;
+ }
}
/**
* Change the position to the precedent
*/
public void precedent() {
- if (index > 0)
- index--;
+ if (index > 0)
+ index--;
}
/**
* Returns a string representation of the object from the current position.
*/
public String toString() {
- StringBuilder sb = new StringBuilder();
- for (int i = index; i < count; i++) {
- ValueOperator vo = items.elementAt(i);
- sb.append(vo.value.toString()).append(vo.operator);
- }
- // remove the last one
- if (sb.length() > 0) {
- return sb.deleteCharAt(sb.length()-1).toString();
- } else {
- return "**invalid state**";
- }
+ StringBuilder sb = new StringBuilder();
+ for (int i = index; i < count; i++) {
+ ValueOperator vo = items.get(i);
+ sb.append(vo.value.toString()).append(vo.operator);
+ }
+ // remove the last one
+ if (sb.length() > 0) {
+ return sb.deleteCharAt(sb.length() - 1).toString();
+ } else {
+ return "**invalid state**";
+ }
}
/**
- * Returns a string representation of the object before the current
+ * Returns a string representation of the object before the current
* position.
*/
public String toStringFromStart() {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < index; i++) {
- ValueOperator vo = items.elementAt(i);
- sb.append(vo.value.toString()).append(vo.operator);
- }
-
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+ for ( ValueOperator anItem : items) {
+ sb.append(anItem.value.toString()).append(anItem.operator);
+ }
+ return sb.toString();
}
- class ValueOperator {
- ValueOperator(CssValue value) {
- this.value = value;
- this.operator = SPACE;
- }
- CssValue value;
- char operator;
+ private class ValueOperator {
+ CssValue value;
+ char operator;
+
+ ValueOperator(CssValue value) {
+ this.value = value;
+ this.operator = SPACE;
+ }
}
}
Index: CssString.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssString.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssString.java 25 Mar 2008 18:30:11 -0000 1.6
+++ CssString.java 5 Jan 2010 13:50:01 -0000 1.7
@@ -18,11 +18,11 @@
public class CssString extends CssValue {
public static final int type = CssTypes.CSS_STRING;
-
+
String value;
public final int getType() {
- return type;
+ return type;
}
/**
@@ -33,17 +33,19 @@
/**
* Create a new CssString
+ *
+ * @param s the <EM>String</EM>
*/
public CssString(String s) {
- value = s;
+ value = s;
}
/**
* Set the value of this string.
*
- * @param s the string representation of the string.
- * @param frame For errors and warnings reports.
- * @exception InvalidParamException The unit is incorrect
+ * @param s the string representation of the string.
+ * @param ac For errors and warnings reports.
+ * @throws InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
// if (s.indexOf('\'') == -1 &&
@@ -51,28 +53,28 @@
// throw new InvalidParamException("string", s, ac);
// }
// tokenizer is taking care of the validity of the value
- value = s;
+ value = s;
}
/**
* Returns the string
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return value;
+ return value;
}
/**
* Get the hash code of the internal string.
*/
public int hashCode() {
- return value.hashCode();
+ return value.hashCode();
}
/**
@@ -81,8 +83,8 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return (value instanceof CssString &&
- this.value.equals(((CssString) value).value));
+ return (value instanceof CssString &&
+ this.value.equals(((CssString) value).value));
}
}
--- NEW FILE: CssValueList.java ---
// $Id: CssValueList.java,v 1.1 2010/01/05 13:50:01 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2010.
// 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.ArrayList;
/**
* A space separated value list.
*
*/
public class CssValueList extends CssValue {
public static final int type = CssTypes.CSS_VALUE_LIST;
public ArrayList<CssValue> value;
public final int getType() {
return type;
}
/**
* Create a new CssValueList
*/
public CssValueList() {
value = new ArrayList<CssValue>();
}
/**
* Create a new CssValueList
*
* @param val the <EM>ArrayList</EM> of CssValue
*/
public CssValueList(ArrayList<CssValue> val) {
value = val;
}
/**
* Set the value of this string.
*
* @param s the ArrayList of CSS values
* @param ac For errors and warnings reports.
* @throws org.w3c.css.util.InvalidParamException
* The unit is incorrect
*/
public void set(String s, ApplContext ac)
throws InvalidParamException {
throw new InvalidParamException("invalid-class", s, ac);
}
public void add(CssValue val) {
value.add(val);
}
/**
* Returns the value
*/
public Object get() {
return value;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
StringBuilder sb = new StringBuilder();
for (CssValue aCssValue: value) {
sb.append(aCssValue.toString()).append(" ");
}
sb.setLength(sb.length()-1);
return sb.toString();
}
/**
* Get the hash code of the internal string.
*/
public int hashCode() {
return value.hashCode();
}
/**
* Compares two values for equality.
*
* @param value The other value.
*/
public boolean equals(Object value) {
return (value instanceof CssValueList &&
this.value.equals(((CssValueList) value).value));
}
}
Index: CssNumber.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssNumber.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssNumber.java 25 Mar 2008 18:30:11 -0000 1.7
+++ CssNumber.java 5 Jan 2010 13:50:00 -0000 1.8
@@ -17,9 +17,9 @@
public class CssNumber extends CssValue implements CssValueFloat {
public static final int type = CssTypes.CSS_NUMBER;
-
+
public final int getType() {
- return type;
+ return type;
}
ApplContext ac;
@@ -36,150 +36,149 @@
* Create a new CssNumber
*/
public CssNumber(ApplContext ac, float value) {
- this.ac = ac;
- this.value = new Float(value);
+ this.ac = ac;
+ this.value = new Float(value);
}
public CssNumber(float value) {
- this.value = new Float(value);
+ this.value = new Float(value);
}
/**
* Set the value of this frequency.
*
- * @param s the string representation of the frequency.
- * @param frame For errors and warnings reports.
+ * @param s the string representation of the frequency.
+ * @param ac For errors and warnings reports.
*/
public void set(String s, ApplContext ac) {
- try {
- new Integer(s);
- isInt = true;
- }
- catch(NumberFormatException e) {
- isInt = false;
- }
- finally {
- value = new Float(s);
- }
- this.ac = ac;
+ try {
+ new Integer(s);
+ isInt = true;
+ }
+ catch (NumberFormatException e) {
+ isInt = false;
+ }
+ finally {
+ value = new Float(s);
+ }
+ this.ac = ac;
}
/**
* Returns the value
*/
public Object get() {
- if(isInt) {
- return new Integer(value.intValue());
- }
- return value;
+ if (isInt) {
+ return new Integer(value.intValue());
+ }
+ return value;
}
/**
* Return the float value
*/
public float getValue() {
- return value.floatValue();
+ return value.floatValue();
}
public int getInt() throws InvalidParamException {
- if(isInt) {
- return value.intValue();
- }
- else {
- throw new InvalidParamException("invalid-color", ac);
- }
+ if (isInt) {
+ return value.intValue();
+ } else {
+ throw new InvalidParamException("invalid-color", ac);
+ }
}
public boolean isInteger() {
- return isInt;
+ return isInt;
}
/**
* Returns a length.
* Only zero can be a length.
*
- * @exception InvalidParamException The value is not zero
+ * @throws InvalidParamException The value is not zero
*/
public CssLength getLength() throws InvalidParamException {
- float num = value.floatValue();
- if (num == 0) {
- return new CssLength();
- } else {
- throw new InvalidParamException("zero", "length", ac);
- }
+ float num = value.floatValue();
+ if (num == 0) {
+ return new CssLength();
+ } else {
+ throw new InvalidParamException("zero", "length", ac);
+ }
}
/**
* Returns a percentage.
* Only zero can be a length.
*
- * @exception InvalidParamException The value is not zero
+ * @throws InvalidParamException The value is not zero
*/
public CssPercentage getPercentage() throws InvalidParamException {
- float num = value.floatValue();
- if (num == 0)
- return new CssPercentage();
- else {
- throw new InvalidParamException("zero",
- value.toString(),
- "percentage", ac);
- }
+ float num = value.floatValue();
+ if (num == 0)
+ return new CssPercentage();
+ else {
+ throw new InvalidParamException("zero",
+ value.toString(),
+ "percentage", ac);
+ }
}
/**
* Returns a time.
* Only zero can be a length.
*
- * @exception InvalidParamException The value is not zero
+ * @throws InvalidParamException The value is not zero
*/
public CssTime getTime() throws InvalidParamException {
- float num = value.floatValue();
- if (num == 0)
- return new CssTime();
- else
- throw new InvalidParamException("zero", value.toString(),
- "time", ac);
+ float num = value.floatValue();
+ if (num == 0)
+ return new CssTime();
+ else
+ throw new InvalidParamException("zero", value.toString(),
+ "time", ac);
}
/**
* Returns a angle.
* Only zero can be a length.
*
- * @exception InvalidParamException The value is not zero
+ * @throws InvalidParamException The value is not zero
*/
public CssAngle getAngle() throws InvalidParamException {
- float num = value.floatValue();
- if (num == 0)
- return new CssAngle();
- else
- throw new InvalidParamException("zero", value.toString(),
- "angle", ac);
+ float num = value.floatValue();
+ if (num == 0)
+ return new CssAngle();
+ else
+ throw new InvalidParamException("zero", value.toString(),
+ "angle", ac);
}
/**
* Returns a frequency.
* Only zero can be a length.
*
- * @exception InvalidParamException The value is not zero
+ * @throws InvalidParamException The value is not zero
*/
public CssFrequency getFrequency() throws InvalidParamException {
- float num = value.floatValue();
- if (num == 0) {
- return new CssFrequency();
- } else {
- throw new InvalidParamException("zero",
- value.toString(), "frequency", ac);
- }
+ float num = value.floatValue();
+ if (num == 0) {
+ return new CssFrequency();
+ } else {
+ throw new InvalidParamException("zero",
+ value.toString(), "frequency", ac);
+ }
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if(isInt) {
- return value.intValue() + "";
- }
- return value.toString();
+ if (isInt) {
+ return value.intValue() + "";
+ }
+ return value.toString();
}
/**
@@ -188,8 +187,8 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return (value instanceof CssNumber &&
- this.value.equals(((CssNumber) value).value));
+ return (value instanceof CssNumber &&
+ this.value.equals(((CssNumber) value).value));
}
}
Index: CssTypes.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssTypes.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssTypes.java 6 Mar 2009 11:02:46 -0000 1.2
+++ CssTypes.java 5 Jan 2010 13:50:01 -0000 1.3
@@ -25,4 +25,7 @@
public static final int CSS_FUNCTION = 12;
public static final int CSS_UNICODE_RANGE = 13;
+ // not generated by the parser
+ public static final int CSS_VALUE_LIST = 20;
+
}
Index: CssUnicodeRange.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssUnicodeRange.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssUnicodeRange.java 25 Mar 2008 18:30:12 -0000 1.5
+++ CssUnicodeRange.java 5 Jan 2010 13:50:01 -0000 1.6
@@ -39,7 +39,7 @@
* Set the value of this frequency.
*
* @param s the string representation of the frequency.
- * @param frame For errors and warnings reports.
+ * @param ac For errors and warnings reports.
*/
public void set(String s, ApplContext ac) {
value = s;
@@ -65,8 +65,7 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return ((value instanceof CssUnicodeRange)
- && (value != null)
+ return ((value != null) && (value instanceof CssUnicodeRange)
&& this.value.equals(((CssUnicodeRange) value).value));
}
Index: CssAngle.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssAngle.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssAngle.java 25 Mar 2008 18:30:11 -0000 1.7
+++ CssAngle.java 5 Jan 2010 13:50:00 -0000 1.8
@@ -12,32 +12,33 @@
/**
* <H3>Angle</H3>
-
+ * <p/>
* <P>Angle units are used with aural cascading style sheets.
- *
+ * <p/>
* <P>These are the legal angle units:
- *
+ * <p/>
* <UL>
* <LI>deg: degrees
* <LI>grad: gradians
* <LI>rad: radians
* </UL>
- *
+ * <p/>
* <p>Values in these units may be negative. They should be normalized to the
* range 0-360deg by the UA. For example, -10deg and 350deg are equivalent.
*
- * @version $Revision$ */
+ * @version $Revision$
+ */
public class CssAngle extends CssValue implements CssValueFloat {
public static final int type = CssTypes.CSS_ANGLE;
-
+
public final int getType() {
- return type;
+ return type;
}
Float value;
int unit;
- static String[] units = { "deg", "grad", "rad" };
+ static String[] units = {"deg", "grad", "rad"};
static int[] hash_units;
static Float defaultValue = new Float(0);
@@ -45,87 +46,87 @@
* Create a new CssAngle.
*/
public CssAngle() {
- this(defaultValue);
+ this(defaultValue);
}
/**
* Create a new CssAngle
*/
public CssAngle(float v) {
- this(new Float(v));
+ this(new Float(v));
}
/**
* Create a new CssAngle
*/
public CssAngle(Float angle) {
- value = angle;
+ value = angle;
}
/**
* Set the value of this angle.
*
- * @param s The string representation of the angle
- * @param frame For errors and warnings reports
- * @exception InvalidParamException The unit is incorrect
+ * @param s The string representation of the angle
+ * @param ac For errors and warnings reports
+ * @throws InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
- s = s.toLowerCase();
- int length = s.length();
- String unit;
- //float v;
- if (s.indexOf("grad") == -1) {
- unit = s.substring(length-3, length);
- value = new Float(s.substring(0, length-3));
- } else {
- unit = "grad";
- value = new Float(s.substring(0, length-4));
- }
- int hash = unit.hashCode();
+ s = s.toLowerCase();
+ int length = s.length();
+ String unit;
+ //float v;
+ if (s.indexOf("grad") == -1) {
+ unit = s.substring(length - 3, length);
+ value = new Float(s.substring(0, length - 3));
+ } else {
+ unit = "grad";
+ value = new Float(s.substring(0, length - 4));
+ }
+ int hash = unit.hashCode();
- int i = 0;
- while (i<units.length) {
- if (hash == hash_units[i]) {
- this.unit = i;
- break;
- }
- i++;
- }
+ int i = 0;
+ while (i < units.length) {
+ if (hash == hash_units[i]) {
+ this.unit = i;
+ break;
+ }
+ i++;
+ }
- if (i > 2) {
- throw new InvalidParamException("unit", unit, ac);
- }
+ if (i > 2) {
+ throw new InvalidParamException("unit", unit, ac);
+ }
- this.unit = i; // there is no unit by default
+ this.unit = i; // there is no unit by default
- /* clipping with degree */
- /*
- while (v < 0) {
- v += 360;
- }
- while (v > 360) {
- v -= 360;
- }
- */
+ /* clipping with degree */
+ /*
+ while (v < 0) {
+ v += 360;
+ }
+ while (v > 360) {
+ v -= 360;
+ }
+ */
}
/**
* Returns the current value
*/
public Object get() {
- return value;
+ return value;
}
public float getValue() {
- return value.floatValue();
+ return value.floatValue();
}
/**
* Returns the current value
*/
public String getUnit() {
- return units[unit];
+ return units[unit];
}
/**
@@ -133,11 +134,11 @@
*/
public String toString() {
- if (value.floatValue() != 0) {
- return Util.displayFloat(value) + getUnit();
- } else {
- return Util.displayFloat(value);
- }
+ if (value.floatValue() != 0) {
+ return Util.displayFloat(value) + getUnit();
+ } else {
+ return Util.displayFloat(value);
+ }
}
/**
@@ -146,39 +147,39 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return (value instanceof CssAngle &&
- this.value.equals(((CssAngle) value).value) &&
- unit == ((CssAngle) value).unit);
+ return (value instanceof CssAngle &&
+ this.value.equals(((CssAngle) value).value) &&
+ unit == ((CssAngle) value).unit);
}
private float normalize(float degree) {
- while (degree < 0) {
- degree += 360;
- }
- while (degree > 360) {
- degree -= 360;
- }
- return 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 angle = value.floatValue();
- switch (unit) {
- 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;
- }
+ float angle = value.floatValue();
+ switch (unit) {
+ 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
@@ -216,22 +217,24 @@
}
}
*/
+
public boolean isDegree() {
- return unit == 0;
+ return unit == 0;
}
public boolean isGradian() {
- return unit == 1;
+ return unit == 1;
}
public boolean isRadian() {
- return unit == 2;
+ return unit == 2;
}
static {
- hash_units = new int[units.length];
- for (int i=0; i<units.length; i++)
- hash_units[i] = units[i].hashCode();
+ hash_units = new int[units.length];
+ for (int i = 0; i < units.length; i++) {
+ hash_units[i] = units[i].hashCode();
+ }
}
}
Index: CssColorCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColorCSS1.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- CssColorCSS1.java 6 Mar 2009 14:26:59 -0000 1.13
+++ CssColorCSS1.java 5 Jan 2010 13:50:00 -0000 1.14
@@ -6,11 +6,10 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import java.util.HashMap;
-
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.Util;
+
+import java.util.HashMap;
/**
* <H3>
Index: CssURL.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssURL.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssURL.java 25 Mar 2008 18:30:11 -0000 1.6
+++ CssURL.java 5 Jan 2010 13:50:01 -0000 1.7
@@ -6,44 +6,45 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import java.net.MalformedURLException;
-import java.net.URL;
-
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.HTTPURL;
import org.w3c.css.util.InvalidParamException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
/**
- * <H3>
- * URL
- * </H3>
- * <P>
- * A Uniform Resource Locator (URL) is identified with a functional notation:
- * <PRE>
- * BODY { background: url(http://www.bg.com/pinkish.gif) }
- * </PRE>
- * <P>
- * The format of a URL value is 'url(' followed by optional white space followed
- * by an optional single quote (') or double quote (") character followed by
- * the URL itself (as defined in <A HREF="#ref11">[11]</A>) followed by an optional
- * single quote (') or double quote (") character followed by optional whitespace
- * followed by ')'. Quote characters that are not part of the URL itself must
- * be balanced.
- * <P>
- * Parentheses, commas, whitespace characters, single quotes (') and double
- * quotes (") appearing in a URL must be escaped with a backslash: '\(', '\)',
- * '\,'.
- * <P>
- * Partial URLs are interpreted relative to the source of the style sheet, not
- * relative to the document:
- * <PRE>
- * BODY { background: url(yellow) }
- * </PRE>
- * See also
- * <P>
- * <A NAME="ref11">[11]</A> T Berners-Lee, L Masinter, M McCahill: "Uniform
- * Resource Locators (URL)", <A href="ftp://ds.internic.net/rfc/rfc1738.txt">RFC
- * 1738</A>, CERN, Xerox Corporation, University of Minnesota, December 1994
+ * <H3>
+ * URL
+ * </H3>
+ * <p/>
+ * A Uniform Resource Locator (URL) is identified with a functional notation:
+ * <PRE>
+ * BODY { background: url(http://www.bg.com/pinkish.gif) }
+ * </PRE>
+ * <p/>
+ * The format of a URL value is 'url(' followed by optional white space followed
+ * by an optional single quote (') or double quote (") character followed by
+ * the URL itself (as defined in <A HREF="#ref11">[11]</A>) followed by an optional
+ * single quote (') or double quote (") character followed by optional whitespace
+ * followed by ')'. Quote characters that are not part of the URL itself must
+ * be balanced.
+ * <p/>
+ * Parentheses, commas, whitespace characters, single quotes (') and double
+ * quotes (") appearing in a URL must be escaped with a backslash: '\(', '\)',
+ * '\,'.
+ * <p/>
+ * Partial URLs are interpreted relative to the source of the style sheet, not
+ * relative to the document:
+ * <PRE>
+ * BODY { background: url(yellow) }
+ * </PRE>
+ * See also
+ * <p/>
+ * <A NAME="ref11">[11]</A> T Berners-Lee, L Masinter, M McCahill: "Uniform
+ * Resource Locators (URL)", <A href="ftp://ds.internic.net/rfc/rfc1738.txt">RFC
+ * 1738</A>, CERN, Xerox Corporation, University of Minnesota, December 1994
+ *
* @version $Revision$
*/
public class CssURL extends CssValue {
@@ -51,7 +52,7 @@
public static final int type = CssTypes.CSS_URL;
public final int getType() {
- return type;
+ return type;
}
String value;
@@ -62,75 +63,78 @@
/**
* Set the value of this URL.
*
- * @param s the string representation of the URL.
- * @param frame For errors and warnings reports.
- * @exception InvalidParamException The unit is incorrect
+ * @param s the string representation of the URL.
+ * @param ac For errors and warnings reports.
+ * @throws InvalidParamException The unit is incorrect
* @deprecated
*/
public void set(String s, ApplContext ac)
- throws InvalidParamException {
- throw new InvalidParamException("Deprecated method invocation", ac);
+ throws InvalidParamException {
+ throw new InvalidParamException("Deprecated method invocation", ac);
}
/**
* Set the value of this URL.
*
- * @param s the string representation of the URL.
- * @param frame For errors and warnings reports.
+ * @param s the string representation of the URL.
+ * @param ac For errors and warnings reports.
* @param base the base location of the style sheet
- * @exception InvalidParamException The unit is incorrect
+ * @throws InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac, URL base)
- throws InvalidParamException {
- String urlHeading = s.substring(0,3).toLowerCase();
- String urlname = s.substring(4, s.length()-1).trim();
- this.base = base;
+ throws InvalidParamException {
+ String urlHeading = s.substring(0, 3).toLowerCase();
+ String urlname = s.substring(4, s.length() - 1).trim();
+ this.base = base;
// try {
// CssString convert = new CssString();
// convert.set(urlname, ac);
// value = (String) convert.get();
// } catch (InvalidParamException e) {
- value = urlname;
- full = null;
+ value = urlname;
+ full = null;
// }
- if (!urlHeading.startsWith("url"))
- throw new InvalidParamException("url", s, ac);
+ if (!urlHeading.startsWith("url"))
+ throw new InvalidParamException("url", s, ac);
}
/**
* Get the internal value.
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns the URL
+ *
+ * @return the URL
+ * @throws java.net.MalformedURLException (self explanatory)
*/
public URL getURL() throws MalformedURLException {
- return HTTPURL.getURL(base, value);
+ return HTTPURL.getURL(base, value);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if (full != null) {
- return full;
- }
- StringBuilder sb = new StringBuilder("url(");
- sb.append(value).append(')');
- return full = sb.toString();
+ if (full != null) {
+ return full;
+ }
+ StringBuilder sb = new StringBuilder("url(");
+ sb.append(value).append(')');
+ return full = sb.toString();
}
/**
* Compares two values for equality.
*
- * @param value The other value.
+ * @param url The other value.
*/
public boolean equals(Object url) {
- return (url instanceof CssURL && value.equals(((CssURL) url).value));
+ return (url instanceof CssURL && value.equals(((CssURL) url).value));
}
}
Index: CssValue.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssValue.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssValue.java 25 Mar 2008 18:30:12 -0000 1.6
+++ CssValue.java 5 Jan 2010 13:50:01 -0000 1.7
@@ -19,39 +19,39 @@
String cssversion;
public int getType() {
- return type;
+ return type;
}
-
- /**
- * Set the value of this value.
- *
- * @param s the string representation of the value.
- * @param frame For errors and warnings reports.
- * @exception InvalidParamException The unit is incorrect
- */
- public abstract void set(String s, ApplContext ac)
- throws InvalidParamException;
- /**
- * Returns the internal value
- */
- public abstract Object get();
+ /**
+ * Set the value of this value.
+ *
+ * @param s the string representation of the value.
+ * @param ac For errors and warnings reports.
+ * @throws InvalidParamException The unit is incorrect
+ */
+ public abstract void set(String s, ApplContext ac)
+ throws InvalidParamException;
- /**
- * Compares two values for equality.
- *
- * @param value The other value.
- */
- public boolean equals(Object value) {
- return super.equals(value);
- }
+ /**
+ * @return the internal value
+ */
+ public abstract Object get();
+
+ /**
+ * Compares two values for equality.
+ *
+ * @param value The other value.
+ */
+ public boolean equals(Object value) {
+ return super.equals(value);
+ }
public void setCssVersion(String cssversion) {
- this.cssversion = cssversion;
+ this.cssversion = cssversion;
}
public boolean isDefault() {
- return false;
+ return false;
}
}
Index: CssIdent.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssIdent.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CssIdent.java 17 Dec 2009 21:57:30 -0000 1.9
+++ CssIdent.java 5 Jan 2010 13:50:00 -0000 1.10
@@ -6,82 +6,85 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
-import java.util.HashMap;
-
import org.w3c.css.util.ApplContext;
+import java.util.HashMap;
+
/**
* @version $Revision$
*/
public class CssIdent extends CssValue {
- public static HashMap<String,CssIdent> allowedvalues;
+ public static HashMap<String, CssIdent> allowedvalues;
+
static {
- allowedvalues = new HashMap<String,CssIdent>();
- allowedvalues.put("inherit", new CssIdent("inherit"));
- allowedvalues.put("none", new CssIdent("none"));
+ allowedvalues = new HashMap<String, CssIdent>();
+ allowedvalues.put("inherit", new CssIdent("inherit"));
+ allowedvalues.put("none", new CssIdent("none"));
}
+
/**
* Get a cached CssIdent, useful for common values like "inherit"
+ *
* @param name, the ident name
* @return a CssIdent
*/
public static CssIdent getIdent(String name) {
- CssIdent val = allowedvalues.get(name);
- if (val != null) {
- return val;
- }
- val = new CssIdent(name);
- allowedvalues.put(name, val);
- return val;
+ CssIdent val = allowedvalues.get(name);
+ if (val != null) {
+ return val;
+ }
+ val = new CssIdent(name);
+ allowedvalues.put(name, val);
+ return val;
}
public static final int type = CssTypes.CSS_IDENT;
-
+
private int hashcode = 0;
public final int getType() {
- return type;
+ return type;
}
-
+
/**
* Create a new CssIdent
*/
public CssIdent() {
}
-
+
/**
* Create a new CssIdent
*
* @param s The identificator
*/
public CssIdent(String s) {
- value = s;
+ value = s;
}
/**
* Set the value of this ident.
*
- * @param s the string representation of the identificator.
- * @param frame For errors and warnings reports.
+ * @param s the string representation of the identificator.
+ * @param ac For errors and warnings reports.
*/
public void set(String s, ApplContext ac) {
- value = s;
- hashcode = 0;
+ value = s;
+ hashcode = 0;
}
/**
* Returns the internal value.
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return value;
+ return value;
}
/**
@@ -90,27 +93,28 @@
* @param value The other value.
*/
public boolean equals(Object value) {
- return (value instanceof CssIdent && value.hashCode() == hashCode());
+ return ((value instanceof CssIdent) && (value.hashCode()==hashCode()));
}
/**
* Compares two values for equality.
*
* @param value The other value.
+ * @return true is the two values are matching
*/
public boolean equals(CssIdent value) {
- return (value.hashCode() == hashCode());
+ return (value.hashCode() == hashCode());
}
/**
* Returns a hashcode for this ident.
*/
public int hashCode() {
- // we cache, as we use toLowerCase and don't store the resulting string
- if (hashcode == 0) {
- hashcode = value.toLowerCase().hashCode();
- }
- return hashcode;
+ // we cache, as we use toLowerCase and don't store the resulting string
+ if (hashcode == 0) {
+ hashcode = value.toLowerCase().hashCode();
+ }
+ return hashcode;
}
private String value;
Index: RGB.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/RGB.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- RGB.java 7 Jul 2009 13:32:57 -0000 1.7
+++ RGB.java 5 Jan 2010 13:50:01 -0000 1.8
@@ -64,6 +64,9 @@
/**
* Create a new RGB with default values
+ * @param r the red channel, an <EM>int</EM>
+ * @param g the green channel, an <EM>int</EM>
+ * @param b the blue channel, an <EM>int</EM>
*/
public RGB(int r, int g, int b) {
this.r = r;
Index: CssPercentage.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssPercentage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssPercentage.java 5 Mar 2009 18:02:21 -0000 1.7
+++ CssPercentage.java 5 Jan 2010 13:50:00 -0000 1.8
@@ -2,7 +2,7 @@
// $Id$
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;
@@ -12,32 +12,33 @@
import org.w3c.css.util.Util;
/**
- * <H3>
- * Percentage units
- * </H3>
- * <P>
- * The format of a percentage value is an optional sign character ('+' or '-',
- * with '+' being the default) immediately followed by a number (with or without
- * a decimal point) immediately followed by '%'.
- * <P>
- * Percentage values are always relative to another value, for example a length
- * unit. Each property that allows percentage units also defines what value
- * the percentage value refer to. Most often this is the font size of the element
- * itself:
- * <PRE>
- * P { line-height: 120% } / * 120% of the element's 'font-size' * /
+ * <H3>
+ * Percentage units
+ * </H3>
+ * <p/>
+ * The format of a percentage value is an optional sign character ('+' or '-',
+ * with '+' being the default) immediately followed by a number (with or without
+ * a decimal point) immediately followed by '%'.
+ * <p/>
+ * Percentage values are always relative to another value, for example a length
+ * unit. Each property that allows percentage units also defines what value
+ * the percentage value refer to. Most often this is the font size of the element
+ * itself:
+ * <PRE>
+ * P { line-height: 120% } / * 120% of the element's 'font-size' * /
* </PRE>
- * <P>
- * In all inherited CSS1 properties, if the value is specified as a percentage,
- * child elements inherit the resultant value, not the percentage value.
+ * <p/>
+ * In all inherited CSS1 properties, if the value is specified as a percentage,
+ * child elements inherit the resultant value, not the percentage value.
+ *
* @version $Revision$
*/
public class CssPercentage extends CssValue {
public static final int type = CssTypes.CSS_PERCENTAGE;
-
+
public final int getType() {
- return type;
+ return type;
}
static Float defaultValue = new Float(0);
@@ -47,7 +48,7 @@
* Create a new CssPercentage
*/
public CssPercentage() {
- this(defaultValue);
+ this(defaultValue);
}
/**
@@ -56,7 +57,7 @@
* @param value The value.
*/
public CssPercentage(int value) {
- this(new Float(value));
+ this(new Float(value));
}
/**
@@ -65,7 +66,7 @@
* @param value the float value.
*/
public CssPercentage(float value) {
- this(new Float(value));
+ this(new Float(value));
}
/**
@@ -74,52 +75,53 @@
* @param value the Float object.
*/
public CssPercentage(Float value) {
- this.value = value;
+ this.value = value;
}
/**
* Set the value of this percentage.
*
- * @param s the string representation of the percentage.
- * @param frame For errors and warnings reports.
- * @exception InvalidParamException The unit is incorrect
+ * @param s the string representation of the percentage.
+ * @param ac For errors and warnings reports.
+ * @throws InvalidParamException The unit is incorrect
*/
public void set(String s, ApplContext ac) throws InvalidParamException {
- if (s.charAt(s.length()-1) != '%') {
- throw new InvalidParamException("percentage", s, ac);
- }
- this.value = new Float(s.substring(0, s.length()-1));
+ int slength = s.length();
+ if (s.charAt(slength - 1) != '%') {
+ throw new InvalidParamException("percentage", s, ac);
+ }
+ this.value = new Float(s.substring(0, slength - 1));
}
/**
* Returns the current value
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns the value as a float
*/
public float getValue() {
- return value.floatValue();
+ return value.floatValue();
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return Util.displayFloat(value) + "%";
+ return Util.displayFloat(value) + "%";
}
/**
* Compares two values for equality.
*
- * @param value The other value.
+ * @param val The other value.
*/
public boolean equals(Object val) {
- return ((val instanceof CssPercentage)
- && value.equals(((CssPercentage) val).value));
+ return ((val instanceof CssPercentage)
+ && value.equals(((CssPercentage) val).value));
}
}
Received on Tuesday, 5 January 2010 13:50:08 UTC