- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 26 Sep 2012 08:43:56 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv695/css3 Added Files: CssMargin.java CssMarginBottom.java CssMarginLeft.java CssMarginRight.java CssMarginTop.java Log Message: margin-* per css1/css2/css21/css3-box --- NEW FILE: CssMarginLeft.java --- // $Id: CssMarginLeft.java,v 1.1 2012/09/26 08:43: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; /** * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#margin-left */ public class CssMarginLeft extends org.w3c.css.properties.css.CssMarginLeft { /** * Create a new CssMarginLeft */ public CssMarginLeft() { value = initial; } /** * Set the value of the property<br/> * Does not check the number of values * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginLeft(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginLeft(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); value = CssMargin.checkValue(ac, expression, check, this); } } --- NEW FILE: CssMarginBottom.java --- // $Id: CssMarginBottom.java,v 1.1 2012/09/26 08:43: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; /** * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#margin-bottom */ public class CssMarginBottom extends org.w3c.css.properties.css.CssMarginBottom { /** * Create a new CssMarginBottom */ public CssMarginBottom() { value = initial; } /** * Set the value of the property<br/> * Does not check the number of values * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginBottom(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginBottom(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); value = CssMargin.checkValue(ac, expression, check, this); } } --- NEW FILE: CssMarginRight.java --- // $Id: CssMarginRight.java,v 1.1 2012/09/26 08:43: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; /** * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#margin-right */ public class CssMarginRight extends org.w3c.css.properties.css.CssMarginRight { /** * Create a new CssMarginRight */ public CssMarginRight() { value = initial; } /** * Set the value of the property<br/> * Does not check the number of values * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginRight(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginRight(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); value = CssMargin.checkValue(ac, expression, check, this); } } --- NEW FILE: CssMargin.java --- // $Id: CssMargin.java,v 1.1 2012/09/26 08:43: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.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.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/2007/WD-css3-box-20070809/#margin1 */ public class CssMargin extends org.w3c.css.properties.css.CssMargin { public static final CssIdent auto = CssIdent.getIdent("auto"); /** * Create a new CssMargin */ public CssMargin() { } /** * Set the value of the property<br/> * Does not check the number of values * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMargin(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMargin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 4) { throw new InvalidParamException("unrecognize", ac); } CssValue val; char op; ArrayList<CssValue> v = new ArrayList<CssValue>(); boolean gotInherit = false; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: CssLength l = val.getLength(); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: v.add(val); break; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { v.add(inherit); gotInherit = true; break; } if (auto.equals(val)) { v.add(auto); break; } // if not inherit, or not an ident // let it flow to the exception default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); } // now we check the number of values... marginBottom = new CssMarginBottom(); marginLeft = new CssMarginLeft(); marginTop = new CssMarginTop(); marginRight = new CssMarginRight(); if (gotInherit) { if (v.size() > 1) { throw new InvalidParamException("unrecognize", ac); } value = inherit; marginBottom.value = inherit; marginTop.value = inherit; marginLeft.value = inherit; marginRight.value = inherit; } else { switch (v.size()) { case 1: marginTop.value = v.get(0); marginRight.value = v.get(0); marginBottom.value = v.get(0); marginLeft.value = v.get(0); break; case 2: marginTop.value = v.get(0); marginRight.value = v.get(1); marginBottom.value = v.get(0); marginLeft.value = v.get(1); break; case 3: marginTop.value = v.get(0); marginRight.value = v.get(1); marginBottom.value = v.get(2); marginLeft.value = v.get(1); break; case 4: marginTop.value = v.get(0); marginRight.value = v.get(1); marginBottom.value = v.get(2); marginLeft.value = v.get(3); break; default: // can't happen unless we are not checking // the size throw new InvalidParamException("unrecognize", ac); } } value = new CssValueList(v); } // for use by individual margin-* properties protected static CssValue checkValue(ApplContext ac, CssExpression expression, boolean check, CssProperty caller) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val; char op; val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: CssLength l = val.getLength(); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: expression.next(); return val; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { expression.next(); return inherit; } if (auto.equals(val)) { expression.next(); return auto; } // if not inherit, or not an ident // let it flow to the exception } throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } } --- NEW FILE: CssMarginTop.java --- // $Id: CssMarginTop.java,v 1.1 2012/09/26 08:43: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; /** * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#margin-top */ public class CssMarginTop extends org.w3c.css.properties.css.CssMarginTop { /** * Create a new CssMarginTop */ public CssMarginTop() { value = initial; } /** * Set the value of the property<br/> * Does not check the number of values * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginTop(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException * The expression is incorrect */ public CssMarginTop(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); value = CssMargin.checkValue(ac, expression, check, this); } }
Received on Wednesday, 26 September 2012 08:44:01 UTC