CVS 2002/css-validator/org/w3c/css/properties/css2

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2
In directory roscoe:/tmp/cvs-serv26416/css2

Modified Files:
	Css2Style.java 
Added Files:
	CssSize.java 
Log Message:
@page size per CSS2/CSS3 http://www.w3.org/TR/2013/WD-css3-page-20130314/#page-size-prop

--- /sources/public/2002/css-validator/org/w3c/css/properties/css2/Css2Style.java	2014/01/30 15:09:53	1.51
+++ /sources/public/2002/css-validator/org/w3c/css/properties/css2/Css2Style.java	2014/04/10 18:14:53	1.52
@@ -1,5 +1,5 @@
 //
-// $Id: Css2Style.java,v 1.51 2014/01/30 15:09:53 ylafon Exp $
+// $Id: Css2Style.java,v 1.52 2014/04/10 18:14:53 ylafon Exp $
 // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
 //
 // (c) COPYRIGHT MIT and INRIA, 1997.
@@ -48,6 +48,7 @@
 import org.w3c.css.properties.css.CssQuotes;
 import org.w3c.css.properties.css.CssRichness;
 import org.w3c.css.properties.css.CssRight;
+import org.w3c.css.properties.css.CssSize;
 import org.w3c.css.properties.css.CssSpeak;
 import org.w3c.css.properties.css.CssSpeakHeader;
 import org.w3c.css.properties.css.CssSpeakNumeral;
@@ -69,7 +70,7 @@
 import org.w3c.css.values.CssIdent;
 
 /**
- * @version $Revision: 1.51 $
+ * @version $Revision: 1.52 $
  */
 public class Css2Style extends Css1Style {
 
@@ -101,6 +102,7 @@
 	public CssPageBreakBefore cssPageBreakBefore;
 	public CssPageBreakInside cssPageBreakInside;
 	public CssMarks cssMarks;
+	public CssSize cssSize;
 
 	/**
 	 * font properties
@@ -269,7 +271,18 @@
 		}
 		return cssMarks;
 	}
-	
+
+	/**
+	 * Get the size property
+	 */
+	public final CssSize getSize() {
+		if (cssSize == null) {
+			cssSize =
+					(CssSize) style.CascadingOrder(new CssSize(),
+							style, selector);
+		}
+		return cssSize;
+	}	
 	/**
 	 * get the font-stretch property
 	 *

--- /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssSize.java	2014/04/10 18:14:53	NONE
+++ /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssSize.java	2014/04/10 18:14:53	1.1
// $Id: CssSize.java,v 1.1 2014/04/10 18:14:53 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang University 2014.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css2;

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 org.w3c.css.values.CssValueList;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.SPACE;

/**
 * @spec 1
 */
public class CssSize extends org.w3c.css.properties.css.CssSize {

	public static final CssIdent[] allowed_values;

	static {
		String[] _allowed_values = {"auto", "portrait", "landscape"};
		int i = 0;
		allowed_values = new CssIdent[_allowed_values.length];
		for (String s : _allowed_values) {
			allowed_values[i++] = CssIdent.getIdent(s);
		}
	}

	public static final CssIdent getAllowedIdent(CssIdent ident) {
		for (CssIdent id : allowed_values) {
			if (id.equals(ident)) {
				return id;
			}
		}
		return null;
	}

	/**
	 * Create a new CssSize
	 */
	public CssSize() {
	}

	/**
	 * Creates a new CssSize
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssSize(ApplContext ac, CssExpression expression, boolean check)
			throws InvalidParamException {
		if (check && expression.getCount() > 2) {
			throw new InvalidParamException("unrecognize", ac);
		}
		setByUser();

		CssValue val;
		char op;

		val = expression.getValue();
		op = expression.getOperator();

		ArrayList<CssValue> vals = new ArrayList<>();

		while (!expression.end()) {
			val = expression.getValue();
			op = expression.getOperator();

			switch (val.getType()) {
				case CssTypes.CSS_NUMBER:
					val = val.getLength();
				case CssTypes.CSS_LENGTH:
					vals.add(val);
					// not in the spec, but size ought to be non-negative
					val.getLength().checkPositiveness(ac, this);
					break;
				case CssTypes.CSS_IDENT:
					if (expression.getCount() > 1) {
						throw new InvalidParamException("unrecognize", ac);
					}
					value = getAllowedIdent((CssIdent) val);
					if (value != null) {
						break;
					}
					// unrecognized ident.. fail!
				default:
					throw new InvalidParamException("value", val,
							getPropertyName(), ac);
			}
			if (op != SPACE) {
				throw new InvalidParamException("operator",
						((new Character(op)).toString()), ac);
			}
			expression.next();
		}
		// set the value if needed (only lengths are added in the ArrayList)
		if (vals.size() != 0) {
			// and set the value (the empty arraylist is taken care of during parsing)
			value = (vals.size() == 1) ? vals.get(0) : new CssValueList(vals);
		}
	}

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

Received on Thursday, 10 April 2014 18:14:54 UTC