- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 05 Sep 2012 11:46:23 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv2910/css3 Modified Files: CssMarqueeSpeed.java Css3Style.java Log Message: marquee-speed per http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-speed Index: Css3Style.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- Css3Style.java 5 Sep 2012 11:41:08 -0000 1.90 +++ Css3Style.java 5 Sep 2012 11:46:21 -0000 1.91 @@ -43,6 +43,7 @@ import org.w3c.css.properties.css.CssHyphens; import org.w3c.css.properties.css.CssLineBreak; import org.w3c.css.properties.css.CssMarqueeDirection; +import org.w3c.css.properties.css.CssMarqueeSpeed; import org.w3c.css.properties.css.CssOpacity; import org.w3c.css.properties.css.CssOverflowWrap; import org.w3c.css.properties.css.CssTabSize; @@ -130,6 +131,7 @@ public CssTabSize cssTabSize; public CssMarqueeDirection cssMarqueeDirection; + public CssMarqueeSpeed cssMarqueeSpeed; CssDropInitialAfterAdjust cssDropInitialAfterAdjust; CssDropInitialAfterAlign cssDropInitialAfterAlign; @@ -169,7 +171,6 @@ CssPaddingRightCSS3 cssPaddingRightCSS3; CssMarquee cssMarquee; CssMarqueeRepetition cssMarqueeRepetition; - CssMarqueeSpeed cssMarqueeSpeed; CssMarqueeStyle cssMarqueeStyle; public org.w3c.css.properties.css.CssBorderImageSource getBorderImageSource() { Index: CssMarqueeSpeed.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssMarqueeSpeed.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssMarqueeSpeed.java 5 Jan 2010 13:49:53 -0000 1.3 +++ CssMarqueeSpeed.java 5 Sep 2012 11:46:21 -0000 1.4 @@ -1,167 +1,88 @@ -// // $Id$ -// From Sijtsche de Jong (sy.de.jong@let.rug.nl) +// Author: Yves Lafon <ylafon@w3.org> // -// (c) COPYRIGHT 1995-2000 World Wide Web Consortium (MIT, INRIA, Keio University) -// Please first read the full copyright statement at -// http://www.w3.org/Consortium/Legal/copyright-software-19980720 - +// (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.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.CssTime; +import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -public class CssMarqueeSpeed extends CssProperty { - - String mspeed; - - static CssIdent slow = new CssIdent("slow"); - static CssIdent normal = new CssIdent("normal"); - static CssIdent fast = new CssIdent("fast"); - static CssIdent initial = new CssIdent("initial"); - - /** - * Create a new CssMarqueeSpeed - */ - public CssMarqueeSpeed() { - mspeed = "normal"; - } +/** + * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-speed + */ +public class CssMarqueeSpeed extends org.w3c.css.properties.css.CssMarqueeSpeed { - /** - * Create a new CssMarqueeSpeed - * - * @param expression The expression for this property - * @exception InvalidParamException Incorrect values - */ - public CssMarqueeSpeed(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - setByUser(); - CssValue val = expression.getValue(); + private static CssIdent[] allowed_values; - if (val.equals(normal)) { - mspeed = "normal"; - expression.next(); - } - else if (val.equals(slow)) { - mspeed = "slow"; - expression.next(); - } - else if (val.equals(initial)) { - mspeed = "initial"; - expression.next(); - } - else if (val.equals(fast)) { - mspeed = "fast"; - expression.next(); + static { + String id_values[] = {"slow", "normal", "fast"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } } - else if (val instanceof CssLength) { - mspeed = val.toString(); - expression.next(); - val = expression.getValue(); - if (val != null) { - if (val instanceof CssTime) { - mspeed = mspeed += " " + val.toString(); - expression.next(); - } else { - throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } } - } - } - else if (val.equals(inherit)) { - mspeed = "inherit"; - expression.next(); - } - else { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); + return null; } - } - - public CssMarqueeSpeed(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) { - if (((Css3Style) style).cssMarqueeSpeed != null) - style.addRedefinitionWarning(ac, this); - ((Css3Style) style).cssMarqueeSpeed = this; - } - - /** - * Get this property in the style. - * - * @param style The style where the property is - * @param resolve if true, resolve the style to find this property - */ - public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { - if (resolve) { - return ((Css3Style) style).getMarqueeSpeed(); - } - else { - return ((Css3Style) style).cssMarqueeSpeed; + /** + * Create a new CssMarqueeSpeed + */ + public CssMarqueeSpeed() { + value = initial; } - } - - /** - * Compares two properties for equality. - * - * @param value The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssMarqueeSpeed && - mspeed.equals(((CssMarqueeSpeed) property).mspeed)); - } - - /** - * Returns the name of this property - */ - public String getPropertyName() { - return "marquee-speed"; - } - /** - * Returns the value of this property - */ - public Object get() { - return mspeed; - } - - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return mspeed.equals(inherit); - } + /** + * Creates a new CssMarqueeSpeed + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssMarqueeSpeed(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); - /** - * Returns a string representation of the object - */ - public String toString() { - return mspeed.toString(); - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - /** - * Is the value of this property a default value - * It is used by alle macro for the function <code>print</code> - */ - public boolean isDefault() { - return mspeed.equals("normal"); - } + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + if (inherit.equals(val)) { + value = inherit; + } else { + val = getMatchingIdent((CssIdent) val); + if (val == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + } + expression.next(); + } + public CssMarqueeSpeed(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } +
Received on Wednesday, 5 September 2012 11:46:29 UTC