W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2011

2002/css-validator/org/w3c/css/properties/css3 CssDisplay.java,NONE,1.1 Css3Style.java,1.9,1.10

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 31 Aug 2011 18:34:53 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Qypcj-0003EC-Pw@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv12201/css/properties/css3

Modified Files:
	Css3Style.java 
Added Files:
	CssDisplay.java 
Log Message:
aligned 'display' to the latest CSS21 REC, started upgrading its definition for CSS3 (currently using idents from http://www.w3.org/TR/2007/WD-css3-box-20070809/#display )

Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Css3Style.java	5 Jan 2010 13:49:49 -0000	1.9
+++ Css3Style.java	31 Aug 2011 18:34:51 -0000	1.10
@@ -9,6 +9,7 @@
 package org.w3c.css.properties.css3;
 
 import org.w3c.css.parser.CssSelectors;
+import org.w3c.css.properties.atsc.ATSCStyle;
 import org.w3c.css.properties.css.CssBackgroundClip;
 import org.w3c.css.properties.css.CssBackgroundOrigin;
 import org.w3c.css.properties.css.CssBackgroundSize;
@@ -32,7 +33,7 @@
 
 import org.w3c.css.parser.CssPrinterStyle;
 
-public class Css3Style extends org.w3c.css.properties.atsc.ATSCStyle {
+public class Css3Style extends ATSCStyle {
 
     CssOpacity cssOpacity;
     CssColorProfile cssColorProfile;

--- NEW FILE: CssDisplay.java ---
// $Id: CssDisplay.java,v 1.1 2011/08/31 18:34:51 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
// Updated September 14th 2000 Sijtsche de Jong (sy.de.jong@let.rug.nl)
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css3;

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;

import java.util.HashMap;

/**
 * Validity: 2007/08/09
 * From http://www.w3.org/TR/2007/WD-css3-box-20070809/#the-lsquo
 * <p/>
 * 4.1. The ?display? property
 * Name: 	display
 * Value: 	inline | block | inline-block | list-item | run-in | compact | table |
 * inline-table | table-row-group | table-header-group |
 * table-footer-group | table-row | table-column-group | table-column |
 * table-cell | table-caption | ruby | ruby-base | ruby-text |
 * ruby-base-group | ruby-text-group | <template>| none
 * Initial: 	inline
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual (?none? applies to all media)
 * Computed value: 	specified value, except for floats, root elements and positioned elements; see text
 *
 *
 * TODO do &lt;template&gt; from http://www.w3.org/TR/2010/WD-css3-layout-20100429/#declaring-templates-the-display-property
 *
 */
public class CssDisplay extends org.w3c.css.properties.css.CssDisplay {

    public CssIdent value;
    private static HashMap<String, CssIdent> allowed_values;

    static {
        allowed_values = new HashMap<String, CssIdent>();

        String[] DISPLAY = {
                "inline", "block", "inline-block", "list-item", "run-in",
                "compact", "table", "inline-table", "table-row-group",
                "table-header-group", "table-footer-group", "table-row",
                "table-column-group", "table-column", "table-cell",
                "table-caption", "ruby", "ruby-base", "ruby-text",
                "ruby-base-group", "ruby-text-group", "none"
        };

        for (String aDISPLAY : DISPLAY) {
            allowed_values.put(aDISPLAY, CssIdent.getIdent(aDISPLAY));
        }
    }

    /**
     * Create a new CssDisplay
     */
    public CssDisplay() {
        // nothing to do
    }

    /**
     * Create a new CssDisplay
     *
     * @param ac         The context
     * @param expression The expression for this property
     * @param check      true if explicit check is needed
     * @throws org.w3c.css.util.InvalidParamException
     *          Values are incorect
     */
    public CssDisplay(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) {
            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);
    }

    public CssDisplay(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();
    }

    /**
     * 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 == inline);
    }

}
Received on Wednesday, 31 August 2011 18:34:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:46 UTC