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

2002/css-validator/org/w3c/css/properties/css3 CssFlex.java,NONE,1.1 Css3Style.java,1.110,1.111 CssFlexBasis.java,1.1,1.2

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 08 Oct 2012 07:20:50 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1TL7dy-0008I5-SR@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv31803/css3

Modified Files:
	Css3Style.java CssFlexBasis.java 
Added Files:
	CssFlex.java 
Log Message:
added flex per http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#flex

Index: CssFlexBasis.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFlexBasis.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFlexBasis.java	7 Oct 2012 14:45:52 -0000	1.1
+++ CssFlexBasis.java	8 Oct 2012 07:20:48 -0000	1.2
@@ -22,6 +22,13 @@
 
 	public static final CssIdent auto = CssIdent.getIdent("auto");
 
+	public static final CssIdent getAllowedIdent(CssIdent ident) {
+		if (auto.equals(ident)) {
+			return auto;
+		}
+		return null;
+	}
+
 	/**
 	 * Create a new CssFlexBasis
 	 */

--- NEW FILE: CssFlex.java ---
// $Id: CssFlex.java,v 1.1 2012/10/08 07:20:48 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.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.CssNumber;
import org.w3c.css.values.CssOperator;
import org.w3c.css.values.CssPercentage;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.math.BigDecimal;

/**
 * @spec http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#flex
 */
public class CssFlex extends org.w3c.css.properties.css.CssFlexFlow {

	private CssFlexGrow flexGrow;
	private CssFlexShrink flexShrink;
	private CssFlexBasis flexBasis;

	/**
	 * Create a new CssFlexFlow
	 */
	public CssFlex() {
		value = initial;
		flexGrow = new CssFlexGrow();
		flexShrink = new CssFlexShrink();
		flexBasis = new CssFlexBasis();
	}

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

		CssValue growVal = null;
		CssValue shrinkVal = null;
		CssValue basisVal = null;
		CssValue val;
		char op;
		boolean gotNumber = false;

		while (!expression.end()) {
			val = expression.getValue();
			op = expression.getOperator();

			switch (val.getType()) {
				case CssTypes.CSS_IDENT:
					CssIdent ident = (CssIdent) val;
					if (inherit.equals(ident)) {
						value = inherit;
						if (expression.getCount() > 1) {
							throw new InvalidParamException("value",
									val.toString(),
									getPropertyName(), ac);
						}
						break;
					}
					if (none.equals(ident)) {
						value = none;
						if (expression.getCount() > 1) {
							throw new InvalidParamException("value",
									val.toString(),
									getPropertyName(), ac);
						}
						break;
					}
					if (basisVal == null) {
						basisVal = CssFlexBasis.getAllowedIdent(ident);
						if (basisVal == null) {
							throw new InvalidParamException("value",
									val.toString(),
									getPropertyName(), ac);
						}
						gotNumber = false;
						break;
					}
					// unrecognized token...
					throw new InvalidParamException("value",
							val.toString(),
							getPropertyName(), ac);
				case CssTypes.CSS_NUMBER:
					if (growVal == null) {
						CssNumber num = val.getNumber();
						num.checkPositiveness(ac, this);
						growVal = val;
						gotNumber = true;
						break;
					}
					// we can get shrink only after grow
					if (gotNumber && shrinkVal == null) {
						CssNumber num = val.getNumber();
						num.checkPositiveness(ac, this);
						shrinkVal = val;
						break;
					}
					// we got too many number -> fail if not zero...
					// which happens only of basisVal is null
					// and we get a length, so val = 0
					// otherwise it will either fail or flow to default:
				case CssTypes.CSS_LENGTH:
					if (basisVal == null) {
						CssLength l = val.getLength();
						l.checkPositiveness(ac, this);
						basisVal = l;
						break;
					}
				case CssTypes.CSS_PERCENTAGE:
					if (basisVal == null) {
						CssPercentage p = val.getPercentage();
						p.checkPositiveness(ac, this);
						basisVal = p;
						break;
					}
				default:
					throw new InvalidParamException("value",
							val.toString(),
							getPropertyName(), ac);
			}
			if (op != CssOperator.SPACE) {
				throw new InvalidParamException("operator",
						((new Character(op)).toString()), ac);
			}
			expression.next();
		}
		// for addToStyle, redefinitions and equality check
		flexBasis = new CssFlexBasis();
		flexGrow = new CssFlexGrow();
		flexShrink = new CssFlexShrink();
		if (value == inherit) {
			flexBasis.value = inherit;
			flexGrow.value = inherit;
			flexShrink.value = inherit;
		} else if (value == none) {
			flexBasis.value = CssFlexBasis.auto;
			CssNumber z = new CssNumber();
			z.setValue(BigDecimal.ZERO);
			flexGrow.value = z;
			flexShrink.value = z;
		} else {
			CssValueList v = new CssValueList();
			if (growVal != null) {
				v.add(growVal);
				flexGrow.value = growVal;
				if (shrinkVal != null) {
					v.add(shrinkVal);
					flexShrink.value = shrinkVal;
				}
			}
			if (basisVal != null) {
				v.add(basisVal);
				flexBasis.value = basisVal;
			}
			value = v;
		}
	}


	public CssFlex(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);
		flexBasis.addToStyle(ac, style);
		flexGrow.addToStyle(ac, style);
		flexShrink.addToStyle(ac, style);
	}
}


Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- Css3Style.java	7 Oct 2012 14:45:52 -0000	1.110
+++ Css3Style.java	8 Oct 2012 07:20:48 -0000	1.111
@@ -32,6 +32,7 @@
 import org.w3c.css.properties.css.CssColumnSpan;
 import org.w3c.css.properties.css.CssColumnWidth;
 import org.w3c.css.properties.css.CssColumns;
+import org.w3c.css.properties.css.CssFlex;
 import org.w3c.css.properties.css.CssFlexBasis;
 import org.w3c.css.properties.css.CssFlexDirection;
 import org.w3c.css.properties.css.CssFlexFlow;
@@ -162,6 +163,7 @@
 	public CssAlignContent cssAlignContent;
 	public CssAlignItems cssAlignItems;
 	public CssAlignSelf cssAlignSelf;
+	public CssFlex cssFlex;
 	public CssFlexBasis cssFlexBasis;
 	public CssFlexDirection cssFlexDirection;
 	public CssFlexWrap cssFlexWrap;
@@ -1175,6 +1177,15 @@
 		return cssAlignSelf;
 	}
 
+	public CssFlex getFlex() {
+		if (cssFlex == null) {
+			cssFlex =
+					(CssFlex) style.CascadingOrder(
+							new CssFlex(), style, selector);
+		}
+		return cssFlex;
+	}
+
 	public CssFlexBasis getFlexBasis() {
 		if (cssFlexBasis == null) {
 			cssFlexBasis =
Received on Monday, 8 October 2012 07:20:52 UTC

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