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

2002/css-validator/org/w3c/css/values CssImage.java,NONE,1.1 CssColor.java,1.24,1.25 CssTypes.java,1.7,1.8

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 07 Nov 2012 15:46:40 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1TW7pw-0000dy-Fm@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv2460

Modified Files:
	CssColor.java CssTypes.java 
Added Files:
	CssImage.java 
Log Message:
image, first steps (image) TODO gradients

Index: CssTypes.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssTypes.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssTypes.java	18 Oct 2012 09:39:52 -0000	1.7
+++ CssTypes.java	7 Nov 2012 15:46:38 -0000	1.8
@@ -27,6 +27,7 @@
     public static final int CSS_RATIO         = 14;
     public static final int CSS_SWITCH        = 15;
 	public static final int CSS_HASH_IDENT    = 16;
+	public static final int CSS_IMAGE         = 17;
 
     // not generated by the parser
     public static final int CSS_VALUE_LIST    = 20;

Index: CssColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssColor.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- CssColor.java	7 Nov 2012 14:28:35 -0000	1.24
+++ CssColor.java	7 Nov 2012 15:46:38 -0000	1.25
@@ -269,7 +269,7 @@
     /**
      * Parse an ident color.
      */
-    private void setIdentColor(String s, ApplContext ac)
+    protected void setIdentColor(String s, ApplContext ac)
             throws InvalidParamException {
         String lower_s = s.toLowerCase();
         switch (ac.getCssVersion()) {

--- NEW FILE: CssImage.java ---
// $Id: CssImage.java,v 1.1 2012/11/07 15:46:38 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.values;

import org.w3c.css.util.ApplContext;
import org.w3c.css.util.CssVersion;
import org.w3c.css.util.InvalidParamException;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.COMMA;

/**
 * @author CSS3 Image
 */
public class CssImage extends CssValue {

	public static final int type = CssTypes.CSS_IMAGE;

	public final int getType() {
		return type;
	}

	String name;
	CssValue value;

	private String _cache;

	/**
	 * Set the value of this function
	 *
	 * @param s  the string representation of the frequency.
	 * @param ac For errors and warnings reports.
	 */
	public void set(String s, ApplContext ac) {
		// @@TODO
	}


	public void setImageList(CssExpression exp, ApplContext ac)
			throws InvalidParamException {
		name = "image";
		_cache = null;
		// ImageList defined in CSS3 and onward
		if (ac.getCssVersion().compareTo(CssVersion.CSS3) < 0) {
			StringBuilder sb = new StringBuilder();
			sb.append("image(").append(exp.toStringFromStart()).append(')');
			throw new InvalidParamException("notversion", sb.toString(),
					ac.getCssVersionString(), ac);
		}

		CssValue val;
		char op;
		boolean gotcolor = false;
		ArrayList<CssValue> v = new ArrayList<CssValue>();
		CssColor c;
		while (!exp.end()) {
			val = exp.getValue();
			op = exp.getOperator();
			// color is always last
			if (gotcolor) {
				throw new InvalidParamException("value",
						val.toString(),
						"image()", ac);
			}

			switch (val.getType()) {
				case CssTypes.CSS_URL:
				case CssTypes.CSS_STRING:
					v.add(val);
					break;
				case CssTypes.CSS_HASH_IDENT:
					c = new CssColor();
					c.setShortRGBColor(val.toString(), ac);
					v.add(c);
					gotcolor = true;
					break;
				case CssTypes.CSS_IDENT:
					c = new CssColor();
					c.setIdentColor(val.toString(), ac);
					v.add(c);
					gotcolor = true;
					break;
				default:
					throw new InvalidParamException("value",
							val.toString(),
							"image()", ac);
			}
			exp.next();
			if (!exp.end() && op != COMMA) {
				exp.starts();
				throw new InvalidParamException("operator",
						((new Character(op)).toString()), ac);
			}
		}
		value = (v.size() == 1) ? v.get(0) : new CssLayerList(v);
	}

	/**
	 * Returns the value
	 */
	public Object get() {
		// @@TODO
		return null;
	}

	/**
	 * Returns the name of the function
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns a string representation of the object.
	 */
	public String toString() {
		if (_cache == null) {
			StringBuilder sb = new StringBuilder();
			sb.append(name).append('(').append(value).append(')');
			_cache = sb.toString();
		}
		return _cache;
	}

	/**
	 * Compares two values for equality.
	 *
	 * @param other The other value.
	 */
	public boolean equals(Object other) {
		// @@FIXME
		return (other instanceof CssImage &&
				this.name.equals(((CssImage) other).name) &&
				this.value.equals(((CssImage) other).value));
	}
}
Received on Wednesday, 7 November 2012 15:46:47 UTC

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