- From: Julien Grand-Mourcel via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 24 Sep 2007 11:18:50 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer In directory hutz:/tmp/cvs-serv28939/org/w3c/css/parser/analyzer Modified Files: CssParser.jj Log Message: Adding some tests to put nice warnings instead of errors when a property is not in the default profile but in another one when "no special profile" is selected Index: CssParser.jj =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- CssParser.jj 13 Sep 2007 10:09:19 -0000 1.21 +++ CssParser.jj 24 Sep 2007 11:18:47 -0000 1.22 @@ -571,13 +571,15 @@ throw new ParseException( ac.getMsg().getString("parser.charset")); } - // stricter rule for CSS21 and soon for CSS3 - else if("css21".equals(ac.getCssVersion()) && - (!" ".equals(space1Token.image) || (space2Token != null && - !"".equals(space2Token.image)))) { - throw new ParseException(ac.getMsg().getString( + // stricter rule for CSS21 and soon for CSS3 + else if("none".equals(ac.getProfile())) { + ac.getFrame().addWarning("charsetspecial"); + } else if ("css21".equals(ac.getCssVersion()) && + (!" ".equals(space1Token.image) || (space2Token != null && + !"".equals(space2Token.image)))) { + throw new ParseException(ac.getMsg().getString( "parser.charsetspecial")); - } + } else { addCharSet(n.image); } @@ -1175,36 +1177,40 @@ current=simple_selector(null) ( LOOKAHEAD(2) comb=combinator() { - if (ac.getProfile() != null) { - if (ac.getProfile().equals("mobile") || - getAtRule().toString().equals("@media atsc-tv") || - ac.getCssVersion().equals("css1")) { - if (comb == '+') - throw new InvalidParamException("nocomb", "+", ac); - if (comb == '>') - throw new InvalidParamException("nocomb", ">", ac); - } else if (ac.getProfile().equals("tv")) { - if (comb == '+') - throw new InvalidParamException("nocomb", "+", ac); - - } - } - if (!ac.getCssVersion().equals("css3")) { - if (comb == '~') { - throw new InvalidParamException("nocomb", "~", ac); - } - } - switch(comb) { - case '+': - current.addAdjacent(new AdjacentSelector()); - break; - case '>': - current.addChild(new ChildSelector()); - break; - default: - current.addDescendant(new DescendantSelector()); - } - //current.setConnector(comb); + if ("none".equals(ac.getProfile())) { + ac.getFrame().addWarning("nocomb"); + } else { + if (ac.getProfile() != null) { + if (ac.getProfile().equals("mobile") || + getAtRule().toString().equals("@media atsc-tv") || + ac.getCssVersion().equals("css1")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + if (comb == '>') + throw new InvalidParamException("nocomb", ">", ac); + } else if (ac.getProfile().equals("tv")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + } + } + if (!ac.getCssVersion().equals("css3")) { + if (comb == '~') + throw new InvalidParamException("nocomb", "~", ac); + } + } + + } + switch(comb) { + case '+': + current.addAdjacent(new AdjacentSelector()); + break; + case '>': + current.addChild(new ChildSelector()); + break; + default: + current.addDescendant(new DescendantSelector()); + } + //current.setConnector(comb); } current=simple_selector(current) )* ( <S> )* @@ -1400,9 +1406,13 @@ n=<IDENT> { // s.setElement(convertIdent(n.image), ac); s.addType(new TypeSelector(convertIdent(n.image)));} | "*" { - if (!ac.getCssVersion().equals("css1")) { -// s.setElement(null); - s.addUniversal(new UniversalSelector()); + if (!ac.getCssVersion().equals("css1") && !"none".equals(ac.getProfile())) { + if (ac.getCssVersion().equals("css1") && "none".equals(ac.getProfile())) { + ac.getFrame().addWarning("notversion"); + } else { +// s.setElement(null); + s.addUniversal(new UniversalSelector()); + } } else { ac.getFrame().addError(new CssError(new InvalidParamException("notversion", "*", ac.getCssVersion(), ac))); @@ -1500,12 +1510,15 @@ "::" ( ( n=<IDENT> { try { - if (ac.getCssVersion().equals("css3")) { - s.addPseudo(convertIdent(n.image).toLowerCase()); - } else { - throw new InvalidParamException("pseudo-element", ":" + convertIdent(n.image).toLowerCase() , - ac.getCssVersion() ,ac); - } + if (ac.getCssVersion().equals("css3")) { + s.addPseudo(convertIdent(n.image).toLowerCase()); + } else if ("none".equals(ac.getProfile())) { + ac.getFrame().addWarning("pseudo-element"); + } else { + if (true) + throw new InvalidParamException("pseudo-element", + convertIdent(n.image).toLowerCase(), ac.getMsg().getString(ac.getCssVersion()), ac); + } } catch(InvalidParamException e) { //e.printStackTrace(); removeThisRule();
Received on Monday, 24 September 2007 11:19:01 UTC