Skip to content

Treat starts-with-dash at rules as vendor-prefixed #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 65 additions & 53 deletions org/w3c/css/parser/analyzer/CssParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2295,13 +2295,25 @@ final public void ignoreStatement() throws ParseException {
*/
final public void atRuleDeclaration() throws ParseException {Token n;
n = jj_consume_token(ATKEYWORD);
//ac.getFrame().addWarning("at-rule", token.toString());
ac.getFrame().addError(
new CssError(new InvalidParamException("at-rule",
token, ac)));
if (n.toString().charAt(1) == '-') {
if (ac.getTreatVendorExtensionsAsWarnings()) {
ac.getFrame() //
.addWarning("at-rule", //
n.toString());
} else {
addAtRuleError();
}
} else {
addAtRuleError();
}
skipStatement();
}

void addAtRuleError() throws ParseException {//
ac.getFrame().addError(new CssError(new InvalidParamException( //
"at-rule", token, ac)));
}

/**
* @exception ParseException exception during the parse
*/
Expand Down Expand Up @@ -5295,55 +5307,6 @@ private boolean jj_2_5(int xla)
finally { jj_save(4, xla); }
}

private boolean jj_3R_126()
{
if (jj_scan_token(S)) return true;
return false;
}

private boolean jj_3R_122()
{
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_126()) { jj_scanpos = xsp; break; }
}
if (jj_scan_token(MINUS)) return true;
return false;
}

private boolean jj_3_5()
{
if (jj_3R_125()) return true;
if (jj_scan_token(LPARAN)) return true;
return false;
}

private boolean jj_3R_130()
{
if (jj_3R_138()) return true;
if (jj_3R_129()) return true;
return false;
}

private boolean jj_3R_182()
{
if (jj_3R_127()) return true;
return false;
}

private boolean jj_3_2()
{
if (jj_scan_token(NUMBER)) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_scan_token(21)) { jj_scanpos = xsp; break; }
}
if (jj_scan_token(DIV)) return true;
return false;
}

private boolean jj_3R_125()
{
if (jj_3R_129()) return true;
Expand Down Expand Up @@ -5912,6 +5875,55 @@ private boolean jj_3R_138()
return false;
}

private boolean jj_3R_126()
{
if (jj_scan_token(S)) return true;
return false;
}

private boolean jj_3R_122()
{
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_126()) { jj_scanpos = xsp; break; }
}
if (jj_scan_token(MINUS)) return true;
return false;
}

private boolean jj_3_5()
{
if (jj_3R_125()) return true;
if (jj_scan_token(LPARAN)) return true;
return false;
}

private boolean jj_3R_130()
{
if (jj_3R_138()) return true;
if (jj_3R_129()) return true;
return false;
}

private boolean jj_3R_182()
{
if (jj_3R_127()) return true;
return false;
}

private boolean jj_3_2()
{
if (jj_scan_token(NUMBER)) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_scan_token(21)) { jj_scanpos = xsp; break; }
}
if (jj_scan_token(DIV)) return true;
return false;
}

/** Generated Token Manager. */
public CssParserTokenManager token_source;
SimpleCharStream jj_input_stream;
Expand Down
21 changes: 17 additions & 4 deletions org/w3c/css/parser/analyzer/CssParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1500,14 +1500,27 @@ void atRuleDeclaration() :
{
n=<ATKEYWORD>
{
//ac.getFrame().addWarning("at-rule", token.toString());
ac.getFrame().addError(
new CssError(new InvalidParamException("at-rule",
token, ac)));
if (n.toString().charAt(1) == '-') {
if (ac.getTreatVendorExtensionsAsWarnings()) {
ac.getFrame() //
.addWarning("at-rule", //
n.toString());
} else {
addAtRuleError();
}
} else {
addAtRuleError();
}
skipStatement();
}
}

JAVACODE
void addAtRuleError() { //
ac.getFrame().addError(new CssError(new InvalidParamException( //
"at-rule", token, ac)));
}

/**
* @exception ParseException exception during the parse
*/
Expand Down
1 change: 1 addition & 0 deletions org/w3c/css/util/Messages.properties.en
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ warning.relative: Using relative units gives more robust stylesheets in property

# used by org.w3c.css.css.StyleSheetParser and org.w3c.css.css.StyleSheetXMLParser
error.at-rule: Unrecognized at-rule %s
warning.at-rule: Unrecognized at-rule %s

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