Skip to content

Commit 78ebb17

Browse files
committed
Updates #372 to cope with grammar changes, fixes #370
Align to new values of 'contain' based on latest WD of contains-3 https://www.w3.org/TR/2022/WD-css-contain-3-20220818/#contain-property
1 parent b72d7c9 commit 78ebb17

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

org/w3c/css/properties/css3/CssContain.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
/**
2121
* @spec https://www.w3.org/TR/2020/WD-css-contain-2-20201216/#propdef-contain
22+
* @spec https://www.w3.org/TR/2022/WD-css-contain-3-20220818/#contain-property
2223
*/
2324
public class CssContain extends org.w3c.css.properties.css.CssContain {
2425

2526
public static final CssIdent[] allowed_single_values;
2627
public static final CssIdent[] allowed_multiple_values;
2728
public static final CssIdent auto = CssIdent.getIdent("auto");
29+
public static final CssIdent size = CssIdent.getIdent("size");
30+
public static final CssIdent inline_size = CssIdent.getIdent("inline-size");
2831

2932
static {
3033
String[] _allowed_single_values = {"none", "strict", "content"};
@@ -34,7 +37,7 @@ public class CssContain extends org.w3c.css.properties.css.CssContain {
3437
allowed_single_values[i++] = CssIdent.getIdent(s);
3538
}
3639
// "style" added as of css-contain-2 but at-risk
37-
String[] _allowed_multiple_values = {"size", "layout", "paint", "style"};
40+
String[] _allowed_multiple_values = {"size", "inline-size", "layout", "paint", "style"};
3841
i = 0;
3942
allowed_multiple_values = new CssIdent[_allowed_multiple_values.length];
4043
for (String s : _allowed_multiple_values) {
@@ -60,6 +63,10 @@ public static CssIdent getAllowedMultipleIdent(CssIdent ident) {
6063
return null;
6164
}
6265

66+
public static boolean isExclusiveIdent(CssIdent ident) {
67+
return (size.equals(ident) || inline_size.equals(ident));
68+
}
69+
6370
/**
6471
* Create a new CssContain
6572
*/
@@ -79,6 +86,7 @@ public CssContain(ApplContext ac, CssExpression expression, boolean check)
7986
char op;
8087
CssIdent id, ident;
8188
boolean got_single = false;
89+
boolean got_exclusive = false;
8290

8391
setByUser();
8492

@@ -129,6 +137,15 @@ public CssContain(ApplContext ac, CssExpression expression, boolean check)
129137
expression.getValue(),
130138
getPropertyName(), ac);
131139
}
140+
if (isExclusiveIdent(ident)) {
141+
if (got_exclusive) {
142+
throw new InvalidParamException("value",
143+
expression.getValue(),
144+
getPropertyName(), ac);
145+
} else {
146+
got_exclusive = true;
147+
}
148+
}
132149
idvalues.add(ident);
133150
values.add(val);
134151
if (op != SPACE) {

0 commit comments

Comments
 (0)