Skip to content

Commit 17d3062

Browse files
authored
Merge pull request w3c#103 from w3c/sideshowbarker/at-rule-vendor-prefix-warning
Treat starts-with-dash at rules as vendor-prefixed
2 parents bc0f04b + 6c6dee3 commit 17d3062

File tree

3 files changed

+83
-57
lines changed

3 files changed

+83
-57
lines changed

org/w3c/css/parser/analyzer/CssParser.java

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,13 +2295,25 @@ final public void ignoreStatement() throws ParseException {
22952295
*/
22962296
final public void atRuleDeclaration() throws ParseException {Token n;
22972297
n = jj_consume_token(ATKEYWORD);
2298-
//ac.getFrame().addWarning("at-rule", token.toString());
2299-
ac.getFrame().addError(
2300-
new CssError(new InvalidParamException("at-rule",
2301-
token, ac)));
2298+
if (n.toString().charAt(1) == '-') {
2299+
if (ac.getTreatVendorExtensionsAsWarnings()) {
2300+
ac.getFrame() //
2301+
.addWarning("at-rule", //
2302+
n.toString());
2303+
} else {
2304+
addAtRuleError();
2305+
}
2306+
} else {
2307+
addAtRuleError();
2308+
}
23022309
skipStatement();
23032310
}
23042311

2312+
void addAtRuleError() throws ParseException {//
2313+
ac.getFrame().addError(new CssError(new InvalidParamException( //
2314+
"at-rule", token, ac)));
2315+
}
2316+
23052317
/**
23062318
* @exception ParseException exception during the parse
23072319
*/
@@ -5295,55 +5307,6 @@ private boolean jj_2_5(int xla)
52955307
finally { jj_save(4, xla); }
52965308
}
52975309

5298-
private boolean jj_3R_126()
5299-
{
5300-
if (jj_scan_token(S)) return true;
5301-
return false;
5302-
}
5303-
5304-
private boolean jj_3R_122()
5305-
{
5306-
Token xsp;
5307-
while (true) {
5308-
xsp = jj_scanpos;
5309-
if (jj_3R_126()) { jj_scanpos = xsp; break; }
5310-
}
5311-
if (jj_scan_token(MINUS)) return true;
5312-
return false;
5313-
}
5314-
5315-
private boolean jj_3_5()
5316-
{
5317-
if (jj_3R_125()) return true;
5318-
if (jj_scan_token(LPARAN)) return true;
5319-
return false;
5320-
}
5321-
5322-
private boolean jj_3R_130()
5323-
{
5324-
if (jj_3R_138()) return true;
5325-
if (jj_3R_129()) return true;
5326-
return false;
5327-
}
5328-
5329-
private boolean jj_3R_182()
5330-
{
5331-
if (jj_3R_127()) return true;
5332-
return false;
5333-
}
5334-
5335-
private boolean jj_3_2()
5336-
{
5337-
if (jj_scan_token(NUMBER)) return true;
5338-
Token xsp;
5339-
while (true) {
5340-
xsp = jj_scanpos;
5341-
if (jj_scan_token(21)) { jj_scanpos = xsp; break; }
5342-
}
5343-
if (jj_scan_token(DIV)) return true;
5344-
return false;
5345-
}
5346-
53475310
private boolean jj_3R_125()
53485311
{
53495312
if (jj_3R_129()) return true;
@@ -5912,6 +5875,55 @@ private boolean jj_3R_138()
59125875
return false;
59135876
}
59145877

5878+
private boolean jj_3R_126()
5879+
{
5880+
if (jj_scan_token(S)) return true;
5881+
return false;
5882+
}
5883+
5884+
private boolean jj_3R_122()
5885+
{
5886+
Token xsp;
5887+
while (true) {
5888+
xsp = jj_scanpos;
5889+
if (jj_3R_126()) { jj_scanpos = xsp; break; }
5890+
}
5891+
if (jj_scan_token(MINUS)) return true;
5892+
return false;
5893+
}
5894+
5895+
private boolean jj_3_5()
5896+
{
5897+
if (jj_3R_125()) return true;
5898+
if (jj_scan_token(LPARAN)) return true;
5899+
return false;
5900+
}
5901+
5902+
private boolean jj_3R_130()
5903+
{
5904+
if (jj_3R_138()) return true;
5905+
if (jj_3R_129()) return true;
5906+
return false;
5907+
}
5908+
5909+
private boolean jj_3R_182()
5910+
{
5911+
if (jj_3R_127()) return true;
5912+
return false;
5913+
}
5914+
5915+
private boolean jj_3_2()
5916+
{
5917+
if (jj_scan_token(NUMBER)) return true;
5918+
Token xsp;
5919+
while (true) {
5920+
xsp = jj_scanpos;
5921+
if (jj_scan_token(21)) { jj_scanpos = xsp; break; }
5922+
}
5923+
if (jj_scan_token(DIV)) return true;
5924+
return false;
5925+
}
5926+
59155927
/** Generated Token Manager. */
59165928
public CssParserTokenManager token_source;
59175929
SimpleCharStream jj_input_stream;

org/w3c/css/parser/analyzer/CssParser.jj

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,14 +1500,27 @@ void atRuleDeclaration() :
15001500
{
15011501
n=<ATKEYWORD>
15021502
{
1503-
//ac.getFrame().addWarning("at-rule", token.toString());
1504-
ac.getFrame().addError(
1505-
new CssError(new InvalidParamException("at-rule",
1506-
token, ac)));
1503+
if (n.toString().charAt(1) == '-') {
1504+
if (ac.getTreatVendorExtensionsAsWarnings()) {
1505+
ac.getFrame() //
1506+
.addWarning("at-rule", //
1507+
n.toString());
1508+
} else {
1509+
addAtRuleError();
1510+
}
1511+
} else {
1512+
addAtRuleError();
1513+
}
15071514
skipStatement();
15081515
}
15091516
}
15101517

1518+
JAVACODE
1519+
void addAtRuleError() { //
1520+
ac.getFrame().addError(new CssError(new InvalidParamException( //
1521+
"at-rule", token, ac)));
1522+
}
1523+
15111524
/**
15121525
* @exception ParseException exception during the parse
15131526
*/

org/w3c/css/util/Messages.properties.en

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ warning.relative: Using relative units gives more robust stylesheets in property
186186

187187
# used by org.w3c.css.css.StyleSheetParser and org.w3c.css.css.StyleSheetXMLParser
188188
error.at-rule: Unrecognized at-rule %s
189+
warning.at-rule: Unrecognized at-rule %s
189190

190191
# used by all properties and values
191192
error.operator: %s is an incorrect operator

0 commit comments

Comments
 (0)