Skip to content

Commit 5d5b71b

Browse files
committed
handle layer definition in @​import
1 parent afc86d0 commit 5d5b71b

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

org/w3c/css/atrules/css/AtRuleImport.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class AtRuleImport extends AtRule {
2121

2222
boolean is_url = false;
2323
String linkname = null;
24+
AtRuleLayer layer = null;
2425
AtRuleMedia media = null;
2526

2627
public String keyword() {
@@ -64,6 +65,10 @@ public String toString() {
6465
ret.append(linkname);
6566
ret.append('\"');
6667
}
68+
if (layer != null) {
69+
ret.append(' ');
70+
ret.append(layer.getNameString());
71+
}
6772
if (media != null && !media.isEmpty()) {
6873
ret.append(' ');
6974
ret.append(media.getValueString());
@@ -72,10 +77,12 @@ public String toString() {
7277
return ret.toString();
7378
}
7479

75-
public AtRuleImport(String linkname, boolean is_url, AtRuleMedia media) {
76-
this.media = media;
80+
public AtRuleImport(String linkname, boolean is_url,
81+
AtRuleLayer layer, AtRuleMedia media) {
7782
this.linkname = linkname;
7883
this.is_url = is_url;
84+
this.layer = layer;
85+
this.media = media;
7986
}
8087

8188
public String getLinkname() {

org/w3c/css/atrules/css/AtRuleLayer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ public String toString() {
7272
return ret.toString();
7373
}
7474

75+
public String getNameString() {
76+
StringBuilder ret = new StringBuilder();
77+
if (name != null) {
78+
return "layer";
79+
} else {
80+
ret.append("layer(").append(name).append(")");
81+
return ret.toString();
82+
}
83+
}
84+
7585
public String lookupPrefix() {
7686
return "";
7787
}

org/w3c/css/parser/CssFouffa.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package org.w3c.css.parser;
1212

1313
import org.w3c.css.atrules.css.AtRuleImport;
14+
import org.w3c.css.atrules.css.AtRuleLayer;
1415
import org.w3c.css.atrules.css.AtRuleMedia;
1516
import org.w3c.css.atrules.css.AtRuleNamespace;
1617
import org.w3c.css.atrules.css.media.MediaFeature;
@@ -422,9 +423,9 @@ public void handleNamespaceDeclaration(URL url, String prefix,
422423
* @param file the file name in the import statement
423424
*/
424425
public void handleImport(URL url, String file, boolean is_url,
425-
AtRuleMedia media) {
426+
AtRuleLayer layer, AtRuleMedia media) {
426427
// CssError cssError = null;
427-
AtRuleImport importrule = new AtRuleImport(file, is_url, media);
428+
AtRuleImport importrule = new AtRuleImport(file, is_url, layer, media);
428429
newAtRule(importrule);
429430
endOfAtRule();
430431

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ public abstract class CssParser {
236236
* @param url The style sheet where this import statement appears.
237237
* @param file the file name in the import
238238
*/
239-
public abstract void handleImport(URL url, String file,
240-
boolean is_url, AtRuleMedia media);
239+
public abstract void handleImport(URL url, String file, boolean is_url,
240+
AtRuleLayer layer, AtRuleMedia media);
241241

242242
/**
243243
* Call by the namespace declaration statement.
@@ -791,6 +791,7 @@ TOKEN [IGNORE_CASE] :
791791
| <FUNCTIONATTR : "attr(" >
792792
| <FUNCTIONVAR : "var(" >
793793
| <FUNCTIONENV : "env(" >
794+
| <FUNCTIONLAYER : "layer(" >
794795
}
795796

796797
<DEFAULT>
@@ -1029,9 +1030,12 @@ void namespaceDeclaration() :
10291030
void importDeclaration() :
10301031
{Token n;
10311032
AtRuleMedia media = AtRuleMedia.getInstance(ac.getCssVersion());
1033+
AtRuleLayer layer = null;
10321034
CssValue val;
10331035
String importFile;
10341036
boolean is_url = false;
1037+
String layername = "";
1038+
CssVersion version = ac.getCssVersion();
10351039
}
10361040
{
10371041
try {
@@ -1052,10 +1056,31 @@ void importDeclaration() :
10521056
}
10531057
)
10541058
( <S> )*
1059+
( ( "layer" {
1060+
if (version.compareTo(CssVersion.CSS3) < 0) {
1061+
addError(new InvalidParamException("noatruleyet", "", ac),
1062+
skipStatement());
1063+
}
1064+
layer = new AtRuleLayer();
1065+
}
1066+
| ( <FUNCTIONLAYER> ( <S> )* n=<IDENT> {
1067+
if (version.compareTo(CssVersion.CSS3) < 0) {
1068+
addError(new InvalidParamException("noatruleyet", "", ac),
1069+
skipStatement());
1070+
}
1071+
layer = new AtRuleLayer();
1072+
layername = convertIdent(n.image);
1073+
}
1074+
( <DOT> n=<IDENT> {
1075+
layername = layername + "." + convertIdent(n.image);
1076+
} )*
1077+
( <S> )* <RPAREN> {
1078+
layer.setName(convertIdent(n.image));
1079+
} ) ) ( <S> )* )?
10551080
( mediaquerylist(media) )? <SEMICOLON>
10561081
( <S> )*
10571082
{
1058-
handleImport(getURL(), importFile, is_url, media);
1083+
handleImport(getURL(), importFile, is_url, layer, media);
10591084
}
10601085
} catch (ParseException e) {
10611086
addError(e, skipStatement());

0 commit comments

Comments
 (0)