- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 08 Oct 2012 08:56:13 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv32088/css3
Modified Files:
Css3Style.java
Added Files:
CssAnimationTimingFunction.java
Log Message:
animation-timing-function per http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-timing-function
Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- Css3Style.java 8 Oct 2012 08:46:53 -0000 1.113
+++ Css3Style.java 8 Oct 2012 08:56:11 -0000 1.114
@@ -16,6 +16,7 @@
import org.w3c.css.properties.css.CssAlignSelf;
import org.w3c.css.properties.css.CssAnimationDelay;
import org.w3c.css.properties.css.CssAnimationDuration;
+import org.w3c.css.properties.css.CssAnimationTimingFunction;
import org.w3c.css.properties.css.CssBackgroundClip;
import org.w3c.css.properties.css.CssBackgroundOrigin;
import org.w3c.css.properties.css.CssBackgroundSize;
@@ -164,6 +165,7 @@
public CssAnimationDelay cssAnimationDelay;
public CssAnimationDuration cssAnimationDuration;
+ public CssAnimationTimingFunction cssAnimationTimingFunction;
public CssAlignContent cssAlignContent;
public CssAlignItems cssAlignItems;
@@ -1126,7 +1128,16 @@
}
return cssAnimationDuration;
}
-
+
+ public CssAnimationTimingFunction getAnimationTimingFunction() {
+ if (cssAnimationTimingFunction == null) {
+ cssAnimationTimingFunction =
+ (CssAnimationTimingFunction) style.CascadingOrder(
+ new CssAnimationTimingFunction(), style, selector);
+ }
+ return cssAnimationTimingFunction;
+ }
+
public CssTransitionDelay getTransitionDelay() {
if (cssTransitionDelay == null) {
cssTransitionDelay =
--- NEW FILE: CssAnimationTimingFunction.java ---
// $Id: CssAnimationTimingFunction.java,v 1.1 2012/10/08 08:56:11 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.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.CssLayerList;
import org.w3c.css.values.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import java.util.ArrayList;
import static org.w3c.css.values.CssOperator.COMMA;
/**
* @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-timing-function
*/
public class CssAnimationTimingFunction extends org.w3c.css.properties.css.CssAnimationTimingFunction {
public static final CssIdent[] allowed_values;
public static final String steps_func = "steps";
public static final String cubic_bezier_func = "cubic-bezier";
public static final CssIdent start;
public static final CssIdent end;
static {
String[] _allowed_values = {"ease", "linear", "ease-in",
"ease-out", "ease-in-out", "step-start", "step-end"};
allowed_values = new CssIdent[_allowed_values.length];
int i = 0;
for (String s : _allowed_values) {
allowed_values[i++] = CssIdent.getIdent(s);
}
// for 'steps function
start = CssIdent.getIdent("start");
end = CssIdent.getIdent("end");
}
public static CssIdent getAllowedIdent(CssIdent ident) {
for (CssIdent id : allowed_values) {
if (id.equals(ident)) {
return id;
}
}
return null;
}
/**
* Create a new CssAnimationTimingFunction
*/
public CssAnimationTimingFunction() {
value = initial;
}
/**
* Creates a new CssAnimationTimingFunction
*
* @param expression The expression for this property
* @throws org.w3c.css.util.InvalidParamException
* Expressions are incorrect
*/
public CssAnimationTimingFunction(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
setByUser();
CssValue val;
char op;
ArrayList<CssValue> values = new ArrayList<CssValue>();
boolean singleVal = false;
CssValue sValue = null;
while (!expression.end()) {
val = expression.getValue();
op = expression.getOperator();
switch (val.getType()) {
case CssTypes.CSS_FUNCTION:
parseFunctionValues(ac, val, this);
values.add(val);
break;
case CssTypes.CSS_IDENT:
if (inherit.equals(val)) {
singleVal = true;
sValue = inherit;
values.add(inherit);
break;
} else {
CssIdent id = getAllowedIdent((CssIdent) val);
if (id != null) {
values.add(id);
break;
}
// if not recognized, let it fail
}
default:
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}
expression.next();
if (!expression.end() && (op != COMMA)) {
throw new InvalidParamException("operator",
((new Character(op)).toString()), ac);
}
}
if (singleVal && values.size() > 1) {
throw new InvalidParamException("value",
sValue.toString(),
getPropertyName(), ac);
}
value = (values.size() == 1) ? values.get(0) : new CssLayerList(values);
}
public CssAnimationTimingFunction(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
// parse and check timing function
// value might be used later... currently ignored
private static CssValue parseStepsFunction(ApplContext ac, CssExpression funcparam, CssProperty caller)
throws InvalidParamException {
CssValue val;
char op;
if (funcparam.getCount() > 2) {
throw new InvalidParamException("unrecognize", ac);
}
ArrayList<CssValue> values = new ArrayList<CssValue>();
val = funcparam.getValue();
op = funcparam.getOperator();
if (val.getType() != CssTypes.CSS_NUMBER) {
throw new InvalidParamException("value",
val.toString(),
caller.getPropertyName(), ac);
}
// we have a number, continue checks
CssNumber number = val.getNumber();
// it must be a >0 integer
number.checkInteger(ac, caller);
number.checkStrictPositiveness(ac, caller);
values.add(val);
funcparam.next();
if (!funcparam.end()) {
// check the second value
if (op != COMMA) {
throw new InvalidParamException("operator",
((new Character(op)).toString()), ac);
}
val = funcparam.getValue();
if (val.getType() != CssTypes.CSS_IDENT) {
throw new InvalidParamException("value",
val.toString(),
caller.getPropertyName(), ac);
}
if (start.equals(val)) {
values.add(start);
} else if (end.equals(val)) {
values.add(end);
} else {
// unrecognized ident
throw new InvalidParamException("value",
val.toString(),
caller.getPropertyName(), ac);
}
funcparam.next();
}
return (values.size() == 1) ? values.get(0) : new CssLayerList(values);
}
private static CssValue parseCubicBezierFunction(ApplContext ac, CssExpression funcparam, CssProperty caller)
throws InvalidParamException {
CssValue val;
char op;
if (funcparam.getCount() > 4) {
throw new InvalidParamException("unrecognize", ac);
}
if (funcparam.getCount() < 4) {
throw new InvalidParamException("few-value", caller.getPropertyName(), ac);
}
ArrayList<CssValue> values = new ArrayList<CssValue>();
for (int i = 0; i < 4; i++) {
val = funcparam.getValue();
op = funcparam.getOperator();
if (val.getType() != CssTypes.CSS_NUMBER) {
throw new InvalidParamException("value",
val.toString(),
caller.getPropertyName(), ac);
}
// we have a number, continue checks
CssNumber number = val.getNumber();
// it must be between 0 and 1 for X [x1,y1,x2,y2]
if ((i & 0x1) == 0) {
number.checkPositiveness(ac, caller);
number.checkLowerEqualThan(ac, 1., caller);
}
values.add(val);
// go to the next item...
funcparam.next();
if (!funcparam.end() && (op != COMMA)) {
throw new InvalidParamException("operator",
((new Character(op)).toString()), ac);
}
}
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);
}
}
Received on Monday, 8 October 2012 08:56:22 UTC