- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Sat, 17 Sep 2011 06:02:28 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser In directory hutz:/tmp/cvs-serv24491/css/parser Modified Files: CssFouffa.java CssPropertyFactory.java CssSelectors.java Log Message: better handling of versions and profile, error/warning processing now replacing all %s, error reporting do no longer have duplicate values Index: CssSelectors.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssSelectors.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- CssSelectors.java 14 Sep 2011 16:31:49 -0000 1.32 +++ CssSelectors.java 17 Sep 2011 06:02:26 -0000 1.33 @@ -22,7 +22,6 @@ import org.w3c.css.selectors.attributes.AttributeExact; import org.w3c.css.util.ApplContext; import org.w3c.css.util.CssProfile; -import org.w3c.css.util.CssVersion; import org.w3c.css.util.InvalidParamException; import org.w3c.css.util.Messages; import org.w3c.css.util.Util; @@ -175,14 +174,7 @@ return; } - CssProfile profile = ac.getCssProfile(); - String spec; - if (profile != CssProfile.NONE) { - spec = profile.toString(); - } else { - CssVersion version = ac.getCssVersion(); - spec = version.toString(); - } + String spec = ac.getPropertyKey(); // is it a pseudo-class? String[] ps = PseudoFactory.getPseudoClass(spec); @@ -211,49 +203,31 @@ if (pseudo == null) { return; } - CssProfile profile = ac.getCssProfile(); - String spec; - if (profile != CssProfile.NONE) { - spec = profile.toString(); - } else { - CssVersion version = ac.getCssVersion(); - spec = version.toString(); - } + String spec = ac.getPropertyKey(); // is it a pseudo-element? String[] ps = PseudoFactory.getPseudoElement(spec); if (ps != null) { - for (int i = 0; i < ps.length; i++) { - if (pseudo.equals(ps[i])) { + for (String s : ps) { + if (pseudo.equals(s)) { addPseudoElement(new PseudoElementSelector(pseudo)); return; } } } - // the ident isn't a valid pseudo-something throw new InvalidParamException("pseudo", "::" + pseudo, ac); } public void setPseudoFun(String pseudo, String param) throws InvalidParamException { - CssProfile profile = ac.getCssProfile(); - String spec; - if (profile != CssProfile.NONE) { - spec = profile.toString(); - } else { - CssVersion version = ac.getCssVersion(); - spec = version.toString(); - } + String spec = ac.getPropertyKey(); String[] ps = PseudoFactory.getPseudoFunction(spec); if (ps != null) { - for (int i = 0; i < ps.length; i++) { - if (pseudo.equals(ps[i])) { - addPseudoFunction( - PseudoFactory.newPseudoFunction(pseudo, - param, - ac)); + for (String s : ps) { + if (pseudo.equals(s)) { + addPseudoFunction(PseudoFactory.newPseudoFunction(pseudo, param, ac)); return; } } Index: CssPropertyFactory.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssPropertyFactory.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- CssPropertyFactory.java 14 Sep 2011 16:31:49 -0000 1.27 +++ CssPropertyFactory.java 17 Sep 2011 06:02:26 -0000 1.28 @@ -10,6 +10,7 @@ import org.w3c.css.properties.PropertiesLoader; import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; +import org.w3c.css.util.CssProfile; import org.w3c.css.util.CssVersion; import org.w3c.css.util.InvalidParamException; import org.w3c.css.util.Utf8Properties; @@ -21,7 +22,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.StringTokenizer; -import java.util.Vector; /** * @author Philippe Le Hegaret @@ -52,18 +52,6 @@ /** * Create a new CssPropertyFactory */ - /* - * public CssPropertyFactory(URL url, URL allprop_url) { properties = new - * Utf8Properties(); InputStream f = null; try { f = url.openStream(); - * properties.load(f); } catch (IOException e) { e.printStackTrace(); } - * finally { try { if (f != null) f.close(); } catch (Exception e) { - * e.printStackTrace(); } // ignore } - * // list of all properties allprops = new Utf8Properties(); InputStream - * f_all = null; try { f_all = allprop_url.openStream(); - * allprops.load(f_all); } catch (IOException e) { e.printStackTrace(); } - * finally { try { if (f_all != null) f_all.close(); } catch (Exception e) { - * e.printStackTrace(); } // ignore } } - */ public CssPropertyFactory(String profile) { properties = PropertiesLoader.getProfile(profile); // It's not good to have null properties :-/ @@ -76,17 +64,16 @@ return properties.getProperty(name); } - private Vector<String> getVector(String media) { - Vector<String> list = new Vector<String>(4); - String medium = new String(); + private ArrayList<String> getMediaList(String media) { + ArrayList<String> list = new ArrayList<String>(); + String medium; StringTokenizer tok = new StringTokenizer(media, ","); while (tok.hasMoreTokens()) { medium = tok.nextToken(); medium = medium.trim(); - list.addElement(medium); + list.add(medium); } - return list; } @@ -106,7 +93,7 @@ String media = atRule.toString(); String upmedia = media.toUpperCase(); int pos = -1; - int pos2 = media.toUpperCase().indexOf("AND"); + int pos2 = upmedia.indexOf("AND"); if (pos2 == -1) { pos2 = media.length(); @@ -180,7 +167,6 @@ } media = media.trim(); - classname = setClassName(atRule, media, ac, property); // the property does not exist in this profile @@ -191,15 +177,26 @@ throw new WarningParamException("vendor-extension", property); } ArrayList<String> pfsOk = new ArrayList<String>(); + String spec = ac.getPropertyKey(); for (int i = 0; i < SORTEDPROFILES.length; ++i) { String p = String.valueOf(SORTEDPROFILES[i]); - if (!p.equals(ac.getCssVersionString()) && PropertiesLoader.getProfile(p).containsKey(property)) { + if (!p.equals(spec) && PropertiesLoader.getProfile(p).containsKey(property)) { pfsOk.add(p); } } - if (pfsOk.size() > 0) { + if (ac.getCssProfile() == CssProfile.NONE) { + String latestVersion = pfsOk.get(pfsOk.size()-1); + CssVersion v = CssVersion.resolve(ac, latestVersion); + // should always be true... otherwise there is an issue... + if (v.compareTo(ac.getCssVersion()) > 0) { + ac.getFrame().addWarning("noexistence", new String[] { property, ac.getMsg().getString(ac.getPropertyKey()), pfsOk.toString() }); + ac.setCssVersion(v); + } + classname = setClassName(atRule, media, ac, property); + } else { + /* // This should be uncommented when no-profile in enabled if (ac.getProfileString().equals("none")) { @@ -213,7 +210,8 @@ } else */ - throw new InvalidParamException("noexistence", new String[]{property, ac.getMsg().getString(ac.getCssVersionString()), pfsOk.toString()}, ac); + throw new InvalidParamException("noexistence", new String[]{property, ac.getMsg().getString(ac.getPropertyKey()), pfsOk.toString()}, ac); + } } else { throw new InvalidParamException("noexistence-at-all", property, ac); } @@ -247,21 +245,20 @@ private String setClassName(AtRule atRule, String media, ApplContext ac, String property) { String className; - Vector<String> list = new Vector<String>(getVector(media)); if (atRule instanceof AtRuleMedia) { - className = PropertiesLoader.getProfile(ac.getCssVersionString()).getProperty(property); + className = PropertiesLoader.getProfile(ac.getPropertyKey()).getProperty(property); // a list of media has been specified if (className != null && !media.equals("all")) { String propMedia = PropertiesLoader.mediaProperties.getProperty(property); - for (int i = 0; i < list.size(); i++) { - String medium = list.elementAt(i); + ArrayList<String> list = getMediaList(media); + for (String medium : list) { if (propMedia.indexOf(medium.toLowerCase()) == -1 && !propMedia.equals("all")) { ac.getFrame().addWarning("noexistence-media", new String[]{property, medium + " (" + propMedia + ")"}); } } } } else { - className = PropertiesLoader.getProfile(ac.getCssVersionString()).getProperty("@" + atRule.keyword() + "." + property); + className = PropertiesLoader.getProfile(ac.getPropertyKey()).getProperty("@" + atRule.keyword() + "." + property); } return className; } Index: CssFouffa.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssFouffa.java,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- CssFouffa.java 14 Sep 2011 16:31:49 -0000 1.55 +++ CssFouffa.java 17 Sep 2011 06:02:26 -0000 1.56 @@ -107,15 +107,8 @@ } // load the CssStyle - CssProfile profile = ac.getCssProfile(); + String spec = ac.getPropertyKey(); String classStyle; - String spec; - if (profile != CssProfile.NONE) { - spec = profile.toString(); - } else { - CssVersion version = ac.getCssVersion(); - spec = version.toString(); - } classStyle = PropertiesLoader.config.getProperty(spec); if (classStyle == null) { @@ -226,14 +219,7 @@ + ac.getProfileString()); } - CssProfile profile = ac.getCssProfile(); - String spec; - if (profile != CssProfile.NONE) { - spec = profile.toString(); - } else { - CssVersion version = ac.getCssVersion(); - spec = version.toString(); - } + String spec = ac.getPropertyKey(); // load the CssStyle String classStyle = PropertiesLoader.config.getProperty(spec);
Received on Saturday, 17 September 2011 06:02:34 UTC