- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 24 Aug 2012 07:07:07 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv32119/css3
Modified Files:
CssBackgroundClip.java CssBackgroundSize.java
Log Message:
ident case sensitivity
Index: CssBackgroundSize.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackgroundSize.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssBackgroundSize.java 4 Oct 2011 13:05:25 -0000 1.4
+++ CssBackgroundSize.java 24 Aug 2012 07:07:05 -0000 1.5
@@ -17,7 +17,6 @@
import org.w3c.css.values.CssValueList;
import java.util.ArrayList;
-import java.util.HashMap;
import static org.w3c.css.values.CssOperator.COMMA;
import static org.w3c.css.values.CssOperator.SPACE;
@@ -43,186 +42,197 @@
*/
public class CssBackgroundSize extends org.w3c.css.properties.css.CssBackgroundSize {
- private static CssIdent auto;
- private static HashMap<String, CssIdent> allowed_values;
+ private static CssIdent auto;
+ private static CssIdent[] allowed_values;
- static {
- auto = CssIdent.getIdent("auto");
- allowed_values = new HashMap<String, CssIdent>();
- allowed_values.put("auto", auto);
- allowed_values.put("cover", CssIdent.getIdent("cover"));
- allowed_values.put("contain", CssIdent.getIdent("contain"));
- }
+ static {
+ auto = CssIdent.getIdent("auto");
+ allowed_values = new CssIdent[3];
+ allowed_values[0] = auto;
+ allowed_values[1] = CssIdent.getIdent("cover");
+ allowed_values[2] = CssIdent.getIdent("contain");
+ }
- public static boolean isMatchingIdent(CssIdent ident) {
- return allowed_values.containsKey(ident.toString());
- }
+ public static boolean isMatchingIdent(CssIdent ident) {
+ return (getMatchingIdent(ident) != null);
+ }
- Object value;
+ public static CssIdent getMatchingIdent(CssIdent ident) {
+ for (CssIdent id : allowed_values) {
+ if (id.equals(ident)) {
+ return id;
+ }
+ }
+ return null;
+ }
- /**
- * Create a new CssBackgroundSize
- */
- public CssBackgroundSize() {
- value = auto;
- }
+ Object value;
- /**
- * Create a new CssBackgroundSize
- *
- * @param ac The context
- * @param expression The expression for this property
- * @param check if arguments count must be checked.
- * @throws org.w3c.css.util.InvalidParamException Values are incorrect
- */
- public CssBackgroundSize(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
- ArrayList<CssValue> values = new ArrayList<CssValue>();
- char op;
- CssValue val;
- CssValueList vl = null;
- boolean is_complete = true;
+ /**
+ * Create a new CssBackgroundSize
+ */
+ public CssBackgroundSize() {
+ value = auto;
+ }
- setByUser();
+ /**
+ * Create a new CssBackgroundSize
+ *
+ * @param ac The context
+ * @param expression The expression for this property
+ * @param check if arguments count must be checked.
+ * @throws org.w3c.css.util.InvalidParamException
+ * Values are incorrect
+ */
+ public CssBackgroundSize(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ ArrayList<CssValue> values = new ArrayList<CssValue>();
+ char op;
+ CssValue val;
+ CssValueList vl = null;
+ boolean is_complete = true;
- while (!expression.end()) {
- val = expression.getValue();
- op = expression.getOperator();
- switch (val.getType()) {
- case CssTypes.CSS_NUMBER:
- val = ((CssNumber) val).getLength();
- case CssTypes.CSS_LENGTH:
- case CssTypes.CSS_PERCENTAGE:
- // per spec only non-negative values are allowed
- float f = ((Float) val.get()).floatValue();
- if (f < 0) {
- throw new InvalidParamException("negative-value",
- val.toString(), ac);
- }
- if (is_complete) {
- vl = new CssValueList();
- vl.add(val);
- } else {
- vl.add(val);
- values.add(vl);
- }
- is_complete = !is_complete;
- break;
- case CssTypes.CSS_IDENT:
- if (inherit.equals(val)) {
- // if we got inherit after other values, fail
- // if we got more than one value... fail
- if ((values.size() > 0) || (expression.getCount() > 1)) {
- throw new InvalidParamException("value", val,
- getPropertyName(), ac);
- }
- values.add(inherit);
- break;
- } else if (auto.equals(val)) {
- if (is_complete) {
- vl = new CssValueList();
- vl.add(auto);
- } else {
- vl.add(auto);
- values.add(vl);
- }
- is_complete = !is_complete;
- break;
- } else {
- CssValue v = allowed_values.get(val.toString());
- // if ok, and if we are not in a middle of a compound
- // value...
- if (v != null && is_complete) {
- values.add(v);
- break;
- }
- }
- default:
- throw new InvalidParamException("value", val,
- getPropertyName(), ac);
+ setByUser();
- }
- expression.next();
- if (!expression.end()) {
- // incomplete value followed by a comma... it's complete!
- if (!is_complete && (op == COMMA)) {
- values.add(vl);
- is_complete = true;
- }
- // complete values are separated by a comma, otherwise space
- if ((is_complete && (op != COMMA)) ||
- (!is_complete && (op != SPACE))) {
- throw new InvalidParamException("operator",
- ((new Character(op)).toString()), ac);
- }
- }
- }
- // if we reach the end in a value that can come in pair
- if (!is_complete) {
- values.add(vl);
- }
- if (values.size() == 1) {
- value = values.get(0);
- } else {
- value = values;
- }
- }
+ while (!expression.end()) {
+ val = expression.getValue();
+ op = expression.getOperator();
+ switch (val.getType()) {
+ case CssTypes.CSS_NUMBER:
+ val = ((CssNumber) val).getLength();
+ case CssTypes.CSS_LENGTH:
+ case CssTypes.CSS_PERCENTAGE:
+ // per spec only non-negative values are allowed
+ float f = ((Float) val.get()).floatValue();
+ if (f < 0) {
+ throw new InvalidParamException("negative-value",
+ val.toString(), ac);
+ }
+ if (is_complete) {
+ vl = new CssValueList();
+ vl.add(val);
+ } else {
+ vl.add(val);
+ values.add(vl);
+ }
+ is_complete = !is_complete;
+ break;
+ case CssTypes.CSS_IDENT:
+ if (inherit.equals(val)) {
+ // if we got inherit after other values, fail
+ // if we got more than one value... fail
+ if ((values.size() > 0) || (expression.getCount() > 1)) {
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ values.add(inherit);
+ break;
+ } else if (auto.equals(val)) {
+ if (is_complete) {
+ vl = new CssValueList();
+ vl.add(auto);
+ } else {
+ vl.add(auto);
+ values.add(vl);
+ }
+ is_complete = !is_complete;
+ break;
+ } else {
+ CssValue v = getMatchingIdent((CssIdent) val);
+ // if ok, and if we are not in a middle of a compound
+ // value...
+ if (v != null && is_complete) {
+ values.add(v);
+ break;
+ }
+ }
+ default:
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ expression.next();
+ if (!expression.end()) {
+ // incomplete value followed by a comma... it's complete!
+ if (!is_complete && (op == COMMA)) {
+ values.add(vl);
+ is_complete = true;
+ }
+ // complete values are separated by a comma, otherwise space
+ if ((is_complete && (op != COMMA)) ||
+ (!is_complete && (op != SPACE))) {
+ throw new InvalidParamException("operator",
+ ((new Character(op)).toString()), ac);
+ }
+ }
+ }
+ // if we reach the end in a value that can come in pair
+ if (!is_complete) {
+ values.add(vl);
+ }
+ if (values.size() == 1) {
+ value = values.get(0);
+ } else {
+ value = values;
+ }
+ }
- public CssBackgroundSize(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
- /**
- * Compares two properties for equality.
- *
- * @param property The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssBackgroundSize &&
- value.equals(((CssBackgroundSize) property).value));
- }
+ public CssBackgroundSize(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
- /**
- * Returns the value of this property
- */
- public Object get() {
- return value;
- }
+ /**
+ * Compares two properties for equality.
+ *
+ * @param property The other property.
+ */
+ public boolean equals(CssProperty property) {
+ return (property instanceof CssBackgroundSize &&
+ value.equals(((CssBackgroundSize) property).value));
+ }
- public void set(Object val) {
- value = val;
- }
- /**
- * Returns true if this property is "softly" inherited
- */
- public boolean isSoftlyInherited() {
- return (inherit == value);
- }
+ /**
+ * Returns the value of this property
+ */
+ public Object get() {
+ return value;
+ }
- /**
- * Returns a string representation of the object
- */
- public String toString() {
- if (value instanceof ArrayList) {
- ArrayList values = (ArrayList) value;
- StringBuilder sb = new StringBuilder();
- for (Object aValue : values) {
- sb.append(aValue.toString()).append(", ");
- }
- sb.setLength(sb.length() - 2);
- return sb.toString();
- }
- return value.toString();
- }
+ public void set(Object val) {
+ value = val;
+ }
- /**
- * Is the value of this property a default value
- * It is used by all macro for the function <code>print</code>
- */
- public boolean isDefault() {
- return (auto == value);
- }
+ /**
+ * Returns true if this property is "softly" inherited
+ */
+ public boolean isSoftlyInherited() {
+ return (inherit == value);
+ }
+
+ /**
+ * Returns a string representation of the object
+ */
+ public String toString() {
+ if (value instanceof ArrayList) {
+ ArrayList values = (ArrayList) value;
+ StringBuilder sb = new StringBuilder();
+ for (Object aValue : values) {
+ sb.append(aValue.toString()).append(", ");
+ }
+ sb.setLength(sb.length() - 2);
+ return sb.toString();
+ }
+ return value.toString();
+ }
+
+ /**
+ * Is the value of this property a default value
+ * It is used by all macro for the function <code>print</code>
+ */
+ public boolean isDefault() {
+ return (auto == value);
+ }
}
Index: CssBackgroundClip.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackgroundClip.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssBackgroundClip.java 3 Apr 2012 14:20:54 -0000 1.7
+++ CssBackgroundClip.java 24 Aug 2012 07:07:05 -0000 1.8
@@ -17,7 +17,6 @@
import org.w3c.css.values.CssValue;
import java.util.ArrayList;
-import java.util.HashMap;
import static org.w3c.css.values.CssOperator.COMMA;
@@ -27,158 +26,168 @@
public class CssBackgroundClip extends org.w3c.css.properties.css.CssBackgroundClip {
- public final static CssIdent border_box;
- public static HashMap<String, CssIdent> allowed_values;
- public final static String val[] = {"border-box", "padding-box", "content-box"};
- Object value;
+ public final static CssIdent border_box;
+ public static CssIdent[] allowed_values;
+ public final static String val[] = {"border-box", "padding-box", "content-box"};
+ Object value;
- static {
- border_box = CssIdent.getIdent("border-box");
- allowed_values = new HashMap<String, CssIdent>();
- for (String s : val) {
- allowed_values.put(s, CssIdent.getIdent(s));
- }
- }
+ static {
+ border_box = CssIdent.getIdent("border-box");
+ allowed_values = new CssIdent[val.length];
+ int i = 0;
+ for (String s : val) {
+ allowed_values[i++] = CssIdent.getIdent(s);
+ }
+ }
- public static boolean isMatchingIdent(CssIdent ident) {
- return allowed_values.containsValue(ident);
+ public static boolean isMatchingIdent(CssIdent ident) {
+ return (getMatchingIdent(ident) != null);
- }
+ }
- /**
- * Create a new CssBackgroundClip
- */
- public CssBackgroundClip() {
- value = initial;
- }
+ public static CssIdent getMatchingIdent(CssIdent ident) {
+ for (CssIdent id : allowed_values) {
+ if (id.equals(ident)) {
+ return id;
+ }
+ }
+ return null;
+ }
- /**
- * Create a new CssBackgroundClip
- *
- * @param expression The expression for this property
- * @throws org.w3c.css.util.InvalidParamException
- * Incorrect value
- */
- public CssBackgroundClip(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ /**
+ * Create a new CssBackgroundClip
+ */
+ public CssBackgroundClip() {
+ value = initial;
+ }
- ArrayList<CssValue> values = new ArrayList<CssValue>();
+ /**
+ * Create a new CssBackgroundClip
+ *
+ * @param expression The expression for this property
+ * @throws org.w3c.css.util.InvalidParamException
+ * Incorrect value
+ */
+ public CssBackgroundClip(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
- CssValue val;
- CssIdent matchingIdent;
- char op;
+ ArrayList<CssValue> values = new ArrayList<CssValue>();
- while (!expression.end()) {
- val = expression.getValue();
- op = expression.getOperator();
- switch (val.getType()) {
- case CssTypes.CSS_IDENT:
- if (inherit.equals(val)) {
- // if we got inherit after other values, fail
- // if we got more than one value... fail
- if ((values.size() > 0) || (expression.getCount() > 1)) {
- throw new InvalidParamException("value", val,
- getPropertyName(), ac);
- }
- values.add(inherit);
- break;
- }
- matchingIdent = allowed_values.get(val.toString());
- if (matchingIdent != null) {
- values.add(matchingIdent);
- break;
- }
- default:
- throw new InvalidParamException("value", val,
- getPropertyName(), ac);
- }
- expression.next();
- if (!expression.end() && (op != COMMA)) {
- throw new InvalidParamException("operator",
- ((new Character(op)).toString()), ac);
- }
- }
- if (values.size() == 1) {
- value = values.get(0);
- } else {
- value = values;
- }
- }
+ CssValue val;
+ CssIdent matchingIdent;
+ char op;
- public CssBackgroundClip(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
- }
+ while (!expression.end()) {
+ val = expression.getValue();
+ op = expression.getOperator();
+ switch (val.getType()) {
+ case CssTypes.CSS_IDENT:
+ if (inherit.equals(val)) {
+ // if we got inherit after other values, fail
+ // if we got more than one value... fail
+ if ((values.size() > 0) || (expression.getCount() > 1)) {
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ values.add(inherit);
+ break;
+ }
+ matchingIdent = getMatchingIdent((CssIdent) val);
+ if (matchingIdent != null) {
+ values.add(matchingIdent);
+ break;
+ }
+ default:
+ throw new InvalidParamException("value", val,
+ getPropertyName(), ac);
+ }
+ expression.next();
+ if (!expression.end() && (op != COMMA)) {
+ throw new InvalidParamException("operator",
+ ((new Character(op)).toString()), ac);
+ }
+ }
+ if (values.size() == 1) {
+ value = values.get(0);
+ } else {
+ value = values;
+ }
+ }
- public void set(Object val) {
- value = val;
- }
+ public CssBackgroundClip(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
- /**
- * Returns the value of this property
- */
- public Object get() {
- return value;
- }
+ public void set(Object val) {
+ value = val;
+ }
- /**
- * Add this property to the CssStyle
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- // TODO FIXME -> in CssStyle
- if (((Css3Style) style).cssBackgroundClip != null)
- style.addRedefinitionWarning(ac, this);
- ((Css3Style) style).cssBackgroundClip = this;
- }
+ /**
+ * Returns the value of this property
+ */
+ public Object get() {
+ return value;
+ }
- /**
- * 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 ((Css3Style) style).getCssBackgroundClip();
- } else {
- return ((Css3Style) style).cssBackgroundClip;
- }
- }
+ /**
+ * Add this property to the CssStyle
+ *
+ * @param style The CssStyle
+ */
+ public void addToStyle(ApplContext ac, CssStyle style) {
+ // TODO FIXME -> in CssStyle
+ if (((Css3Style) style).cssBackgroundClip != null)
+ style.addRedefinitionWarning(ac, this);
+ ((Css3Style) style).cssBackgroundClip = this;
+ }
- /**
- * Compares two properties for equality.
- *
- * @param property The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssBackgroundClip &&
- value.equals(((CssBackgroundClip) property).value));
- }
+ /**
+ * 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 ((Css3Style) style).getCssBackgroundClip();
+ } else {
+ return ((Css3Style) style).cssBackgroundClip;
+ }
+ }
- /**
- * Returns a string representation of the object
- */
- public String toString() {
- if (value instanceof ArrayList) {
- ArrayList values = (ArrayList) value;
- StringBuilder sb = new StringBuilder();
- for (Object aValue : values) {
- sb.append(aValue.toString()).append(", ");
- }
- sb.setLength(sb.length() - 2);
- return sb.toString();
- }
- return value.toString();
- }
+ /**
+ * Compares two properties for equality.
+ *
+ * @param property The other property.
+ */
+ public boolean equals(CssProperty property) {
+ return (property instanceof CssBackgroundClip &&
+ value.equals(((CssBackgroundClip) property).value));
+ }
- /**
- * Is the value of this property a default value
- * It is used by all macro for the function <code>print</code>
- */
- public boolean isDefault() {
- return (border_box == value);
- }
+ /**
+ * Returns a string representation of the object
+ */
+ public String toString() {
+ if (value instanceof ArrayList) {
+ ArrayList values = (ArrayList) value;
+ StringBuilder sb = new StringBuilder();
+ for (Object aValue : values) {
+ sb.append(aValue.toString()).append(", ");
+ }
+ sb.setLength(sb.length() - 2);
+ return sb.toString();
+ }
+ return value.toString();
+ }
+
+ /**
+ * Is the value of this property a default value
+ * It is used by all macro for the function <code>print</code>
+ */
+ public boolean isDefault() {
+ return (border_box == value);
+ }
}
Received on Friday, 24 August 2012 07:07:09 UTC