- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 12 Oct 2012 12:41:32 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv26635/css3 Modified Files: Css3Style.java Added Files: CssTransformOrigin.java Log Message: transform-origin per http://www.w3.org/TR/2012/WD-css3-transforms-20120911/#transform-origin Index: Css3Style.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- Css3Style.java 12 Oct 2012 12:28:46 -0000 1.126 +++ Css3Style.java 12 Oct 2012 12:41:29 -0000 1.127 @@ -85,6 +85,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.CssTransformOrigin; import org.w3c.css.properties.css.CssTransformStyle; import org.w3c.css.properties.css.CssTransition; import org.w3c.css.properties.css.CssTransitionDelay; @@ -200,7 +201,8 @@ public CssBackfaceVisibility cssBackfaceVisibility; public CssPerspective cssPerspective; public CssPerspectiveOrigin cssPerspectiveOrigin; - + public CssTransformOrigin cssTransformOrigin; + CssDropInitialAfterAdjust cssDropInitialAfterAdjust; CssDropInitialAfterAlign cssDropInitialAfterAlign; CssDropInitialBeforeAdjust cssDropInitialBeforeAdjust; @@ -1100,7 +1102,7 @@ } return cssAnimation; } - + public CssAnimationDelay getAnimationDelay() { if (cssAnimationDelay == null) { cssAnimationDelay = @@ -1118,7 +1120,7 @@ } return cssAnimationDirection; } - + public CssAnimationDuration getAnimationDuration() { if (cssAnimationDuration == null) { cssAnimationDuration = @@ -1136,7 +1138,7 @@ } return cssAnimationIterationCount; } - + public CssAnimationName getAnimationName() { if (cssAnimationName == null) { cssAnimationName = @@ -1362,6 +1364,16 @@ } return cssPerspectiveOrigin; } + + public CssTransformOrigin getTransformOrigin() { + if (cssTransformOrigin == null) { + cssTransformOrigin = + (CssTransformOrigin) style.CascadingOrder( + new CssTransformOrigin(), style, selector); + } + return cssTransformOrigin; + } + /// /** --- NEW FILE: CssTransformOrigin.java --- // $Id: CssTransformOrigin.java,v 1.1 2012/10/12 12:41:29 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.CssLength; 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/WD-css3-transforms-20120911/#transform-origin */ public class CssTransformOrigin extends org.w3c.css.properties.css.CssTransformOrigin { public static CssIdent[] allowed_values; public static CssIdent center, top, bottom, left, right; static { top = CssIdent.getIdent("top"); bottom = CssIdent.getIdent("bottom"); left = CssIdent.getIdent("left"); right = CssIdent.getIdent("right"); center = CssIdent.getIdent("center"); allowed_values = new CssIdent[5]; allowed_values[0] = top; allowed_values[1] = bottom; allowed_values[2] = left; allowed_values[3] = right; allowed_values[4] = center; } public static CssIdent getMatchingIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; } } return null; } public boolean isVerticalIdent(CssIdent ident) { return top.equals(ident) || center.equals(ident) || bottom.equals(ident); } public boolean isHorizontalIdent(CssIdent ident) { return left.equals(ident) || center.equals(ident) || right.equals(ident); } /** * Create a new CssTransformOrigin */ public CssTransformOrigin() { super(); } /** * Creates a new CssTransformOrigin * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * Values are incorrect */ public CssTransformOrigin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { int nb_val = expression.getCount(); if (check && nb_val > 3) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; ArrayList<CssValue> 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; } // we will check later values.add(val); expression.next(); 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 check(values, ac); value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } // check the value private void check(ArrayList<CssValue> values, ApplContext ac) throws InvalidParamException { int nb_keyword = 0; int nb_values = values.size(); if (nb_values > 3 || nb_values == 0) { throw new InvalidParamException("unrecognize", ac); } // basic check for (CssValue aValue : values) { switch (aValue.getType()) { case CssTypes.CSS_NUMBER: case CssTypes.CSS_LENGTH: CssLength len = aValue.getLength(); break; case CssTypes.CSS_PERCENTAGE: break; case CssTypes.CSS_IDENT: nb_keyword++; break; default: throw new InvalidParamException("value", aValue, getPropertyName(), ac); } } // then we need to ckeck the values if we got two values and // at least one keyword (as restrictions may occur) if (nb_keyword > 0 && nb_values >= 2) { CssValue v = values.get(0); if (v.getType() == CssTypes.CSS_IDENT) { CssIdent id = (CssIdent) v; if (!isHorizontalIdent(id)) { throw new InvalidParamException("value", id, getPropertyName(), ac); } } v = values.get(1); if (v.getType() == CssTypes.CSS_IDENT) { CssIdent id = (CssIdent) v; if (!isVerticalIdent(id)) { throw new InvalidParamException("value", id, getPropertyName(), ac); } } } // if we got 3 values, the last one must be a length // (number 0 has been validated before, so number is admissible) if (nb_values == 3) { CssValue v = values.get(2); if (v.getType() != CssTypes.CSS_LENGTH && v.getType() != CssTypes.CSS_NUMBER) { throw new InvalidParamException("value", v, getPropertyName(), ac); } } } public CssTransformOrigin(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } }
Received on Friday, 12 October 2012 12:41:36 UTC