- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 12 Feb 2009 21:26:37 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser In directory hutz:/tmp/cvs-serv1130/org/w3c/css/parser Modified Files: AtRuleMedia.java CssFouffa.java CssSelectors.java Log Message: pseudo-function handling, per CSS3 selectors rules (note that some construction forbidden by the text are ok according to the grammar, so extra checks are needed) Initial support of namespaces. Index: CssSelectors.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssSelectors.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- CssSelectors.java 12 Feb 2009 10:55:34 -0000 1.26 +++ CssSelectors.java 12 Feb 2009 21:26:34 -0000 1.27 @@ -242,69 +242,15 @@ if(profile == null || profile.equals("") || profile.equals("none")) { profile = ac.getCssVersion(); } - String[] ps = PseudoFactory.getPseudoFunction(profile); if(ps != null) { for(int i = 0; i < ps.length; i++) { if(pseudo.equals(ps[i])) { - if(pseudo.equals("contains")) { - addPseudoFunction( - new PseudoFunctionContains(pseudo, param)); - return; - } - if(pseudo.equals("lang")) { - addPseudoFunction( - new PseudoFunctionLang(pseudo, param)); - return; - } - if(pseudo.equals("not")) { - addPseudoFunction( - new PseudoFunctionNot(pseudo, param)); - return; - } - if(pseudo.equals("nth-child")) { - try { - addPseudoFunction( - new PseudoFunctionNthChild(pseudo, param)); - } - catch(NumberFormatException e) { - throw new InvalidParamException("pseudo", ":" + pseudo, ac); - } - return; - } - if(pseudo.equals("nth-last-child")) { - try { - addPseudoFunction( - new PseudoFunctionNthLastChild( - pseudo, param)); - } - catch(NumberFormatException e) { - throw new InvalidParamException("pseudo", ":" + pseudo, ac); - } - return; - } - if(pseudo.equals("nth-of-type")) { - try { - addPseudoFunction( - new PseudoFunctionNthOfType( - pseudo, param)); - } - catch(NumberFormatException e) { - throw new InvalidParamException("pseudo", ":" + pseudo, ac); - } - return; - } - if(pseudo.equals("nth-last-of-type")) { - try { - addPseudoFunction( - new PseudoFunctionNthLastOfType( - pseudo, param)); - } - catch(NumberFormatException e) { - throw new InvalidParamException("pseudo", ":" + pseudo, ac); - } - return; - } + addPseudoFunction( + PseudoFactory.newPseudoFunction(pseudo, + param, + ac)); + return; } } throw new InvalidParamException("pseudo", ":" + pseudo, ac); Index: AtRuleMedia.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/AtRuleMedia.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- AtRuleMedia.java 10 Dec 2008 15:22:58 -0000 1.12 +++ AtRuleMedia.java 12 Feb 2009 21:26:34 -0000 1.13 @@ -167,5 +167,32 @@ } return ret.toString(); } + + public String getValueString() { + StringBuilder ret = new StringBuilder(); + if (!restrictor.equals("")) { + ret.append(restrictor); + ret.append(' '); + } + boolean f = true; + for (int i = 0; i < media.length; i++) { + if (originalMedia[i] != null) { + if (!f) { + ret.append(','); + ret.append(' '); + } else { + f = false; + } + ret.append(originalMedia[i]); + } + } + + for (int i = 0; i < mediafeatures.size(); i++) { + ret.append(" and ("); + ret.append(mediafeatures.elementAt(i)); + ret.append(')'); + } + return ret.toString(); + } } Index: CssFouffa.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssFouffa.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- CssFouffa.java 4 Feb 2009 15:19:20 -0000 1.44 +++ CssFouffa.java 12 Feb 2009 21:26:34 -0000 1.45 @@ -610,7 +610,8 @@ * added to the storage for the output */ public void newAtRule(AtRule atRule) { - for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) { + for (Enumeration<CssValidatorListener> e = listeners.elements(); + e.hasMoreElements();) { e.nextElement().newAtRule(atRule); } } @@ -623,7 +624,8 @@ * @charset rule that has been found by the parser */ public void addCharSet(String charset) { - for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) { + for (Enumeration<CssValidatorListener> e = listeners.elements(); + e.hasMoreElements();) { e.nextElement().addCharSet(charset); } } @@ -635,7 +637,8 @@ * in it. */ public void endOfAtRule() { - for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) { + for (Enumeration<CssValidatorListener> e = listeners.elements(); + e.hasMoreElements();) { e.nextElement().endOfAtRule(); } } @@ -647,7 +650,8 @@ * true if the rule was declared important in the stylesheet */ public void setImportant(boolean important) { - for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) { + for (Enumeration<CssValidatorListener> e = listeners.elements(); + e.hasMoreElements();) { e.nextElement().setImportant(important); } }
Received on Thursday, 12 February 2009 21:26:48 UTC