- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 07 Nov 2012 11:34:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv17598/css1
Modified Files:
Css1Style.java CssListStyle.java CssListStyleImage.java
CssListStylePosition.java CssListStyleType.java
Removed Files:
CssListStyleCSS1.java CssListStyleCSS2.java
CssListStyleConstants.java CssListStyleImageCSS1.java
CssListStyleImageCSS2.java CssListStylePositionCSS1.java
CssListStylePositionCSS2.java CssListStyleTV.java
CssListStyleTypeCSS1.java CssListStyleTypeCSS2.java
CssListStyleTypeTV.java
Log Message:
list-style-* per css1/2/21/3/tv plus cleanup of multiple property depending on the level in css1style
Index: CssListStyleType.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssListStyleType.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssListStyleType.java 5 Jan 2010 13:49:44 -0000 1.4
+++ CssListStyleType.java 7 Nov 2012 11:34:56 -0000 1.5
@@ -1,175 +1,96 @@
-//
// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
-// Updated September 14th 2000 Sijtsche de Jong (sy.de.jong@let.rug.nl)
+// Author: Yves Lafon <ylafon@w3.org>
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
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;
/**
- * <H4>
- * 'list-style-type'
- * </H4>
- * <P>
- * <EM>Value:</EM> disc | circle | square | decimal | lower-roman |
- * upper-roman | lower-alpha | upper-alpha | none
- * check | diamond | menu-check | radio | radio-on | radio-off | radio-ind |
- * enabled-radio-on | enabled-radio-off | enabled-radio-ind |
- * disabled-radio-on | disabled-radio-off | disabled-radio-ind |
- * active-radio-off | active-radio-on | active-radio-ind |
- * hover-radio-off | hover-radio-on | hover-radio-ind |
- * checkbox | checkbox-on | checkbox-off | checkbox-ind |
- * enabled-checkbox-on | enabled-checkbox-off | enabled-checkbox-ind |
- * disabled-checkbox-on | disabled-checkbox-off | disabled-checkbox-ind |
- * active-checkbox-on | active-checkbox-off | active-checkbox-ind |
- * hover-checkbox-on | hover-checkbox-off | hover-checkbox-ind
- <BR>
- * <EM>Initial:</EM> disc<BR>
- * <EM>Applies to:</EM> elements with 'display' value 'list-item'<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P> This property is used to determine the appearance of the list-item
- * marker if 'list-style-image' is 'none' or if the image pointed to by the
- * URL cannot be displayed.
- * <PRE>
- * OL { list-style-type: decimal } /* 1 2 3 4 5 etc. * /
- * OL { list-style-type: lower-alpha } /* a b c d e etc. * /
- * OL { list-style-type: lower-roman } /* i ii iii iv v etc. * /
- * </PRE>
- * @version $Revision$ */
-public class CssListStyleType extends CssProperty
- implements CssListStyleConstants {
-
- int value;
-
- private static int[] hash_values;
-
- /**
- * Create a new CssListStyleType
- */
- public CssListStyleType() {
- // nothing to do
- }
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#list-style-type
+ */
+public class CssListStyleType extends org.w3c.css.properties.css.CssListStyleType {
- /**
- * Create a new CssListStyleType
- * @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
- */
- public CssListStyleType(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ public static final CssIdent[] allowed_values;
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
+ static {
+ String[] _allowed_values = {"none", "disc", "circle", "square", "decimal",
+ "lower-roman", "upper-roman", "lower-alpha", "upper-alpha"};
+ int i = 0;
+ allowed_values = new CssIdent[_allowed_values.length];
+ for (String s : _allowed_values) {
+ allowed_values[i++] = CssIdent.getIdent(s);
+ }
}
- CssValue val = expression.getValue();
-
- setByUser();
-
- if ( val instanceof CssIdent) {
- int hash = val.hashCode();
- for (int i = 0; i < LISTSTYLETYPE.length; i++)
- if (hash_values[i] == hash) {
- value = i;
- expression.next();
- return;
+ public static final CssIdent getAllowedIdent(CssIdent ident) {
+ for (CssIdent id : allowed_values) {
+ if (id.equals(ident)) {
+ return id;
+ }
}
+ return null;
}
- throw new InvalidParamException("value", val, getPropertyName(), ac);
- }
-
- public CssListStyleType(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
+ /**
+ * Create a new CssListStyleType
+ */
+ public CssListStyleType() {
+ }
- /**
- * Returns the value of this property
- */
- public Object get() {
- return LISTSTYLETYPE[value];
- }
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "list-style-type";
- }
+ /**
+ * Set the value of the property<br/>
+ * Does not check the number of values
+ *
+ * @param expression The expression for this property
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyleType(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
- /**
- * Returns true if this property is "softly" inherited
- * e.g. his value equals inherit
- */
- public boolean isSoftlyInherited() {
- return value == (LISTSTYLETYPE.length - 1);
- }
+ /**
+ * Set the value of the property
+ *
+ * @param expression The expression for this property
+ * @param check set it to true to check the number of values
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyleType(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ setByUser();
- /**
- * Returns a string representation of the object.
- */
- public String toString() {
- return LISTSTYLETYPE[value];
- }
+ CssValue val;
+ char op;
- /**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- CssListStyle cssListStyle = ((Css1Style) style).cssListStyle;
- if (cssListStyle.listStyleType != null)
- style.addRedefinitionWarning(ac, this);
- cssListStyle.listStyleType = this;
- }
+ val = expression.getValue();
+ op = expression.getOperator();
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getListStyleType();
- } else {
- return ((Css1Style) style).cssListStyle.listStyleType;
+ if (val.getType() != CssTypes.CSS_IDENT) {
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ CssIdent id = (CssIdent) val;
+ value = getAllowedIdent(id);
+ if (value == null) {
+ throw new InvalidParamException("value",
+ val.toString(),
+ getPropertyName(), ac);
+ }
+ expression.next();
}
- }
-
- /**
- * Compares two properties for equality.
- *
- * @param value The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssListStyleType &&
- ((CssListStyleType) property).value == value);
- }
- /**
- * Is the value of this property is a default value.
- * It is used by all macro for the function <code>print</code>
- */
- public boolean isDefault() {
- return value == 0;
- }
-
- static {
- hash_values = new int[LISTSTYLETYPE.length];
- for (int i = 0; i < LISTSTYLETYPE.length; i++)
- hash_values[i] = LISTSTYLETYPE[i].hashCode();
- }
}
--- CssListStyleImageCSS1.java DELETED ---
--- CssListStyleConstants.java DELETED ---
--- CssListStyleImageCSS2.java DELETED ---
--- CssListStyleCSS2.java DELETED ---
Index: CssListStyleImage.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssListStyleImage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssListStyleImage.java 5 Jan 2010 13:49:44 -0000 1.4
+++ CssListStyleImage.java 7 Nov 2012 11:34:54 -0000 1.5
@@ -1,159 +1,76 @@
-//
// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+// Author: Yves Lafon <ylafon@w3.org>
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
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.CssURL;
+import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
- * <H4>
- * 'list-style-image'
- * </H4>
- * <P>
- * <EM>Value:</EM> <url> | none<BR>
- * <EM>Initial:</EM> none<BR>
- * <EM>Applies to:</EM> elements with 'display' value 'list-item'<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P>
- * This property sets the image that will be used as the list-item marker. When
- * the image is available it will replace the marker set with the 'list-style-type'
- * marker.
- * <PRE>
- * UL { list-style-image: url(http://png.com/ellipse.png) }
- * </PRE>
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#list-style-image
*/
-public class CssListStyleImage extends CssProperty {
-
- CssValue value;
-
- private static CssIdent none = new CssIdent("none");
-
- /**
- * Create a new CssListStyleImage
- */
- public CssListStyleImage() {
- value = none;
- }
-
- /**
- * Create a new CssListStyleImage
- *
- * @param value The value for this property
- * @exception InvalidParamException Values are incorrect
- */
- public CssListStyleImage(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+public class CssListStyleImage extends org.w3c.css.properties.css.CssListStyleImage {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
+ /**
+ * Create a new CssListStyleImage
+ */
+ public CssListStyleImage() {
}
- CssValue val = expression.getValue();
-
- setByUser();
- if (val instanceof CssURL) {
- value = val;
- expression.next();
- } else if (val.equals(none)) {
- value = none;
- expression.next();
- } else if (val.equals(inherit)) {
- value = inherit;
- expression.next();
- } else {
- throw new InvalidParamException("value", val, getPropertyName(), ac);
+ /**
+ * Set the value of the property<br/>
+ * Does not check the number of values
+ *
+ * @param expression The expression for this property
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyleImage(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
}
- }
- public CssListStyleImage(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
-
- /**
- * Returns the value of this property
- */
- public Object get() {
- return value;
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "list-style-image";
- }
-
- /**
- * Returns true if this property is "softly" inherited
- * e.g. his value equals inherit
- */
- public boolean isSoftlyInherited() {
- return value == inherit;
- }
+ /**
+ * Set the value of the property
+ *
+ * @param expression The expression for this property
+ * @param check set it to true to check the number of values
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyleImage(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ setByUser();
- /**
- * Returns a string representation of the object.
- */
- public String toString() {
- return value.toString();
- }
+ CssValue val;
+ char op;
- /**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- CssListStyle cssListStyle = ((Css1Style) style).cssListStyle;
- if (cssListStyle.listStyleImage != null)
- style.addRedefinitionWarning(ac, this);
- cssListStyle.listStyleImage = this;
- }
+ val = expression.getValue();
+ op = expression.getOperator();
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getListStyleImage();
- } else {
- return ((Css1Style) style).cssListStyle.listStyleImage;
+ switch (val.getType()) {
+ case CssTypes.CSS_URL:
+ value = val;
+ break;
+ case CssTypes.CSS_IDENT:
+ if (none.equals(val)) {
+ value = none;
+ break;
+ }
+ default:
+ throw new InvalidParamException("value",
+ val.toString(),
+ getPropertyName(), ac);
+ }
+ expression.next();
}
- }
-
- /**
- * Compares two properties for equality.
- *
- * @param value The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssListStyleImage &&
- value.equals(((CssListStyleImage) property).value));
- }
-
- /**
- * Is the value of this property is a default value.
- * It is used by all macro for the function <code>print</code>
- */
- public boolean isDefault() {
- return value == none;
- }
-
}
Index: Css1Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- Css1Style.java 6 Nov 2012 11:22:01 -0000 1.59
+++ Css1Style.java 7 Nov 2012 11:34:54 -0000 1.60
@@ -12,6 +12,10 @@
import org.w3c.css.properties.css.CssClear;
import org.w3c.css.properties.css.CssDisplay;
import org.w3c.css.properties.css.CssFloat;
+import org.w3c.css.properties.css.CssListStyle;
+import org.w3c.css.properties.css.CssListStyleImage;
+import org.w3c.css.properties.css.CssListStylePosition;
+import org.w3c.css.properties.css.CssListStyleType;
import org.w3c.css.properties.css.CssMargin;
import org.w3c.css.properties.css.CssMarginBottom;
import org.w3c.css.properties.css.CssMarginLeft;
@@ -28,6 +32,7 @@
import org.w3c.css.properties.css.CssTextIndent;
import org.w3c.css.properties.css.CssTextTransform;
import org.w3c.css.properties.css.CssVerticalAlign;
+import org.w3c.css.properties.css.CssWordSpacing;
import org.w3c.css.properties.css.CssZIndex;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
@@ -65,7 +70,7 @@
/**
* word-spacing property
*/
- public org.w3c.css.properties.css.CssWordSpacing cssWordSpacing;
+ public CssWordSpacing cssWordSpacing;
/**
* letter-spacing property
*/
@@ -148,9 +153,10 @@
/**
* list-style properties
*/
- public CssListStyle cssListStyle = new CssListStyle();
- public CssListStyleCSS2 cssListStyleCSS2 = new CssListStyleCSS2();
- public CssListStyleCSS1 cssListStyleCSS1 = new CssListStyleCSS1();
+ public CssListStylePosition cssListStylePosition;
+ public CssListStyleImage cssListStyleImage;
+ public CssListStyleType cssListStyleType;
+ public CssListStyle cssListStyle;
/**
* content property
@@ -158,15 +164,6 @@
public CssContentCSS2 cssContentCSS2;
public CssContent cssContent;
- /**
- * TV property
- */
- public CssListStyleTypeTV cssListStyleTypeTV;
- /**
- * TV property
- */
- public CssListStyleTV cssListStyleTV;
-
public String[] emptyArray = {};
/*
@@ -757,128 +754,50 @@
* Get the list-style-type property
*/
public final CssListStyleType getListStyleType() {
- if (cssListStyle.listStyleType == null) {
- cssListStyle.listStyleType =
+ if (cssListStyleType == null) {
+ cssListStyleType =
(CssListStyleType) style.CascadingOrder(new CssListStyleType(),
style, selector);
}
- return cssListStyle.listStyleType;
- }
-
- public final CssListStyleTypeCSS2 getListStyleTypeCSS2() {
- if (cssListStyleCSS2.listStyleType == null) {
- cssListStyleCSS2.listStyleType =
- (CssListStyleTypeCSS2) style.CascadingOrder(new CssListStyleTypeCSS2(),
- style, selector);
- }
- return cssListStyleCSS2.listStyleType;
- }
-
- public final CssListStyleTypeCSS1 getListStyleTypeCSS1() {
- if (cssListStyleCSS1.listStyleType == null) {
- cssListStyleCSS1.listStyleType =
- (CssListStyleTypeCSS1) style.CascadingOrder(new CssListStyleTypeCSS1(),
- style, selector);
- }
- return cssListStyleCSS1.listStyleType;
+ return cssListStyleType;
}
/**
* Get the list-style-image property
*/
public final CssListStyleImage getListStyleImage() {
- if (cssListStyle.listStyleImage == null) {
- cssListStyle.listStyleImage =
+ if (cssListStyleImage == null) {
+ cssListStyleImage =
(CssListStyleImage) style.CascadingOrder(new CssListStyleImage(),
style, selector);
}
- return cssListStyle.listStyleImage;
- }
-
- public final CssListStyleImageCSS2 getListStyleImageCSS2() {
- if (cssListStyleCSS2.listStyleImage == null) {
- cssListStyleCSS2.listStyleImage =
- (CssListStyleImageCSS2) style.CascadingOrder(new CssListStyleImageCSS2(),
- style, selector);
- }
- return cssListStyleCSS2.listStyleImage;
- }
-
- public final CssListStyleImageCSS1 getListStyleImageCSS1() {
- if (cssListStyleCSS1.listStyleImage == null) {
- cssListStyleCSS1.listStyleImage =
- (CssListStyleImageCSS1) style.CascadingOrder(new CssListStyleImageCSS1(),
- style, selector);
- }
- return cssListStyleCSS1.listStyleImage;
+ return cssListStyleImage;
}
/**
* Get the list-style-position property
*/
public final CssListStylePosition getListStylePosition() {
- if (cssListStyle.listStylePosition == null) {
- cssListStyle.listStylePosition =
+ if (cssListStylePosition == null) {
+ cssListStylePosition =
(CssListStylePosition)
style.CascadingOrder(new CssListStylePosition(),
style, selector);
}
- return cssListStyle.listStylePosition;
- }
-
- public final CssListStylePositionCSS2 getListStylePositionCSS2() {
- if (cssListStyleCSS2.listStylePosition == null) {
- cssListStyleCSS2.listStylePosition =
- (CssListStylePositionCSS2)
- style.CascadingOrder(new CssListStylePositionCSS2(),
- style, selector);
- }
- return cssListStyleCSS2.listStylePosition;
- }
-
- public final CssListStylePositionCSS1 getListStylePositionCSS1() {
- if (cssListStyleCSS1.listStylePosition == null) {
- cssListStyleCSS1.listStylePosition =
- (CssListStylePositionCSS1)
- style.CascadingOrder(new CssListStylePositionCSS1(),
- style, selector);
- }
- return cssListStyleCSS1.listStylePosition;
+ return cssListStylePosition;
}
/**
* Get the list-style property
*/
public final CssListStyle getListStyle() {
- if (cssListStyle.listStyleType == null)
- cssListStyle.listStyleType = getListStyleType();
- if (cssListStyle.listStyleImage == null)
- cssListStyle.listStyleImage = getListStyleImage();
- if (cssListStyle.listStylePosition == null)
- cssListStyle.listStylePosition = getListStylePosition();
+ if (cssListStyle == null) {
+ cssListStyle = (CssListStyle) style.CascadingOrder(new CssListStyle(),
+ style, selector);
+ }
return cssListStyle;
}
- public final CssListStyleCSS2 getListStyleCSS2() {
- if (cssListStyleCSS2.listStyleType == null)
- cssListStyleCSS2.listStyleType = getListStyleTypeCSS2();
- if (cssListStyleCSS2.listStyleImage == null)
- cssListStyleCSS2.listStyleImage = getListStyleImageCSS2();
- if (cssListStyleCSS2.listStylePosition == null)
- cssListStyleCSS2.listStylePosition = getListStylePositionCSS2();
- return cssListStyleCSS2;
- }
-
- public final CssListStyleCSS1 getListStyleCSS1() {
- if (cssListStyleCSS1.listStyleType == null)
- cssListStyleCSS1.listStyleType = getListStyleTypeCSS1();
- if (cssListStyleCSS1.listStyleImage == null)
- cssListStyleCSS1.listStyleImage = getListStyleImageCSS1();
- if (cssListStyleCSS1.listStylePosition == null)
- cssListStyleCSS1.listStylePosition = getListStylePositionCSS1();
- return cssListStyleCSS1;
- }
-
/**
* Get the content property
*/
@@ -900,26 +819,6 @@
return cssContentCSS2;
}
- public final CssListStyleTypeTV getListStyleTypeTV() {
- if (cssListStyleTypeTV == null) {
- cssListStyleTypeTV =
- (CssListStyleTypeTV) style.CascadingOrder(new CssListStyleTypeTV(),
- style, selector);
- }
-
- return cssListStyleTypeTV;
- }
-
- public final CssListStyleTV getListStyleTV() {
- if (cssListStyleTV == null) {
- cssListStyleTV =
- (CssListStyleTV) style.CascadingOrder(new CssListStyleTV(),
- style, selector);
- }
-
- return cssListStyleTV;
- }
-
/**
* Find conflicts in this Style
* For the 'font-family' property
--- CssListStyleCSS1.java DELETED ---
--- CssListStyleTV.java DELETED ---
Index: CssListStylePosition.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssListStylePosition.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssListStylePosition.java 5 Jan 2010 13:49:44 -0000 1.4
+++ CssListStylePosition.java 7 Nov 2012 11:34:56 -0000 1.5
@@ -1,159 +1,96 @@
-//
// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+// Author: Yves Lafon <ylafon@w3.org>
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
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;
/**
- * <H4>
- * 'list-style-position'
- * </H4>
- * <P>
- * <EM>Value:</EM> inside | outside<BR>
- * <EM>Initial:</EM> outside<BR>
- * <EM>Applies to:</EM> elements with 'display' value 'list-item'<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P>
- * The value of 'list-style-position' determines how the list-item marker is
- * drawn with regard to the content. For a formatting example see
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#list-style-position
*/
-public class CssListStylePosition extends CssProperty
- implements CssListStyleConstants {
-
- int value;
-
- /**
- * Create a new CssListStylePosition
- */
- public CssListStylePosition() {
- // nothing to do
- }
+public class CssListStylePosition extends org.w3c.css.properties.css.CssListStylePosition {
- /**
- * Create a new CssListStylePosition
- *
- * @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
- */
- public CssListStylePosition(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ public static final CssIdent[] allowed_values;
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
+ static {
+ String[] _allowed_values = {"inside", "outside"};
+ int i = 0;
+ allowed_values = new CssIdent[_allowed_values.length];
+ for (String s : _allowed_values) {
+ allowed_values[i++] = CssIdent.getIdent(s);
+ }
}
- CssValue val = expression.getValue();
-
- setByUser();
-
- if ( val instanceof CssIdent) {
- int hash = val.hashCode();
- for (int i = 0; i < LISTSTYLEPOSITION.length; i++)
- if (hash_values[i] == hash) {
- value = i;
- expression.next();
- return;
+ public static final CssIdent getAllowedIdent(CssIdent ident) {
+ for (CssIdent id : allowed_values) {
+ if (id.equals(ident)) {
+ return id;
+ }
}
- } else {
- throw new InvalidParamException("value", val, getPropertyName(), ac);
+ return null;
}
- }
- public CssListStylePosition(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
-
- /**
- * Returns the value of this property
- */
- public Object get() {
- return LISTSTYLEPOSITION[value];
- }
+ /**
+ * Create a new CssListStylePosition
+ */
+ public CssListStylePosition() {
+ }
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "list-style-position";
- }
- /**
- * Returns true if this property is "softly" inherited
- * e.g. his value equals inherit
- */
- public boolean isSoftlyInherited() {
- return value == (LISTSTYLEPOSITION.length - 1);
- }
-
- /**
- * Returns a string representation of the object.
- */
- public String toString() {
- return LISTSTYLEPOSITION[value];
- }
+ /**
+ * Set the value of the property<br/>
+ * Does not check the number of values
+ *
+ * @param expression The expression for this property
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStylePosition(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
- /**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- CssListStyle cssListStyle = ((Css1Style) style).cssListStyle;
- if (cssListStyle.listStylePosition != null)
- style.addRedefinitionWarning(ac, this);
- cssListStyle.listStylePosition = this;
- }
+ /**
+ * Set the value of the property
+ *
+ * @param expression The expression for this property
+ * @param check set it to true to check the number of values
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStylePosition(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ setByUser();
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getListStylePosition();
- } else {
- return ((Css1Style) style).cssListStyle.listStylePosition;
- }
- }
+ CssValue val;
+ char op;
- /**
- * Compares two properties for equality.
- *
- * @param value The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssListStylePosition &&
- ((CssListStylePosition) property).value == value);
- }
+ val = expression.getValue();
+ op = expression.getOperator();
- /**
- * Is the value of this property is a default value.
- * It is used by all macro for the function <code>print</code>
- */
- public boolean isDefault() {
- return value == 0;
- }
+ if (val.getType() != CssTypes.CSS_IDENT) {
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ CssIdent id = (CssIdent) val;
+ value = getAllowedIdent(id);
+ if (value == null) {
+ throw new InvalidParamException("value",
+ val.toString(),
+ getPropertyName(), ac);
- private static int[] hash_values;
+ }
+ expression.next();
+ }
- static {
- hash_values = new int[LISTSTYLEPOSITION.length];
- for (int i = 0; i < LISTSTYLEPOSITION.length; i++)
- hash_values[i] = LISTSTYLEPOSITION[i].hashCode();
- }
}
--- CssListStyleTypeCSS1.java DELETED ---
--- CssListStylePositionCSS1.java DELETED ---
--- CssListStyleTypeCSS2.java DELETED ---
Index: CssListStyle.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssListStyle.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssListStyle.java 9 Sep 2011 12:16:44 -0000 1.6
+++ CssListStyle.java 7 Nov 2012 11:34:54 -0000 1.7
@@ -1,329 +1,136 @@
-//
// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+// Author: Yves Lafon <ylafon@w3.org>
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssSelectors;
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
-import org.w3c.css.values.CssOperator;
+import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
+import org.w3c.css.values.CssValueList;
-/**
- * <H4>
- * 'list-style'
- * </H4>
- * <P>
- * <EM>Value:</EM> <keyword> || <position> || <url><BR>
- * <EM>Initial:</EM> not defined for shorthand properties<BR>
- * <EM>Applies to:</EM> elements with 'display' value 'list-item'<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P>
- * The 'list-style' property is a shorthand notation for setting the three
- * properties 'list-style-type', 'list-style-image' and 'list-style-position'
- * at the same place in the style sheet.
- * <PRE>
- * UL { list-style: upper-roman inside }
- * UL UL { list-style: circle outside }
- * LI.square { list-style: square }
- * </PRE>
- * <P>
- * Setting 'list-style' directly on 'LI' elements can have unexpected results.
- * Consider:
- * <PRE>
- * <STYLE TYPE="text/css">
- * OL.alpha LI { list-style: lower-alpha }
- * UL LI { list-style: disc }
- * </STYLE>
- * <BODY>
- * <OL CLASS=alpha>
- * <LI>level 1
- * <UL>
- * <LI>level 2
- * </UL>
- * </OL>
- * </BODY>
- * </PRE>
- * <P> Since the specificity (as defined in the <A
- * HREF="#cascading-order">cascading order</A>) is higher for the first rule
- * in the style sheet in the example above, it will override the second rule
- * on all 'LI' elements and only 'lower-alpha' list styles will be used. It is
- * therefore recommended to set 'list-style' only on the list type elements:
- * <PRE>
- * OL.alpha { list-style: lower-alpha }
- * UL { list-style: disc }
- * </PRE>
- * <P> In the above example, inheritance will transfer the 'list-style' values
- * from 'OL' and 'UL' elements to 'LI' elements.
- * <P>
- * A URL value can be combined with any other value:
- * <PRE>
- * UL { list-style: url(http://png.com/ellipse.png) disc }
- * </PRE>
- * <P> In the example above, the 'disc' will be used when the image is
- * unavailable.
- *
- * @version $Revision$
- */
-public class CssListStyle extends CssProperty implements CssOperator {
-
- CssListStyleType listStyleType;
- CssListStyleImage listStyleImage;
- CssListStylePosition listStylePosition;
-
- boolean inheritedValue;
+import java.util.ArrayList;
- /**
- * Create a new CssListStyle
- */
- public CssListStyle() {
- // nothing to do
- }
+import static org.w3c.css.values.CssOperator.SPACE;
- /**
- * Create a new CssListStyle
- *
- * @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
- */
- public CssListStyle(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+/**
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#list-style
+ */
+public class CssListStyle extends org.w3c.css.properties.css.CssListStyle {
- if(check && expression.getCount() > 3) {
- throw new InvalidParamException("unrecognize", ac);
+ /**
+ * Create a new CssListStyle
+ */
+ public CssListStyle() {
}
- CssValue val = expression.getValue();
- char op = SPACE;
- boolean find = true;
- setByUser();
-
- if (val.equals(inherit)) {
- if(expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
- inheritedValue = true;
- expression.next();
- return;
+ /**
+ * Set the value of the property<br/>
+ * Does not check the number of values
+ *
+ * @param expression The expression for this property
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyle(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
}
- while (find) {
- find = false;
- val = expression.getValue();
- op = expression.getOperator();
-
- if(val != null && val.equals(inherit)) {
- throw new InvalidParamException("unrecognize", ac);
- }
-
- if ((listStyleType == null)
- && (val != null)) {
- try {
- listStyleType = new CssListStyleType(ac, expression);
- find = true;
- } catch (InvalidParamException e) {
- }
- }
- if (!find
- && (listStyleImage == null)
- && (val != null)) {
- try {
- listStyleImage = new CssListStyleImage(ac, expression);
- find = true;
- } catch (InvalidParamException e) {
+ /**
+ * Set the value of the property
+ *
+ * @param expression The expression for this property
+ * @param check set it to true to check the number of values
+ * @throws org.w3c.css.util.InvalidParamException
+ * The expression is incorrect
+ */
+ public CssListStyle(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ if (check && expression.getCount() > 3) {
+ throw new InvalidParamException("unrecognize", ac);
}
- }
- if (!find
- && (val != null)
- && (listStylePosition == null)) {
- listStylePosition = new CssListStylePosition(ac, expression);
- find = true;
- }
- if(val != null && !find) {
- throw new InvalidParamException("unrecognize", ac);
- }
- if (op != SPACE) {
- throw new InvalidParamException("operator",
- ((new Character(op)).toString()),
- ac);
- }
- }
- /*
- if (listStyleType == null) {
- listStyleType = new CssListStyleType();
- }
-
- if (listStyleImage == null) {
- listStyleImage = new CssListStyleImage();
- }
-
- if (listStylePosition == null) {
- listStylePosition = new CssListStylePosition();
- }*/
- }
-
- public CssListStyle(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
-
- /**
- * Returns the value of this property
- */
- public Object get() {
- return listStyleType;
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "list-style";
- }
-
- /**
- * Returns true if this property is "softly" inherited
- * e.g. his value equals inherit
- */
- public boolean isSoftlyInherited() {
- return inheritedValue;
- }
-
- /**
- * Returns a string representation of the object.
- */
- public String toString() {
- if (inheritedValue) {
- return inherit.toString();
- } else {
- String ret = "";
- if(listStyleType != null) {
- ret = listStyleType.toString();
- }
- if (listStyleImage != null &&!listStyleImage.isDefault()) {
- ret += " " + listStyleImage;
- }
- if (listStylePosition != null && !listStylePosition.isDefault()) {
- ret += " " + listStylePosition;
- }
- return ret.trim();
- }
- }
-
-
-
- /**
- * Set this property to be important.
- * Overrides this method for a macro
- */
- public void setImportant() {
- if (!inheritedValue) {
- if(listStyleType != null)
- listStyleType.important = true;
- if(listStyleImage != null)
- listStyleImage.important = true;
- if(listStylePosition != null)
- listStylePosition.important = true;
- }
- }
-
- /**
- * Returns true if this property is important.
- * Overrides this method for a macro
- */
- public boolean getImportant() {
- return ((listStyleType == null || listStyleType.important) &&
- (listStyleImage == null || listStyleImage.important) &&
- (listStylePosition == null || listStylePosition.important));
- }
-
- /**
- * Set the context.
- * Overrides this method for a macro
- *
- * @see org.w3c.css.css.CssCascadingOrder#order
- * @see org.w3c.css.css.StyleSheetParser#handleRule
- */
- public void setSelectors(CssSelectors selector) {
- super.setSelectors(selector);
- if (listStyleType != null) {
- listStyleType.setSelectors(selector);
- }
- if (listStyleImage != null) {
- listStyleImage.setSelectors(selector);
- }
- if (listStylePosition != null) {
- listStylePosition.setSelectors(selector);
- }
- }
+ setByUser();
- /**
- * Add this property to the CssStyle
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- if (!inheritedValue) {
- if(listStyleType != null)
- listStyleType.addToStyle(ac, style);
- if(listStyleImage != null)
- listStyleImage.addToStyle(ac, style);
- if(listStylePosition != null)
- listStylePosition.addToStyle(ac, style);
- } else {
- ((Css1Style) style).cssListStyle.inheritedValue = true;
- }
- }
+ CssValue val;
+ char op;
+ CssValue imageVal = null;
+ CssValue positionVal = null;
+ CssValue typeVal = null;
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getListStyle();
- } else {
- return ((Css1Style) style).cssListStyle;
- }
- }
+ while (!expression.end()) {
+ val = expression.getValue();
+ op = expression.getOperator();
- /**
- * Update the source file and the line.
- * Overrides this method for a macro
- *
- * @param line The line number where this property is defined
- * @param source The source file where this property is defined
- */
- public void setInfo(int line, String source) {
- super.setInfo(line, source);
- if (!inheritedValue) {
- if(listStyleType != null)
- listStyleType.setInfo(line, source);
- if(listStyleImage != null)
- listStyleImage.setInfo(line, source);
- if(listStylePosition != null)
- listStylePosition.setInfo(line, source);
+ switch (val.getType()) {
+ case CssTypes.CSS_URL:
+ if (imageVal != null) {
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ imageVal = val;
+ break;
+ case CssTypes.CSS_IDENT:
+ if (none.equals(val)) {
+ if (imageVal != null || typeVal != null) {
+ // TODO duplicate value error
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ typeVal = none;
+ imageVal = none;
+ break;
+ }
+ // now we go to other values...
+ CssIdent id = (CssIdent) val;
+ if (positionVal == null) {
+ positionVal = CssListStylePosition.getAllowedIdent(id);
+ if (positionVal != null) {
+ break;
+ }
+ }
+ if (typeVal == null) {
+ typeVal = org.w3c.css.properties.css2.CssListStyleType.getAllowedIdent(id);
+ if (typeVal != null) {
+ break;
+ }
+ }
+ // unrecognized ident.. fail!
+ default:
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ if (op != SPACE) {
+ throw new InvalidParamException("operator",
+ ((new Character(op)).toString()), ac);
+ }
+ expression.next();
+ }
+ // set the value
+ if (value != inherit) {
+ ArrayList<CssValue> v = new ArrayList<CssValue>();
+ if (typeVal != null) {
+ v.add(typeVal);
+ }
+ if (positionVal != null) {
+ v.add(positionVal);
+ }
+ if (imageVal != null) {
+ v.add(imageVal);
+ }
+ value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
+ }
+ // then the shorthand values
+ cssListStyleType = new CssListStyleType();
+ cssListStyleType.value = typeVal;
+ cssListStylePosition = new CssListStylePosition();
+ cssListStylePosition.value = positionVal;
+ cssListStyleImage = new CssListStyleImage();
+ cssListStyleImage.value = imageVal;
}
- }
-
- /**
- * Compares two properties for equality.
- *
- * @param value The other property.
- */
- public boolean equals(CssProperty property) {
- // @FIXME
- return false;
- }
-
}
--- CssListStyleTypeTV.java DELETED ---
--- CssListStylePositionCSS2.java DELETED ---
Received on Wednesday, 7 November 2012 11:35:31 UTC