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

2002/css-validator/org/w3c/css/properties/css3 CssTextDecorationLine.java,NONE,1.1 Css3Style.java,1.57,1.58

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Sat, 01 Sep 2012 16:55:52 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T7qzA-0003iU-Sj@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv14207/css3

Modified Files:
	Css3Style.java 
Added Files:
	CssTextDecorationLine.java 
Log Message:
text-decoration-line per http://www.w3.org/TR/2012/WD-css3-text-20120814/#text-decoration-line0

--- NEW FILE: CssTextDecorationLine.java ---
// $Id: CssTextDecorationLine.java,v 1.1 2012/09/01 16:55:50 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.CssOperator;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.util.ArrayList;

/**
 * @spec http://www.w3.org/TR/2012/WD-css3-text-20120814/#text-decoration-line0
 */
public class CssTextDecorationLine extends org.w3c.css.properties.css.CssTextDecorationLine {

	public static final CssIdent underline, overline, line_through;

	static {
		underline = CssIdent.getIdent("underline");
		overline = CssIdent.getIdent("overline");
		line_through = CssIdent.getIdent("line-through");
	}

	public static final CssIdent getAllowedValue(CssIdent ident) {
		if (underline.equals(ident)) {
			return underline;
		}
		if (overline.equals(ident)) {
			return overline;
		}
		if (line_through.equals(ident)) {
			return line_through;
		}
		return null;
	}

	/**
	 * Create a new CssTextDecorationLine
	 */
	public CssTextDecorationLine() {
		value = initial;
	}

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

		CssValue val;
		char op;

		CssIdent underlineValue = null;
		CssIdent overlineValue = null;
		CssIdent lineThroughValue = null;

		val = expression.getValue();
		op = expression.getOperator();

		if (val.getType() != CssTypes.CSS_IDENT) {
			throw new InvalidParamException("value",
					val.toString(),
					getPropertyName(), ac);
		}

		CssIdent ident = (CssIdent) val;
		if (inherit.equals(ident)) {
			value = inherit;
			if (check && expression.getCount() != 1) {
				throw new InvalidParamException("value",
						val.toString(),
						getPropertyName(), ac);
			}
		} else if (none.equals(ident)) {
			value = none;
			if (check && expression.getCount() != 1) {
				throw new InvalidParamException("value",
						val.toString(),
						getPropertyName(), ac);
			}
		} else {
			int nbgot = 0;
			do {
				if (underlineValue == null && underline.equals(ident)) {
					underlineValue = underline;
				} else if (overlineValue == null && overline.equals(ident)) {
					overlineValue = overline;
				} else if (lineThroughValue == null && line_through.equals(ident)) {
					lineThroughValue = line_through;
				} else {
					throw new InvalidParamException("value",
							val.toString(),
							getPropertyName(), ac);
				}
				nbgot++;
				if (expression.getRemainingCount() == 1 || (!check && nbgot == 3)) {
					// if we have both, exit
					// (needed only if check == false...
					break;
				}
				if (op != CssOperator.SPACE) {
					throw new InvalidParamException("operator",
							((new Character(op)).toString()), ac);
				}
				expression.next();
				val = expression.getValue();
				op = expression.getOperator();
				if (val.getType() != CssTypes.CSS_IDENT) {
					throw new InvalidParamException("value",
							val.toString(),
							getPropertyName(), ac);
				}
				ident = (CssIdent) val;
			} while (!expression.end());
			// now construct the value
			ArrayList<CssValue> v = new ArrayList<CssValue>(nbgot);
			if (underlineValue != null) {
				v.add(underlineValue);
			}
			if (overlineValue != null) {
				v.add(overlineValue);
			}
			if (lineThroughValue != null) {
				v.add(lineThroughValue);
			}
			value = (nbgot > 1) ? new CssValueList(v) : v.get(0);
		}
		expression.next();
	}

	public CssTextDecorationLine(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

}


Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- Css3Style.java	31 Aug 2012 21:12:04 -0000	1.57
+++ Css3Style.java	1 Sep 2012 16:55:50 -0000	1.58
@@ -45,6 +45,7 @@
 import org.w3c.css.properties.css.CssTabSize;
 import org.w3c.css.properties.css.CssTextAlignLast;
 import org.w3c.css.properties.css.CssTextDecorationColor;
+import org.w3c.css.properties.css.CssTextDecorationLine;
 import org.w3c.css.properties.css.CssTextDecorationStyle;
 import org.w3c.css.properties.css.CssTextEmphasisColor;
 import org.w3c.css.properties.css.CssTextEmphasisPosition;
@@ -149,6 +150,7 @@
 	public CssTextJustify cssTextJustify;
 	public CssTextDecorationStyle cssTextDecorationStyle;
 	public CssTextDecorationColor cssTextDecorationColor;
+	public CssTextDecorationLine cssTextDecorationLine;
 	public CssTextEmphasisColor cssTextEmphasisColor;
 	public CssTextEmphasisPosition cssTextEmphasisPosition;
 	public CssTextEmphasisStyle cssTextEmphasisStyle;
@@ -1427,6 +1429,15 @@
 		return cssTextDecorationColor;
 	}
 
+	public CssTextDecorationLine getTextDecorationLine() {
+		if (cssTextDecorationLine == null) {
+			cssTextDecorationLine =
+					(CssTextDecorationLine) style.CascadingOrder(
+							new CssTextDecorationLine(), style, selector);
+		}
+		return cssTextDecorationLine;
+	}
+	
 	public CssTextEmphasisColor getTextEmphasisColor() {
 		if (cssTextEmphasisColor == null) {
 			cssTextEmphasisColor =
Received on Saturday, 1 September 2012 16:55:54 UTC

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