- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 24 Aug 2012 07:33:53 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv18771/css3 Modified Files: CssBreakInside.java Log Message: ident case sensitivity Index: CssBreakInside.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBreakInside.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssBreakInside.java 4 Oct 2011 14:33:38 -0000 1.3 +++ CssBreakInside.java 24 Aug 2012 07:33:51 -0000 1.4 @@ -8,7 +8,6 @@ package org.w3c.css.properties.css3; -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; @@ -16,132 +15,90 @@ import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -import java.util.HashMap; - /** - * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks - * <p/> - * When content is laid out in multiple columns, the user agent must determine - * where column breaks are placed. The problem of breaking content into columns - * is similar to breaking content into pages. - * <p/> - * Three new properties are introduced to allow column breaks to be described - * in the same properties as page breaks: ‘break-before’, ‘break-after’, and - * ‘break-inside’. These properties take the same values as - * ‘page-break-before’, ‘page-break-after’, and ‘page-break-inside’ [CSS21]. - * In addition, some new keyword values are added. - * <p/> - * Name: break-inside - * Value: auto | avoid | avoid-page | avoid-column - * Initial: auto - * Applies to: block-level elements - * Inherited: no - * Percentages: N/A - * Media: paged - * Computed value: specified value + * @spec http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks */ public class CssBreakInside extends org.w3c.css.properties.css.CssBreakInside { - static CssIdent auto; - private static HashMap<String, CssIdent> allowed_values; - - CssIdent value; - - static { - allowed_values = new HashMap<String, CssIdent>(); - auto = CssIdent.getIdent("auto"); - String id_values[] = {"auto", "always", "avoid", "left", "right", - "page", "column", "avoid-page", "avoid-column"}; - for (String s : id_values) { - allowed_values.put(s, CssIdent.getIdent(s)); - } - } + static CssIdent auto; + private static CssIdent[] allowed_values; - /** - * Create a new CssColumnWidth - */ - public CssBreakInside() { - value = auto; - } - /** - * Create a new CssBreakInside - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException Incorrect value - */ - public CssBreakInside(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - setByUser(); - CssValue val = expression.getValue(); - - if (check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } + static { + auto = CssIdent.getIdent("auto"); + String id_values[] = {"auto", "always", "avoid", "left", "right", + "page", "column", "avoid-page", "avoid-column"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } - if (val.getType() != CssTypes.CSS_IDENT) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); - } - // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; - } else { - val = allowed_values.get(val.toString()); - if (val == null) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); - } - value = (CssIdent)val; - } - expression.next(); - } + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } - public CssBreakInside(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Create a new CssBreakInside + */ + public CssBreakInside() { + value = initial; + } - /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssBreakInside && - value.equals(((CssBreakInside) property).value)); - } + /** + * Create a new CssBreakInside + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Incorrect value + */ + public CssBreakInside(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); - /** - * Returns the value of this property - */ - public Object get() { - return value; - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return (inherit == value); - } + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + if (inherit.equals(val)) { + value = inherit; + } else { + val = getMatchingIdent((CssIdent) val); + if (val == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + } + expression.next(); + } - /** - * Returns a string representation of the object - */ - public String toString() { - return value.toString(); - } + public CssBreakInside(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * 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); - } + /** + * 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); + } }
Received on Friday, 24 August 2012 07:33:59 UTC