- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 05 Jan 2010 13:49:51 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css21
In directory hutz:/tmp/cvs-serv25562/org/w3c/css/properties/css21
Modified Files:
CssBackgroundCSS21.java CssBackgroundColorCSS21.java
CssBackgroundPositionCSS21.java CssBorderFaceColorCSS21.java
CssColorCSS21.java CssDisplayCSS21.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: CssBorderFaceColorCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBorderFaceColorCSS21.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssBorderFaceColorCSS21.java 14 Sep 2005 15:14:58 -0000 1.2
+++ CssBorderFaceColorCSS21.java 5 Jan 2010 13:49:48 -0000 1.3
@@ -4,8 +4,8 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;
+import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
-import org.w3c.css.properties.css1.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
Index: CssBackgroundCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundCSS21.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBackgroundCSS21.java 10 Dec 2009 14:34:38 -0000 1.5
+++ CssBackgroundCSS21.java 5 Jan 2010 13:49:48 -0000 1.6
@@ -5,18 +5,16 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;
-import org.w3c.css.properties.css1.CssBackgroundAttachmentCSS2;
-import org.w3c.css.properties.css1.CssBackgroundCSS2;
-import org.w3c.css.properties.css1.CssBackgroundImageCSS2;
-import org.w3c.css.properties.css1.CssBackgroundRepeatCSS2;
+import org.w3c.css.properties.css2.CssBackgroundAttachmentCSS2;
+import org.w3c.css.properties.css2.CssBackgroundCSS2;
+import org.w3c.css.properties.css2.CssBackgroundImageCSS2;
+import org.w3c.css.properties.css2.CssBackgroundRepeatCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssValue;
-import org.w3c.css.values.CssString;
import org.w3c.css.values.CssTypes;
-import org.w3c.css.values.CssURL;
/**
* CssBackgroundCSS21<br />
@@ -27,149 +25,149 @@
* Create a new CssBackgroundCSS2
*/
public CssBackgroundCSS21() {
- super();
+ super();
}
/**
* Set the value of the property
*
* @param expression The expression for this property
- * @exception InvalidParamException The expression is incorrect
+ * @throws InvalidParamException The expression is incorrect
*/
public CssBackgroundCSS21(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- CssValue val;
- char op = SPACE;
- boolean find = true;
- CssExpression background_position_expression = null;
+ CssValue val;
+ char op = SPACE;
+ boolean find = true;
+ CssExpression background_position_expression = null;
- // too many values
- if(check && expression.getCount() > 6) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ // too many values
+ if (check && expression.getCount() > 6) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- setByUser();
+ setByUser();
- boolean manyValues = (expression.getCount() > 1);
+ boolean manyValues = (expression.getCount() > 1);
- while (find) {
- val = expression.getValue();
- if (val == null) {
- break;
- }
- op = expression.getOperator();
-
- // if there are many values, we can't have inherit as one of them
- if(manyValues && val.equals(inherit)) {
- throw new InvalidParamException("unrecognize", null, null, ac);
- }
+ while (find) {
+ val = expression.getValue();
+ if (val == null) {
+ break;
+ }
+ op = expression.getOperator();
- switch (val.getType()) {
- case CssTypes.CSS_STRING:
- if (check) {
- throw new InvalidParamException("unrecognize", ac);
- }
- find = false;
- break;
- case CssTypes.CSS_URL:
- if (getImage() == null) {
- setImage(new CssBackgroundImageCSS2(ac, expression));
- continue;
- }
- find = false;
- break;
- case CssTypes.CSS_COLOR:
- if (getColor2() == null) {
- setColor(new CssBackgroundColorCSS21(ac, expression));
- continue;
- }
- find = false;
- break;
- case CssTypes.CSS_NUMBER:
- case CssTypes.CSS_PERCENTAGE:
- case CssTypes.CSS_LENGTH:
- if (background_position_expression == null) {
- background_position_expression = new CssExpression();
- }
- background_position_expression.addValue(val);
- expression.next();
- find = true;
- break;
- case CssTypes.CSS_IDENT:
- // the hard part, as ident can be from different subproperties
- find = false;
- CssIdent identval = (CssIdent) val;
- // check background-image ident
- if (CssBackgroundImageCSS2.checkMatchingIdent(identval)) {
- if (getImage() == null) {
- setImage(new CssBackgroundImageCSS2(ac, expression));
- find = true;
- }
- break;
- }
- // check background-repeat ident
- if (CssBackgroundRepeatCSS2.checkMatchingIdent(identval)) {
- if (getRepeat() == null) {
- setRepeat(new CssBackgroundRepeatCSS2(ac, expression));
- find = true;
- }
- break;
- }
- // check background-attachment ident
- if (CssBackgroundAttachmentCSS2.checkMatchingIdent(identval)) {
- if (getAttachment() == null) {
- setAttachment(new CssBackgroundAttachmentCSS2(ac,
- expression));
- find = true;
- }
- break;
- }
- // check backgorund-position ident
- if (CssBackgroundPositionCSS21.checkMatchingIdent(identval)) {
- if (background_position_expression == null) {
- background_position_expression = new CssExpression();
- }
- background_position_expression.addValue(val);
- expression.next();
- find = true;
- break;
- }
+ // if there are many values, we can't have inherit as one of them
+ if (manyValues && val.equals(inherit)) {
+ throw new InvalidParamException("unrecognize", null, null, ac);
+ }
- if (getColor2() == null) {
- try {
- setColor(new CssBackgroundColorCSS21(ac, expression));
- find = true;
- break;
- } catch (InvalidParamException e) {
- // nothing to do, image will test this value
- }
- }
+ switch (val.getType()) {
+ case CssTypes.CSS_STRING:
+ if (check) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ find = false;
+ break;
+ case CssTypes.CSS_URL:
+ if (getImage() == null) {
+ setImage(new CssBackgroundImageCSS2(ac, expression));
+ continue;
+ }
+ find = false;
+ break;
+ case CssTypes.CSS_COLOR:
+ if (getColor2() == null) {
+ setColor(new CssBackgroundColorCSS21(ac, expression));
+ continue;
+ }
+ find = false;
+ break;
+ case CssTypes.CSS_NUMBER:
+ case CssTypes.CSS_PERCENTAGE:
+ case CssTypes.CSS_LENGTH:
+ if (background_position_expression == null) {
+ background_position_expression = new CssExpression();
+ }
+ background_position_expression.addValue(val);
+ expression.next();
+ find = true;
+ break;
+ case CssTypes.CSS_IDENT:
+ // the hard part, as ident can be from different subproperties
+ find = false;
+ CssIdent identval = (CssIdent) val;
+ // check background-image ident
+ if (CssBackgroundImageCSS2.checkMatchingIdent(identval)) {
+ if (getImage() == null) {
+ setImage(new CssBackgroundImageCSS2(ac, expression));
+ find = true;
+ }
+ break;
+ }
+ // check background-repeat ident
+ if (CssBackgroundRepeatCSS2.checkMatchingIdent(identval)) {
+ if (getRepeat() == null) {
+ setRepeat(new CssBackgroundRepeatCSS2(ac, expression));
+ find = true;
+ }
+ break;
+ }
+ // check background-attachment ident
+ if (CssBackgroundAttachmentCSS2.checkMatchingIdent(identval)) {
+ if (getAttachment() == null) {
+ setAttachment(new CssBackgroundAttachmentCSS2(ac,
+ expression));
+ find = true;
+ }
+ break;
+ }
+ // check backgorund-position ident
+ if (CssBackgroundPositionCSS21.checkMatchingIdent(identval)) {
+ if (background_position_expression == null) {
+ background_position_expression = new CssExpression();
+ }
+ background_position_expression.addValue(val);
+ expression.next();
+ find = true;
+ break;
+ }
- default:
- if (check) {
- throw new InvalidParamException("unrecognize", ac);
- }
- find = false;
- }
- if(check && !find) {
- throw new InvalidParamException("unrecognize", ac);
- }
- if (op != SPACE) {
- throw new InvalidParamException("operator",
- Character.toString(op),
- ac);
- }
- }
- if (background_position_expression != null) {
- setPosition(new CssBackgroundPositionCSS21(ac,
- background_position_expression,
- check));
- }
+ if (getColor2() == null) {
+ try {
+ setColor(new CssBackgroundColorCSS21(ac, expression));
+ find = true;
+ break;
+ } catch (InvalidParamException e) {
+ // nothing to do, image will test this value
+ }
+ }
+
+ default:
+ if (check) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ find = false;
+ }
+ if (check && !find) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ if (op != SPACE) {
+ throw new InvalidParamException("operator",
+ Character.toString(op),
+ ac);
+ }
+ }
+ if (background_position_expression != null) {
+ setPosition(new CssBackgroundPositionCSS21(ac,
+ background_position_expression,
+ check));
+ }
}
public CssBackgroundCSS21(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
}
Index: CssBackgroundColorCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundColorCSS21.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBackgroundColorCSS21.java 11 Feb 2009 22:43:15 -0000 1.3
+++ CssBackgroundColorCSS21.java 5 Jan 2010 13:49:48 -0000 1.4
@@ -4,11 +4,10 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;
-import org.w3c.css.properties.css1.CssBackgroundColorCSS2;
+import org.w3c.css.properties.css2.CssBackgroundColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
-import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
Index: CssDisplayCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssDisplayCSS21.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssDisplayCSS21.java 14 Sep 2005 15:14:58 -0000 1.2
+++ CssDisplayCSS21.java 5 Jan 2010 13:49:48 -0000 1.3
@@ -1,99 +1,175 @@
+//
// $Id$
-// Author: Jean-Guilhem Rouel
-// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
+// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+//
+// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;
-import org.w3c.css.properties.css1.CssDisplayCSS2;
+import org.w3c.css.properties.css.CssDisplay;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
-/**
- * CssDisplayCSS21<br />
- * Created: Aug 30, 2005 3:54:43 PM<br />
+import java.util.HashMap;
+ /**
+ *
+ * http://www.w3.org/TR/2009/CR-CSS2-20090908/visuren.html#display-prop
+ *
+ * 9.2.4 The 'display' property
+
+'display'
+ Value: inline | block | list-item | run-in | inline-block | table |
+ inline-table | table-row-group | table-header-group |
+ table-footer-group | table-row | table-column-group |
+ table-column | table-cell | table-caption | none | inherit
+ Initial: inline
+ Applies to: all elements
+ Inherited: no
+ Percentages: N/A
+ Media: all
+ Computed value: see text
+
+The values of this property have the following meanings:
+
+block
+ This value causes an element to generate a block box.
+inline-block
+ This value causes an element to generate a block box, which itself is
+ flowed as a single inline box, similar to a replaced element. The inside
+ of an inline-block is formatted as a block box, and the element itself is
+ formatted as an inline replaced element.
+inline
+ This value causes an element to generate one or more inline boxes.
+list-item
+ This value causes an element (e.g., LI in HTML) to generate a principal
+ block box and a list-item inline box. For information about lists and
+ examples of list formatting, please consult the section on lists.
+none
+ This value causes an element to not appear in the formatting structure
+ (i.e., in visual media the element generates no boxes and has no effect
+ on layout). Descendant elements do not generate any boxes either;
+ the element and its content are removed from the formatting structure
+ entirely. This behavior cannot be overridden by setting the 'display'
+ property on the descendants.
+
+ Please note that a display of 'none' does not create an invisible box;
+ it creates no box at all. CSS includes mechanisms that enable an element
+ to generate boxes in the formatting structure that affect formatting but
+ are not visible themselves. Please consult the section on visibility for
+ details.
+run-in
+ This value creates either block or inline boxes, depending on context.
+ Properties apply to run-in boxes based on their final status (inline-level
+ or block-level).
+table, inline-table, table-row-group, table-column, table-column-group,
+table-header-group, table-footer-group, table-row, table-cell,
+and table-caption
+ These values cause an element to behave like a table element
+ (subject to restrictions described in the chapter on tables).
+
+The computed value is the same as the specified value, except for positioned
+and floating elements (see Relationships between 'display', 'position', and '
+float') and for the root element. For the root element, the computed value is
+changed as described in the section on the relationships between 'display',
+'position', and 'float'.
+
+Note that although the initial value of 'display' is 'inline', rules in the
+user agent's default style sheet may override this value. See the sample
+style sheet for HTML 4 in the appendix.
+
+Example(s):
+
+Here are some examples of the 'display' property:
+
+p { display: block }
+em { display: inline }
+li { display: list-item }
+img { display: none }
+
+ * @version $Revision$
*/
-public class CssDisplayCSS21 extends CssDisplayCSS2 {
- private static String[] DISPLAY = {
- "inline", "block", "inline-block", "list-item", "run-in", "table",
- "inline-table", "table-row-group", "table-column-group",
- "table-header-group", "table-footer-group", "table-row", "table-column",
- "table-cell", "table-caption", "none", "inherit" };
+public class CssDisplayCSS21 extends CssDisplay {
- private static int[] hash_values;
+ public static CssIdent inline;
+ public static HashMap<String, CssIdent> allowed_values;
static {
- hash_values = new int[DISPLAY.length];
- for (int i = 0; i < DISPLAY.length; i++)
- hash_values[i] = DISPLAY[i].hashCode();
+ allowed_values = new HashMap<String, CssIdent>();
+ String[] DISPLAY = {
+ "inline", "block", "list-item", "run-in", "inline-block",
+ "table", "inline-table", "table-row-group",
+ "table-header-group", "table-footer-group",
+ "table-row", "table-column-group", "table-column",
+ "table-cell", "table-caption", "none"};
+
+ for (String aDISPLAY : DISPLAY) {
+ allowed_values.put(aDISPLAY, CssIdent.getIdent(aDISPLAY));
+ }
+ inline = CssIdent.getIdent("inline");
}
/**
* Create a new CssDisplay
*/
public CssDisplayCSS21() {
- // nothing to do
+ // nothing to do
}
/**
* Create a new CssDisplay
*
+ * @param ac The context
* @param expression The expression for this property
- * @exception InvalidParamException Values are incorect
+ * @param check boolean, if check has to be enforced
+ * @throws org.w3c.css.util.InvalidParamException Values are incorect
*/
public CssDisplayCSS21(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- CssValue val = expression.getValue();
+ CssValue val = expression.getValue();
- setByUser();
+ setByUser();
- if ( val instanceof CssIdent) {
- int hash = val.hashCode();
- for (int i = 0; i < DISPLAY.length; i++) {
- if (hash_values[i] == hash) {
- setValue(i);
- expression.next();
- return;
- }
- }
- }
+ if (val.getType() == CssTypes.CSS_IDENT) {
+ CssIdent id_val = (CssIdent) val;
+ String id_value = id_val.toString();
+ if (inherit.equals(id_val)) {
+ value = inherit;
+ } else {
+ value = allowed_values.get(id_value);
+ }
+ if (value != null) {
+ expression.next();
+ return;
+ }
+ }
+
+ throw new InvalidParamException("value", expression.getValue(),
+ getPropertyName(), ac);
- throw new InvalidParamException("value", expression.getValue(),
- getPropertyName(), ac);
}
public CssDisplayCSS21(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
- /**
- * Returns a string representation of the object.
- */
- public String toString() {
- return DISPLAY[getValue()];
- }
/**
- * Returns true if this property is "softly" inherited
- * e.g. his value equals inherit
+ * Is the value of this property is a default value.
+ * It is used by all macro for the function <code>print</code>
*/
- public boolean isSoftlyInherited() {
- return getValue() == DISPLAY.length - 1;
+ public boolean isDefault() {
+ return (value == inline);
}
- /**
- * Returns the value of this property
- */
- public Object get() {
- return DISPLAY[getValue()];
- }
-}
+}
\ No newline at end of file
Index: CssBackgroundPositionCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackgroundPositionCSS21.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBackgroundPositionCSS21.java 6 Feb 2009 15:17:48 -0000 1.5
+++ CssBackgroundPositionCSS21.java 5 Jan 2010 13:49:48 -0000 1.6
@@ -4,15 +4,10 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;
-import org.w3c.css.properties.css1.CssBackgroundPositionCSS2;
+import org.w3c.css.properties.css2.CssBackgroundPositionCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
-import org.w3c.css.values.CssIdent;
-import org.w3c.css.values.CssLength;
-import org.w3c.css.values.CssNumber;
-import org.w3c.css.values.CssPercentage;
-import org.w3c.css.values.CssValue;
/**
* CssBackgroundPositionCSS21<br />
Received on Tuesday, 5 January 2010 13:50:24 UTC