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

2002/css-validator/org/w3c/css/properties/css3 CssTransition.java,NONE,1.1 Css3Style.java,1.100,1.101 CssTransitionDelay.java,1.1,1.2 CssTransitionProperty.java,1.2,1.3 CssTransitionTimingFunction.java,1.2,1.3

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 04 Oct 2012 10:26:23 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1TJidL-0001TB-FR@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv5583/css3

Modified Files:
	Css3Style.java CssTransitionDelay.java 
	CssTransitionProperty.java CssTransitionTimingFunction.java 
Added Files:
	CssTransition.java 
Log Message:
transition per http://www.w3.org/TR/2012/WD-css3-transitions-20120403/#transition

Index: CssTransitionTimingFunction.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssTransitionTimingFunction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssTransitionTimingFunction.java	3 Oct 2012 15:18:51 -0000	1.2
+++ CssTransitionTimingFunction.java	4 Oct 2012 10:26:21 -0000	1.3
@@ -44,7 +44,7 @@
 		end = CssIdent.getIdent("end");
 	}
 
-	public CssIdent getAllowedIdent(CssIdent ident) {
+	public static CssIdent getAllowedIdent(CssIdent ident) {
 		for (CssIdent id : allowed_values) {
 			if (id.equals(ident)) {
 				return id;
@@ -82,21 +82,9 @@
 			op = expression.getOperator();
 			switch (val.getType()) {
 				case CssTypes.CSS_FUNCTION:
-					CssFunction function = (CssFunction) val;
-					String fname = function.getName().toLowerCase();
-					if (steps_func.equals(fname)) {
-						parseStepsFunction(ac, function.getParameters(), this);
-						values.add(val);
-						break;
-					} else if (cubic_bezier_func.equals(fname)) {
-						parseCubicBezierFunction(ac, function.getParameters(), this);
-						values.add(val);
-						break;
-					}
-					// unrecognized function
-					throw new InvalidParamException("value",
-							val.toString(),
-							getPropertyName(), ac);
+					parseFunctionValues(ac, val, this);
+					values.add(val);
+					break;
 				case CssTypes.CSS_IDENT:
 					if (inherit.equals(val)) {
 						singleVal = true;
@@ -228,5 +216,21 @@
 		}
 		return new CssLayerList(values);
 	}
+
+	protected static CssValue parseFunctionValues(ApplContext ac, CssValue func, CssProperty caller)
+			throws InvalidParamException {
+		CssFunction function = (CssFunction) func;
+		String fname = function.getName().toLowerCase();
+		if (steps_func.equals(fname)) {
+			return parseStepsFunction(ac, function.getParameters(), caller);
+		} else if (cubic_bezier_func.equals(fname)) {
+			return parseCubicBezierFunction(ac, function.getParameters(), caller);
+		}
+		// unrecognized function
+		throw new InvalidParamException("value",
+				func.toString(),
+				caller.getPropertyName(), ac);
+
+	}
 }
 

Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- Css3Style.java	3 Oct 2012 15:11:04 -0000	1.100
+++ Css3Style.java	4 Oct 2012 10:26:21 -0000	1.101
@@ -61,6 +61,7 @@
 import org.w3c.css.properties.css.CssTextEmphasisStyle;
 import org.w3c.css.properties.css.CssTextJustify;
 import org.w3c.css.properties.css.CssTextUnderlinePosition;
+import org.w3c.css.properties.css.CssTransition;
 import org.w3c.css.properties.css.CssTransitionDelay;
 import org.w3c.css.properties.css.CssTransitionDuration;
 import org.w3c.css.properties.css.CssTransitionProperty;
@@ -141,6 +142,7 @@
 	public CssMarqueePlayCount cssMarqueePlayCount;
 	public CssOverflowStyle cssOverflowStyle;
 
+	public CssTransition cssTransition;
 	public CssTransitionDelay cssTransitionDelay;
 	public CssTransitionDuration cssTransitionDuration;
 	public CssTransitionProperty cssTransitionProperty;
@@ -1112,6 +1114,17 @@
 		}
 		return cssTransitionTimingFunction;
 	}
+
+
+	public CssTransition getTransition() {
+		if (cssTransition == null) {
+			cssTransition =
+					(CssTransition) style.CascadingOrder(
+							new CssTransition(), style, selector);
+		}
+		return cssTransition;
+	}
+	
 	///
 
 	/**

--- NEW FILE: CssTransition.java ---
// $Id: CssTransition.java,v 1.1 2012/10/04 10:26:21 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.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.CssLayerList;
import org.w3c.css.values.CssTime;
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.COMMA;
import static org.w3c.css.values.CssOperator.SPACE;

/**
 * @spec http://www.w3.org/TR/2012/WD-css3-transitions-20120403/#transition
 */
public class CssTransition extends org.w3c.css.properties.css.CssTransition {

	CssTransitionProperty cssTransitionProperty = null;
	CssTransitionTimingFunction cssTransitionTimingFunction = null;
	CssTransitionDelay cssTransitionDelay = null;
	CssTransitionDuration cssTransitionDuration = null;

	/**
	 * Create a new CssTransition
	 */
	public CssTransition() {
		value = initial;
		cssTransitionDelay = new CssTransitionDelay();
		cssTransitionDuration = new CssTransitionDuration();
		cssTransitionProperty = new CssTransitionProperty();
		cssTransitionTimingFunction = new CssTransitionTimingFunction();
	}

	/**
	 * Creates a new CssTransition
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssTransition(ApplContext ac, CssExpression expression, boolean check)
			throws InvalidParamException {
		setByUser();
		CssValue val;
		ArrayList<CssValue> values;
		CssExpression single_layer = null;
		char op;

		values = new ArrayList<CssValue>();
		// we just accumulate values and check at validation
		while (!expression.end()) {
			val = expression.getValue();
			op = expression.getOperator();

			if (inherit.equals(val)) {
				if (expression.getCount() > 1) {
					throw new InvalidParamException("value", val,
							getPropertyName(), ac);
				}
				value = inherit;
				expression.next();
				return;
			}
			if (single_layer == null) {
				single_layer = new CssExpression();
			}
			// we will check later
			single_layer.addValue(val);
			single_layer.setOperator(op);
			expression.next();

			if (!expression.end()) {
				// incomplete value followed by a comma... it's complete!
				if (op == COMMA) {
					single_layer.setOperator(SPACE);
					values.add(checkLayer(ac, single_layer, this));
					single_layer = null;
				} else if ((op != SPACE)) {
					throw new InvalidParamException("operator",
							((new Character(op)).toString()), ac);
				}
			}
		}
		// if we reach the end in a value that can come in pair
		if (single_layer != null) {
			values.add(checkLayer(ac, single_layer, this));
		}
		if (values.size() == 1) {
			value = values.get(0);
			CssTransitionValue v = (CssTransitionValue) value;
			if (v.delay != null) {
				cssTransitionDelay = new CssTransitionDelay();
				cssTransitionDelay.value = v.delay;
			}
			if (v.duration != null) {
				cssTransitionDuration = new CssTransitionDuration();
				cssTransitionDuration.value = v.duration;
			}
			if (v.property != null) {
				cssTransitionProperty = new CssTransitionProperty();
				cssTransitionProperty.value = v.property;
			}
			if (v.timingfunc != null) {
				cssTransitionTimingFunction = new CssTransitionTimingFunction();
				cssTransitionTimingFunction.value = v.timingfunc;
			}
		} else {
			// if we have multiple layers, none can't be present
			for (CssValue tv : values) {
				CssTransitionValue rtv = (CssTransitionValue) tv;
				if (rtv.property == none) {
					throw new InvalidParamException("value", none,
							getPropertyName(), ac);
				}
			}
			// TODO explode the layers for addToStyle...
			value = new CssLayerList(values);
		}
	}

	public CssTransition(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) {
		super.addToStyle(ac, style);
		if (cssTransitionDelay != null) {
			cssTransitionDelay.addToStyle(ac, style);
		}
		if (cssTransitionDuration != null) {
			cssTransitionDuration.addToStyle(ac, style);
		}
		if (cssTransitionProperty != null) {
			cssTransitionProperty.addToStyle(ac, style);
		}
		if (cssTransitionTimingFunction != null) {
			cssTransitionTimingFunction.addToStyle(ac, style);
		}
	}

	private CssTransitionValue checkLayer(ApplContext ac,
										  CssExpression expression,
										  CssProperty caller)
			throws InvalidParamException {
		CssTransitionValue v = new CssTransitionValue();
		// here we know we have the right operator, we just need to check
		// everything else.
		if (expression.getCount() > 4) {
			throw new InvalidParamException("unrecognize", ac);
		}
		CssValue val;
		while (!expression.end()) {
			val = expression.getValue();
			switch (val.getType()) {
				case CssTypes.CSS_TIME:
					if (v.duration == null) {
						// we got a duration (first parsable time)
						CssTime t = val.getTime();
						t.warnPositiveness(ac, this);
						v.duration = val;
						break;
					}
					if (v.delay == null) {
						v.delay = val;
						break;
					}
					// we already got two times => exit
					throw new InvalidParamException("value",
							val.toString(),
							caller.getPropertyName(), ac);
				case CssTypes.CSS_FUNCTION:
					if (v.timingfunc == null) {
						CssTransitionTimingFunction.parseFunctionValues(ac, val, this);
						v.timingfunc = val;
						break;
					}
					// unknown function
					throw new InvalidParamException("value",
							val.toString(),
							caller.getPropertyName(), ac);
				case CssTypes.CSS_IDENT:
					CssIdent ident = (CssIdent) val;
					if (inherit.equals(ident)) {
						if (expression.getCount() != 1) {
							throw new InvalidParamException("unrecognize", ac);
						}
						v.property = inherit;
						break;
					}
					if (v.timingfunc == null) {
						CssIdent match = CssTransitionTimingFunction.getAllowedIdent(ident);
						if (match != null) {
							v.timingfunc = match;
							break;
						}
					}
					if (v.property == null) {
						v.property = CssTransitionProperty.getAllowedIdent(ac, ident);
						break;
					}
					// already set, let it fail
				default:
					throw new InvalidParamException("value",
							val.toString(),
							caller.getPropertyName(), ac);
			}
			expression.next();
		}
		return v;
	}

	private class CssTransitionValue extends CssValueList {

		CssValue delay = null;
		CssValue duration = null;
		CssValue property = null;
		CssValue timingfunc = null;

		public String toString() {
			boolean doneFirst = false;
			StringBuilder sb = new StringBuilder();
			if (property != null) {
				sb.append(property);
				doneFirst = true;
			}
			if (duration != null) {
				if (doneFirst) {
					sb.append(' ');
				}
				sb.append(duration);
				doneFirst = true;
				if (delay != null) {
					sb.append(' ').append(delay);
				}
			}
			if (timingfunc != null) {
				if (doneFirst) {
					sb.append(' ');
				}
				sb.append(timingfunc);
			}
			return sb.toString();
		}
	}
}


Index: CssTransitionProperty.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssTransitionProperty.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssTransitionProperty.java	3 Oct 2012 12:03:46 -0000	1.2
+++ CssTransitionProperty.java	4 Oct 2012 10:26:21 -0000	1.3
@@ -24,6 +24,7 @@
 public class CssTransitionProperty extends org.w3c.css.properties.css.CssTransitionProperty {
 
 	public static final CssIdent all = CssIdent.getIdent("all");
+
 	/**
 	 * Create a new CssTransitionProperty
 	 */
@@ -31,6 +32,19 @@
 		value = initial;
 	}
 
+	public static CssIdent getAllowedIdent(ApplContext ac, CssIdent ident) {
+		if (none.equals(ident)) {
+			return none;
+		}
+		if (all.equals(ident)) {
+			return all;
+		}
+		if (PropertiesLoader.getProfile(ac.getPropertyKey()).getProperty(ident.toString()) == null) {
+			ac.getFrame().addWarning("noexproperty", ident.toString());
+		}
+		return ident;
+	}
+
 	/**
 	 * Creates a new CssTransitionProperty
 	 *
@@ -57,17 +71,13 @@
 						singleVal = true;
 						sValue = inherit;
 						values.add(inherit);
-					} else if (none.equals(val)) {
-						singleVal = true;
-						sValue = none;
-						values.add(none);
-					} else if (all.equals(val)) {
-						values.add(all);
 					} else {
-						if (PropertiesLoader.getProfile(ac.getPropertyKey()).getProperty(val.toString()) == null) {
-							ac.getFrame().addWarning("noexproperty", val.toString());
+						CssIdent ident = getAllowedIdent(ac, (CssIdent) val);
+						if (ident == none) {
+							singleVal = true;
+							sValue = none;
 						}
-						values.add(val);
+						values.add(ident);
 					}
 					break;
 				default:
Received on Thursday, 4 October 2012 10:26:27 UTC

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