Skip to content

Commit 9430975

Browse files
committed
The 'distribute' legacy value has been added, and adds a deprecation warning.
1 parent 485ed83 commit 9430975

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

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

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@
1111
import org.w3c.css.values.CssIdent;
1212
import org.w3c.css.values.CssTypes;
1313
import org.w3c.css.values.CssValue;
14+
import org.w3c.css.values.CssValueList;
15+
16+
import java.util.ArrayList;
17+
18+
import static org.w3c.css.values.CssOperator.SPACE;
1419

1520
/**
16-
* @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-justify
21+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#text-justify-property
1722
*/
1823
public class CssTextJustify extends org.w3c.css.properties.css.CssTextJustify {
1924

2025
private static CssIdent[] allowed_values;
26+
private static CssIdent no_compress, distribute;
2127

2228
static {
23-
String id_values[] = {"auto", "none", "inter-word", "inter-character"};
29+
no_compress = CssIdent.getIdent("no-compress");
30+
distribute = CssIdent.getIdent("distribute");
31+
String id_values[] = {"auto", "none", "inter-word", "inter-character", "ruby", "distribute"};
2432
allowed_values = new CssIdent[id_values.length];
2533
int i = 0;
2634
for (String s : id_values) {
@@ -52,28 +60,66 @@ public CssTextJustify() {
5260
*/
5361
public CssTextJustify(ApplContext ac, CssExpression expression, boolean check)
5462
throws InvalidParamException {
63+
ArrayList<CssValue> values = new ArrayList<CssValue>();
64+
CssValue val;
65+
CssExpression trimexp = null;
66+
CssIdent id;
67+
boolean got_no_compress = false;
68+
char op;
69+
5570
setByUser();
56-
CssValue val = expression.getValue();
5771

58-
if (check && expression.getCount() > 1) {
72+
if (check && expression.getCount() > 2) {
5973
throw new InvalidParamException("unrecognize", ac);
6074
}
6175

62-
if (val.getType() != CssTypes.CSS_IDENT) {
63-
throw new InvalidParamException("value",
64-
expression.getValue(),
65-
getPropertyName(), ac);
66-
}
67-
// ident, so inherit, or allowed value
68-
CssIdent id = val.getIdent();
76+
while (!expression.end()) {
77+
val = expression.getValue();
78+
op = expression.getOperator();
6979

70-
if (!CssIdent.isCssWide(id) && (getMatchingIdent(id) == null)) {
71-
throw new InvalidParamException("value",
72-
expression.getValue(),
73-
getPropertyName(), ac);
80+
if (val.getType() != CssTypes.CSS_IDENT) {
81+
throw new InvalidParamException("value",
82+
expression.getValue(),
83+
getPropertyName(), ac);
84+
}
85+
id = val.getIdent();
86+
if (CssIdent.isCssWide(id)) {
87+
if (expression.getCount() > 1) {
88+
throw new InvalidParamException("value",
89+
expression.getValue(),
90+
getPropertyName(), ac);
91+
}
92+
values.add(val);
93+
} else if (id.equals(no_compress)) {
94+
if (got_no_compress) {
95+
throw new InvalidParamException("value",
96+
expression.getValue(),
97+
getPropertyName(), ac);
98+
}
99+
got_no_compress = true;
100+
values.add(val);
101+
} else if (getMatchingIdent(id) != null) {
102+
if (!got_no_compress && !values.isEmpty()) {
103+
throw new InvalidParamException("value",
104+
expression.getValue(),
105+
getPropertyName(), ac);
106+
}
107+
values.add(val);
108+
if (distribute.equals(id)) {
109+
ac.getFrame().addWarning("deprecated", distribute.toString());
110+
}
111+
} else {
112+
throw new InvalidParamException("value",
113+
expression.getValue(),
114+
getPropertyName(), ac);
115+
}
116+
if (op != SPACE) {
117+
throw new InvalidParamException("operator", op,
118+
getPropertyName(), ac);
119+
}
120+
expression.next();
74121
}
75-
value = val;
76-
expression.next();
122+
value = (values.size() == 1) ? values.get(0) : new CssValueList(values);
77123
}
78124

79125
public CssTextJustify(ApplContext ac, CssExpression expression)

0 commit comments

Comments
 (0)