W3C home > Mailing lists > Public > www-validator-cvs@w3.org > February 2012

2002/css-validator/org/w3c/css/properties/css21 CssBackground.java,NONE,1.1 CssBackgroundAttachment.java,NONE,1.1 CssBackgroundColor.java,NONE,1.1 CssBackgroundImage.java,NONE,1.1 CssBackgroundPosition.java,NONE,1.1 CssBackgroundRepeat.java,NONE,1.1 CssLetterSpacing.java,NONE,1.1 CssWhiteSpace.java,NONE,1.1 CssWordSpacing.java,NONE,1.1 CssBorderBottomCSS21.java,1.2,1.3 CssBorderBottomColorCSS21.java,1.2,1.3 CssBorderCSS21.java,1.3,1.4 CssBorderColorCSS21.java,1.2,1.3 CssHeight.java,1.1,1.2 CssWidth.java,1.1,1.2 CssBackgroundCSS21.java,1.6,NONE CssBackgroundColorCSS21.java,1.5,NONE CssBackgroundPositionCSS21.java,1.6,NONE CssWhiteSpaceCSS21.java,1.2,NONE

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 09 Feb 2012 17:36:34 +0000
To: www-val
Message-Id: <E1RvXv8-0006mk-Je@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css21
In directory hutz:/tmp/cvs-serv25830/w3c/css/properties/css21

Modified Files:
	CssBorderBottomCSS21.java CssBorderBottomColorCSS21.java 
	CssBorderCSS21.java CssBorderColorCSS21.java CssHeight.java 
	CssWidth.java 
Added Files:
	CssBackground.java CssBackgroundAttachment.java 
	CssBackgroundColor.java CssBackgroundImage.java 
	CssBackgroundPosition.java CssBackgroundRepeat.java 
	CssLetterSpacing.java CssWhiteSpace.java CssWordSpacing.java 
Removed Files:
	CssBackgroundCSS21.java CssBackgroundColorCSS21.java 
	CssBackgroundPositionCSS21.java CssWhiteSpaceCSS21.java 
Log Message:
various things: Use of BigIntegers to avoid limits, background-* are now avoiding multiplication of checks and properties in CssXStyles impls, various updates for other properties, use of a string reader for string input, added the possibility of not following links, prepared for aggregation of all uris parsed

--- NEW FILE: CssBackgroundRepeat.java ---
//
// $Id: CssBackgroundRepeat.java,v 1.1 2012/02/09 17:36:31 ylafon Exp $
// From Philippe Le Hegaret (http://www.w3.org/TR/2011/REC-CSS2-20110607/text.html#propdef-letter-spacing
 * @version $Revision: 1.1 $
 */
public class CssLetterSpacing extends org.w3c.css.properties.css.CssLetterSpacing {

    private CssValue value;
    private static CssIdent normal = CssIdent.getIdent("normal");

    /**
     * Create a new CssLetterSpacing.
     */
    public CssLetterSpacing() {
        value = normal;
    }

    /**
     * Create a new CssLetterSpacing with an expression
     *
     * @param expression The expression
     * @throws org.w3c.css.util.InvalidParamException The expression is incorrect
     */
    public CssLetterSpacing(ApplContext ac, CssExpression expression,
                            boolean check) throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        CssValue val = expression.getValue();

        setByUser();

        switch (val.getType()) {
            case CssTypes.CSS_NUMBER:
                val = ((CssNumber) val).getLength();
            case CssTypes.CSS_LENGTH:
                value = val;
                break;
            case CssTypes.CSS_IDENT:
                if (inherit.equals(val) || normal.equals(val)) {
                    value = val;
                    break;
                }
            default:
                throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
        }
        expression.next();
    }

    public CssLetterSpacing(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
        return value == inherit;
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssLetterSpacing &&
                value.equals(((CssLetterSpacing) property).value));
    }
}

--- NEW FILE: CssBackgroundAttachment.java ---
//
// $Id: CssBackgroundAttachment.java,v 1.1 2012/02/09 17:36:31 ylafon Exp $
// From Philippe Le Hegaret (http://www.w3.org/TR/2011/REC-CSS2-20110607/text.html#propdef-word-spacing
 * @version $Revision: 1.1 $
 */
public class CssWordSpacing extends org.w3c.css.properties.css.CssWordSpacing {

    private CssValue value;
    private static CssIdent normal = CssIdent.getIdent("normal");

    /**
     * Create a new CssWordSpacing.
     */
    public CssWordSpacing() {
        value = normal;
    }

