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

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

From: CVS User ylafon <cvsmail@w3.org>
Date: Wed, 28 Nov 2012 15:58:54 +0000
Message-Id: <E1Tdk2I-0002Al-Ny@roscoe.w3.org>
To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory roscoe:/tmp/cvs-serv8281/css3

Modified Files:
	Css3Style.java 
Added Files:
	CssImageResolution.java 
Log Message:
image-resolution per http://www.w3.org/TR/2012/CR-css3-images-20120417/#image-resolution

--- /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java	2012/11/28 14:11:08	1.142
+++ /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java	2012/11/28 15:58:54	1.143
@@ -1,6 +1,6 @@
 //
 
-// $Id: Css3Style.java,v 1.142 2012/11/28 14:11:08 ylafon Exp $
+// $Id: Css3Style.java,v 1.143 2012/11/28 15:58:54 ylafon Exp $
 // From Sijtsche de Jong (sy.de.jong@let.rug.nl)
 //
 // COPYRIGHT (c) 1995-2000 World Wide Web Consortium, (MIT, INRIA, Keio University)
@@ -64,6 +64,7 @@
 import org.w3c.css.properties.css.CssHyphens;
 import org.w3c.css.properties.css.CssIcon;
 import org.w3c.css.properties.css.CssImageOrientation;
+import org.w3c.css.properties.css.CssImageResolution;
 import org.w3c.css.properties.css.CssImeMode;
 import org.w3c.css.properties.css.CssJustifyContent;
 import org.w3c.css.properties.css.CssLineBreak;
@@ -232,11 +233,12 @@
 	public CssIcon cssIcon;
 
 	public CssOverflowX cssOverflowX;
-	public CssOverflowY	cssOverflowY;
-	
+	public CssOverflowY cssOverflowY;
+
 	public CssObjectFit cssObjectFit;
 	public CssObjectPosition cssObjectPosition;
 	public CssImageOrientation cssImageOrientation;
+	public CssImageResolution cssImageResolution;
 
 	CssDropInitialAfterAdjust cssDropInitialAfterAdjust;
 	CssDropInitialAfterAlign cssDropInitialAfterAlign;
@@ -1433,6 +1435,15 @@
 		}
 		return cssImageOrientation;
 	}
+
+	public CssImageResolution getImageResolution() {
+		if (cssImageResolution == null) {
+			cssImageResolution =
+					(CssImageResolution) style.CascadingOrder(
+							new CssImageResolution(), style, selector);
+		}
+		return cssImageResolution;
+	}
 	///
 
 	/**

--- /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssImageResolution.java	2012/11/28 15:58:54	NONE
+++ /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssImageResolution.java	2012/11/28 15:58:54	1.1
// $Id: CssImageResolution.java,v 1.1 2012/11/28 15:58:54 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.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 org.w3c.css.values.CssValueList;

import java.util.ArrayList;

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

/**
 * @spec http://www.w3.org/TR/2012/CR-css3-images-20120417/#image-resolution
 */
public class CssImageResolution extends org.w3c.css.properties.css.CssImageResolution {

	public static final CssIdent fromImage = CssIdent.getIdent("from-image");
	public static final CssIdent snap = CssIdent.getIdent("snap");

	/**
	 * Create a new CssImageResolution
	 */
	public CssImageResolution() {
		value = initial;
	}

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

		CssValue val;
		char op;
		CssValue snapVal = null;
		CssValue fromVal = null;
		CssValue resVal = null;

		while (!expression.end()) {
			val = expression.getValue();
			op = expression.getOperator();
			switch (val.getType()) {
				case CssTypes.CSS_RESOLUTION:
					if (resVal != null) {
						throw new InvalidParamException("value", val.toString(),
								getPropertyName(), ac);
					}
					resVal = val;
					break;
				case CssTypes.CSS_IDENT:
					if (inherit.equals(val)) {
						if (expression.getCount() != 1) {
							throw new InvalidParamException("value", inherit,
									getPropertyName(), ac);
						}
						value = inherit;
						break;
					}
					if (fromVal == null) {
						if (fromImage.equals(val)) {
							fromVal = fromImage;
							break;
						}
					}
					if (snapVal == null) {
						if (snap.equals(val)) {
							if ((fromVal != null || resVal != null) && (expression.getRemainingCount() > 1)) {
								// snap can't be between from-image and resolution
								throw new InvalidParamException("value", val.toString(),
										getPropertyName(), ac);
							}
						}
						snapVal = snap;
						break;
					}
				default:
					throw new InvalidParamException("value", val.toString(),
							getPropertyName(), ac);
			}
			if (op != SPACE) {
				throw new InvalidParamException("operator",
						((new Character(op)).toString()), ac);
			}
			expression.next();
		}
		if (value != inherit) {
			// some checks...
			// snap can't be there alone.
			if (snapVal != null && resVal == null && fromVal == null) {
				throw new InvalidParamException("few-value", getPropertyName(), ac);
			}
			ArrayList<CssValue> v = new ArrayList<CssValue>();
			if (fromVal != null) {
				v.add(fromVal);
			}
			if (resVal != null) {
				v.add(resVal);
			}
			if (snapVal != null) {
				v.add(snapVal);
			}
			value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
		}
	}

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

}
Received on Wednesday, 28 November 2012 15:59:03 UTC

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