- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Sat, 22 Oct 2011 13:36:25 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv31862/css/values Modified Files: CssResolution.java CssTypes.java Added Files: CssRatio.java Log Message: ratio is now a value, as it should --- NEW FILE: CssRatio.java --- // // $Id: CssRatio.java,v 1.1 2011/10/22 13:36:23 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT, ERCIM and Keio, 1997-2010. // 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.InvalidParamException; import org.w3c.css.util.Util; /** * @since CSS3 * @spec http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/#values */ public class CssRatio extends CssValue { public static final int type = CssTypes.CSS_RATIO; public final int getType() { return type; } float w; boolean isWInt; float h; boolean isHInt; /** * Create a new CssRatio. */ public CssRatio() { } /** * Set the value of this ratio. * * @param s the string representation of the ratio. * @param ac For errors and warnings reports. * @throws org.w3c.css.util.InvalidParamException (incorrect format) */ public void set(String s, ApplContext ac) throws InvalidParamException { String sw, sh; s = s.toLowerCase(); int slash = s.indexOf('/'); if (slash == -1) { // invalid ratio throw new InvalidParamException("value", s, ac); } // as we got spaces we need to trim the strings... sw = s.substring(0, slash).trim(); sh = s.substring(slash + 1).trim(); try { w = Integer.parseInt(sw); isWInt = true; } catch (NumberFormatException nex) { try { w = Float.parseFloat(sw); } catch (NumberFormatException ne) { // not an int, not a float... bail out throw new InvalidParamException("value", s, ac); } } // sanity check if (w <= 0.f) { throw new InvalidParamException("strictly-positive", s, ac); } try { h = Integer.parseInt(sh); isHInt = true; } catch (NumberFormatException nex) { try { h = Float.parseFloat(sh); } catch (NumberFormatException ne) { // not an int, not a float... bail out throw new InvalidParamException("value", s, ac); } } // sanity check if (h <= 0.f) { throw new InvalidParamException("strictly-positive", s, ac); } } /** * Returns the current value */ public Object get() { return toString(); } /** * Returns a string representation of the object. */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append((isWInt) ? Integer.toString((int)w): Util.displayFloat(w)); sb.append('/'); sb.append((isHInt) ? Integer.toString((int)h): Util.displayFloat(h)); return sb.toString(); } /** * Compares two values for equality. * * @param value The other value. */ public boolean equals(Object value) { try { CssRatio other = (CssRatio) value; // check that the ratio are the same return (Float.compare(w / h, other.w / other.h) == 0); } catch (ClassCastException cce) { return false; } } } Index: CssResolution.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssResolution.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- CssResolution.java 21 Oct 2011 01:49:13 -0000 1.8 +++ CssResolution.java 22 Oct 2011 13:36:23 -0000 1.9 @@ -13,16 +13,8 @@ import org.w3c.css.util.Util; /** - * <H3> - * Resolution units - * </H3> - * <p/> - * The dpi and dpcm units describe the resolution of an output device i.e. the density of - * the pixels. In dots per inch and dots per centimeter, respectively. These units are only used in the - * resolution media feature. - * </P> - * - * @version $Revision$ + * @since CSS3 + * @spec http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/#values */ public class CssResolution extends CssValue { Index: CssTypes.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssTypes.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssTypes.java 5 Jan 2010 13:50:01 -0000 1.3 +++ CssTypes.java 22 Oct 2011 13:36:23 -0000 1.4 @@ -24,6 +24,7 @@ public static final int CSS_DATE = 11; public static final int CSS_FUNCTION = 12; public static final int CSS_UNICODE_RANGE = 13; + public static final int CSS_RATIO = 14; // not generated by the parser public static final int CSS_VALUE_LIST = 20;
Received on Saturday, 22 October 2011 13:36:32 UTC