    /**
     * Create a new CssWordSpacing with an expression
     *
     * @param expression The expression
     * @throws org.w3c.css.util.InvalidParamException The expression is incorrect
     */
    public CssWordSpacing(ApplContext ac, CssExpression expression,
                          boolean check) throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        CssValue val = expression.getValue();

        setByUser();

        switch (val.getType()) {
            case CssTypes.CSS_NUMBER:
                val = ((CssNumber) val).getLength();
            case CssTypes.CSS_LENGTH:
                value = val;
                break;
            case CssTypes.CSS_IDENT:
                if (inherit.equals(val) || normal.equals(val)) {
                    value = val;
                    break;
                }
            default:
                throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
        }
        expression.next();
    }

    public CssWordSpacing(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
        return value == inherit;
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssWordSpacing &&
                value.equals(((CssWordSpacing) property).value));
    }
}

--- CssWhiteSpaceCSS21.java DELETED ---


--- NEW FILE: CssBackgroundColor.java ---
// $Id: CssBackgroundColor.java,v 1.1 2012/02/09 17:36:31 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

/**
 * CssBackgroundColor<br />
 * Created: Aug 31, 2005 2:04:23 PM<br />
 */
public class CssBackgroundColor extends org.w3c.css.properties.css.CssBackgroundColor {

    public CssValue color;

    /**
     * Create a new CssBackgroundColor
     */
    public CssBackgroundColor() {
        color = transparent;
    }

    /**
     * Create a new CssBackgroundColor
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundColor(ApplContext ac, CssExpression expression,
                              boolean check) throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        setByUser();
        CssValue val = expression.getValue();

        switch (val.getType()) {
            case CssTypes.CSS_COLOR:
                setColor(val);
                break;
            case CssTypes.CSS_IDENT:
                if (transparent.equals(val)) {
                    setColor(transparent);
                    break;
                }
                if (inherit.equals(val)) {
                    setColor(inherit);
                    break;
                }
                setColor(new org.w3c.css.values.CssColor(ac,
                        (String) val.get()));
                break;
            default:
                throw new InvalidParamException("value", val.toString(),
                        getPropertyName(), ac);
        }
        expression.next();
    }

    public CssBackgroundColor(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * @param color The color to set.
     */
    public void setColor(CssValue color) {
        this.color = color;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return color;
    }

    /**
     * Returns the color
     */
    public final CssValue getColor() {
        return color;
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
        return color.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (color != null) {
            return color.toString();
        }
        return "";
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.color != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.color = this;
    }

    /**
     * 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).getBackgroundColor();
        } else {
            return ((Css1Style) style).cssBackground.color;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundColor &&
                color.equals(((CssBackgroundColor) property).color));
    }

    /**
     * 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 color == transparent;
    }
}


--- NEW FILE: CssBackgroundImage.java ---
//
// $Id: CssBackgroundImage.java,v 1.1 2012/02/09 17:36:31 ylafon Exp $
// From Philippe Le Hegaret (http://www.w3.org/TR/2011/REC-CSS2-20110607/text.html#white-space-prop
 */
public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace {

    CssValue value;

    public static HashMap<String, CssIdent> allowed_values;

    static {
        allowed_values = new HashMap<String, CssIdent>();
        String[] WHITESPACE = {
                "normal", "pre", "nowrap", "pre-wrap", "pre-line"
        };

        for (String aWS : WHITESPACE) {
            allowed_values.put(aWS, CssIdent.getIdent(aWS));
        }
    }

    /**
     * Create a new CssWhiteSpace
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          values are incorrect
     */
    public CssWhiteSpace(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        CssValue val = expression.getValue();
        setByUser();

        if (val.getType() == CssTypes.CSS_IDENT) {
            if (inherit.equals(val)) {
                value = inherit;
            } else {
                value = allowed_values.get(val.toString());
            }
            if (value != null) {
                expression.next();
                return;
            }
        }
        throw new InvalidParamException("value", expression.getValue(),
                getPropertyName(), ac);
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    public CssWhiteSpace(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

}

--- CssBackgroundPositionCSS21.java DELETED ---

Index: CssWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssWidth.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssWidth.java	27 Sep 2011 08:15:46 -0000	1.1
+++ CssWidth.java	9 Feb 2012 17:36:32 -0000	1.2
@@ -63,7 +63,7 @@
                 val = ((CssNumber) val).getLength();
             case CssTypes.CSS_LENGTH:
                 lenVal = (CssLength) val;
-                if (lenVal.floatValue() < 0.) {
+                if (!lenVal.isPositive()) {
                     throw new InvalidParamException("negative-value",
                             val.toString(), ac);
                 }
Received on Thursday, 9 February 2012 17:36:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:32 GMT