2002/css-validator/org/w3c/css/properties/css3 Css3Style.java,1.128,1.129 CssBoxSizing.java,1.3,1.4

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv1968/css3

Modified Files:
	Css3Style.java CssBoxSizing.java 
Log Message:
box-sizing per http://www.w3.org/TR/2012/WD-css3-ui-20120117/#box-sizing0

Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- Css3Style.java	12 Oct 2012 14:33:54 -0000	1.128
+++ Css3Style.java	15 Oct 2012 13:36:07 -0000	1.129
@@ -29,6 +29,7 @@
 import org.w3c.css.properties.css.CssBackgroundSize;
 import org.w3c.css.properties.css.CssBoxDecorationBreak;
 import org.w3c.css.properties.css.CssBoxShadow;
+import org.w3c.css.properties.css.CssBoxSizing;
 import org.w3c.css.properties.css.CssBreakAfter;
 import org.w3c.css.properties.css.CssBreakBefore;
 import org.w3c.css.properties.css.CssBreakInside;
@@ -104,7 +105,6 @@
 	CssRubyPosition cssRubyPosition;
 	CssRubyAlign cssRubyAlign;
 	CssRubyOverhang cssRubyOverhang;
-	CssBoxSizing cssBoxSizing;
 	CssResizer cssResizer;
 	CssWritingMode cssWritingMode;
 	CssGlyphOrVert cssGlyphOrVert;
@@ -205,6 +205,8 @@
 	public CssTransformOrigin cssTransformOrigin;
 	public CssTransform cssTransform;
 
+	public CssBoxSizing cssBoxSizing;
+
 	CssDropInitialAfterAdjust cssDropInitialAfterAdjust;
 	CssDropInitialAfterAlign cssDropInitialAfterAlign;
 	CssDropInitialBeforeAdjust cssDropInitialBeforeAdjust;

Index: CssBoxSizing.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBoxSizing.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBoxSizing.java	5 Jan 2010 13:49:50 -0000	1.3
+++ CssBoxSizing.java	15 Oct 2012 13:36:07 -0000	1.4
@@ -1,149 +1,89 @@
-//
 // $Id$
-// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
+// Author: Yves Lafon <ylafon@w3.org>
 //
-// (c) COPYRIGHT 1995-2000  World Wide Web Consortium (MIT, INRIA, Keio University)
-// Please first read the full copyright statement at
-// http://www.w3.org/Consortium/Legal/copyright-software-19980720
-
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
+// Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css3;
 
-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;
 
 /**
- *  <P>
- *  <EM>Value:</EM> content-box || border-box || inherit<BR>
- *  <EM>Initial:</EM>content-box<BR>
- *  <EM>Applies to:</EM>all elements that accept width or height<BR>
- *  <EM>Inherited:</EM>no<BR>
- *  <EM>Percentages:</EM>no<BR>
- *  <EM>Media:</EM>:visual
+ * @spec http://www.w3.org/TR/2012/WD-css3-ui-20120117/#box-sizing0
  */
+public class CssBoxSizing extends org.w3c.css.properties.css.CssBoxSizing {
 
-public class CssBoxSizing extends CssProperty {
-
-    CssValue boxsizing;
-    ApplContext ac;
-
-    CssIdent contentbox = new CssIdent("content-box");
-    CssIdent borderbox = new CssIdent("border-box");
-    CssIdent initial = new CssIdent("initial");
-
-    /**
-     * Create a new CssBoxSizing
-     */
-    public CssBoxSizing() {
-	boxsizing = contentbox;
-    }
-
-    public CssBoxSizing(ApplContext ac, CssExpression expression,
-	    boolean check) throws InvalidParamException {
-
-	setByUser();
-	CssValue val = expression.getValue();
+	private static CssIdent[] allowed_values;
 
-	if (val.equals(contentbox)) {
-	    boxsizing = contentbox;
-	    expression.next();
-	}
-	else if (val.equals(borderbox)) {
-	    boxsizing = borderbox;
-	    expression.next();
-	}
-	else if (val.equals(inherit)) {
-	    boxsizing = inherit;
-	    expression.next();
-	}
-	else if (val.equals(initial)) {
-	    boxsizing = initial;
-	    expression.next();
-	}
-	else {
-	    throw new InvalidParamException("value", expression.getValue(),
-					    getPropertyName(), ac);
+	static {
+		String id_values[] = {"content-box", "padding-box", "border-box"};
+		allowed_values = new CssIdent[id_values.length];
+		int i = 0;
+		for (String s : id_values) {
+			allowed_values[i++] = CssIdent.getIdent(s);
+		}
 	}
-    }
 
-    public CssBoxSizing(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) {
-	if (((Css3Style) style).cssBoxSizing != null)
-	    style.addRedefinitionWarning(ac, this);
-	((Css3Style) style).cssBoxSizing = 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 ((Css3Style) style).getBoxSizing();
-	} else {
-	    return ((Css3Style) style).cssBoxSizing;
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
 	}
-    }
-
-    /**
-     * Compares two properties for equality.
-     *
-     * @param value The other property.
-     */
-    public boolean equals(CssProperty property) {
-	return (property instanceof CssBoxSizing &&
-                boxsizing.equals( ((CssBoxSizing) property).boxsizing));
-    }
 
-    /**
-     * Returns the name of this property
-     */
-    public String getPropertyName() {
-	return "box-sizing";
-    }
+	/**
+	 * Create a new CssBoxSizing
+	 */
+	public CssBoxSizing() {
+		value = initial;
+	}
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-	return boxsizing;
-    }
+	/**
+	 * Creates a new CssBoxSizing
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Expressions are incorrect
+	 */
+	public CssBoxSizing(ApplContext ac, CssExpression expression, boolean check)
+			throws InvalidParamException {
+		setByUser();
+		CssValue val = expression.getValue();
 
-    /**
-     * Returns true if this property is "softly" inherited
-     */
-    public boolean isSoftlyInherited() {
-	return boxsizing.equals(inherit);
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    /**
-     * Returns a string representation of the object
-     */
-    public String toString() {
-	return boxsizing.toString();
-    }
+		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();
+	}
 
-    /**
-     * 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 boxsizing == contentbox;
-    }
+	public CssBoxSizing(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
 }
+

Received on Monday, 15 October 2012 13:36:15 UTC