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

2002/css-validator/org/w3c/css/properties/css2 CssClip.java,NONE,1.1 Css2Style.java,1.17,1.18

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 05 Nov 2012 10:36:15 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1TVK2R-0003cp-VM@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2
In directory hutz:/tmp/cvs-serv13802/css2

Modified Files:
	Css2Style.java 
Added Files:
	CssClip.java 
Log Message:
clip per css1/2/21/3

Index: Css2Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/Css2Style.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Css2Style.java	2 Nov 2012 14:34:26 -0000	1.17
+++ Css2Style.java	5 Nov 2012 10:36:13 -0000	1.18
@@ -9,6 +9,7 @@
 import org.w3c.css.parser.CssSelectors;
 import org.w3c.css.properties.aural.ACssStyle;
 import org.w3c.css.properties.css.CssBottom;
+import org.w3c.css.properties.css.CssClip;
 import org.w3c.css.properties.css.CssCursor;
 import org.w3c.css.properties.css.CssLeft;
 import org.w3c.css.properties.css.CssMarkerOffset;
@@ -70,6 +71,7 @@
 	public CssOutline cssOutline;
 	public CssCursor cssCursor;
 
+	public CssClip cssClip;
 	public CssMarkerOffset cssMarkerOffset;
 
 	/**
@@ -318,6 +320,20 @@
 		return cssMarkerOffset;
 	}
 
+
+	/**
+	 * Get the clip property
+	 */
+	public final CssClip getClip() {
+		if (cssClip == null) {
+			cssClip =
+					(CssClip) style.CascadingOrder(new CssClip(),
+							style, selector);
+		}
+		return cssClip;
+	}
+
+
 	/**
 	 * Find conflicts in this Style
 	 *

--- NEW FILE: CssClip.java ---
// $Id: CssClip.java,v 1.1 2012/11/05 10:36:13 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css2;

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.CssFunction;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

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

/**
 * @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/visufx.html#clipping
 */
public class CssClip extends org.w3c.css.properties.css.CssClip {

	public static final CssIdent auto = CssIdent.getIdent("auto");

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

	/**
	 * Creates a new CssClip
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssClip(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_FUNCTION:
				CssFunction func = (CssFunction) val;
				String funcname = func.getName().toLowerCase();
				if (!funcname.equals("rect")) {
					throw new InvalidParamException("shape", val,
							getPropertyName(), ac);
				}
				checkShape(ac, func.getParameters(), this);
				value = val;
				break;
			case CssTypes.CSS_IDENT:
				if (inherit.equals(val)) {
					value = inherit;
					break;
				} else if (auto.equals(inherit)) {
					value = auto;
					break;
				}
				// let if fail.
			default:
				throw new InvalidParamException("value", val,
						getPropertyName(), ac);
		}
	}

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

	static void checkShape(ApplContext ac, CssExpression expression,
						   CssProperty caller) throws InvalidParamException {
		if (expression.getCount() < 4) {
			throw new InvalidParamException("few-value", caller.getPropertyName(), ac);
		}
		if (expression.getCount() > 4) {
			throw new InvalidParamException("unrecognize", ac);
		}
		CssValue val;
		char op, firstop;
		firstop = expression.getOperator();
		if (firstop == SPACE) {
			// we add a warning for SPACE
			ac.getFrame().addWarning("shape-separator");
		}
		for (int i = 0; i < 4; i++) {
			val = expression.getValue();
			op = expression.getOperator();
			switch (val.getType()) {
				case CssTypes.CSS_NUMBER:
					val.getLength();
				case CssTypes.CSS_LENGTH:
					break;
				case CssTypes.CSS_IDENT:
					if (auto.equals(val)) {
						break;
					}
				default:
					throw new InvalidParamException("value",
							val.toString(),
							caller.getPropertyName(), ac);
			}
			expression.next();
			// as the spec was unclear, we allow comma or space
			// but no mix of the two
			if ((op != firstop) || (op != COMMA && op != SPACE)) {
				throw new InvalidParamException("shape-separator",
						((new Character(op)).toString()), ac);
			}
		}
	}
}
Received on Monday, 5 November 2012 10:36:17 UTC

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