- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 10 Oct 2012 07:47:32 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser In directory hutz:/tmp/cvs-serv7462 Modified Files: AtRule.java CssErrorToken.java CssPropertyFactory.java Added Files: AtRuleKeyframes.java Log Message: allow empty prefix to match all properties from an @rule Index: CssErrorToken.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssErrorToken.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssErrorToken.java 14 Sep 2005 15:14:18 -0000 1.4 +++ CssErrorToken.java 10 Oct 2012 07:47:30 -0000 1.5 @@ -7,83 +7,73 @@ package org.w3c.css.parser; -import java.util.Vector; +import org.w3c.css.parser.analyzer.ParseException; +import org.w3c.css.parser.analyzer.Token; + +import java.util.ArrayList; /** * @version $Revision$ */ public class CssErrorToken extends CssError { - /** - * The list of context when the error appears - */ - Vector context; - - /** - * the property name - */ - String property; - - /** - * the string description of the error - */ - String errorString; - - /** - * the expected text - */ - String[] expectedTokens; + /** + * the property name + */ + String property; - /** - * the skipped text - */ - String skippedString; + /** + * the expected text + */ + String[] expectedTokens; - /** - * Create a new CssErrorToken. - * - * @param lin The line number - * @param error The string description of the error - * @param expected The expected text - */ - CssErrorToken(int lin, String error, String[] expected) { - line = lin; - errorString = error; - expectedTokens = expected; - } + /** + * the token in error + */ + String errorToken; + /** + * the skipped text + */ + String skippedString; - /** - * Get contexts - */ - public Vector getContexts() { - return context; - } + public CssErrorToken(ParseException ex, String skippedString) { + Token errtoken = ex.currentToken; + this.skippedString = skippedString; + line = errtoken.next.beginLine; + ArrayList<String> expected = new ArrayList<String>(); + for (int[] idx : ex.expectedTokenSequences) { + if (idx.length > 0) { + expected.add(ex.tokenImage[idx[0]]); + } + } + expectedTokens = new String[expected.size()]; + expectedTokens = expected.toArray(expectedTokens); + errorToken = errtoken.next.image; + error = ex; + } - /** - * Get the name of the property. - */ - public String getPropertyName() { - return property; - } + /** + * Get the name of the property. + */ + public String getPropertyName() { + return property; + } - /** - * Get the string description of the error. - */ - public String getErrorDescription() { - return errorString; - } + /** + * Get the expected text. + */ + public String[] getExpected() { + return expectedTokens; + } - /** - * Get the expected text. - */ - public String[] getExpected() { - return expectedTokens; - } + /** + * Get the skipped text. + */ + public String getSkippedString() { + return skippedString; + } - /** - * Get the skipped text. - */ - public String getSkippedString() { - return skippedString; - } + public String getErrorToken() { + return errorToken; + } } Index: CssPropertyFactory.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssPropertyFactory.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- CssPropertyFactory.java 4 Oct 2012 13:23:09 -0000 1.34 +++ CssPropertyFactory.java 10 Oct 2012 07:47:30 -0000 1.35 @@ -256,7 +256,9 @@ private String setClassName(AtRule atRule, String media, ApplContext ac, String property) { String className; - if (atRule instanceof AtRuleMedia) { + String prefix = atRule.lookupPrefix(); + + if (prefix.isEmpty() || (atRule instanceof AtRuleMedia)) { className = PropertiesLoader.getProfile(ac.getPropertyKey()).getProperty(property); // a list of media has been specified if (className != null && media != null && !media.equals("all")) { --- NEW FILE: AtRuleKeyframes.java --- // $Id: AtRuleKeyframes.java,v 1.1 2012/10/10 07:47:30 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.parser; public class AtRuleKeyframes extends AtRule { String name = null; public String keyword() { return "keyframes"; } public boolean isEmpty() { return false; } /** * The second must be exactly the same of this one */ public boolean canApply(AtRule atRule) { return false; } /** * The second must only match this one */ public boolean canMatch(AtRule atRule) { return false; } public void setName(String name) { this.name = name; } public String lookupPrefix() { return ""; } /** * Returns a string representation of the object. */ public String toString() { StringBuilder ret = new StringBuilder(); ret.append('@'); ret.append(keyword()); ret.append(' '); ret.append(name); return ret.toString(); } public AtRuleKeyframes(String name) { this.name = name; } } Index: AtRule.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/AtRule.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- AtRule.java 21 Oct 2011 01:49:08 -0000 1.6 +++ AtRule.java 10 Oct 2012 07:47:30 -0000 1.7 @@ -11,27 +11,31 @@ package org.w3c.css.parser; /** + * @author Philippe Le Hegaret * @version $Revision$ - * @author Philippe Le Hegaret */ public abstract class AtRule { - /** - * Returns the at rule keyword - */ - public abstract String keyword(); + /** + * Returns the at rule keyword + */ + public abstract String keyword(); - /** - * The second must be exactly the same of this one - */ - public abstract boolean canApply(AtRule atRule); + /** + * The second must be exactly the same of this one + */ + public abstract boolean canApply(AtRule atRule); - /** - * The second must only match this one - */ - public abstract boolean canMatch(AtRule atRule); + /** + * The second must only match this one + */ + public abstract boolean canMatch(AtRule atRule); - public boolean isEmpty() { - return false; - } + public boolean isEmpty() { + return false; + } + + public String lookupPrefix() { + return keyword(); + } }
Received on Wednesday, 10 October 2012 07:47:33 UTC