Skip to content

Commit be17271

Browse files
committed
1 parent e409d4c commit be17271

5 files changed

Lines changed: 256 additions & 1 deletion

File tree

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ hanging-punctuation: org.w3c.css.properties.css3.CssHangingPu
226226
text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright
227227
text-orientation: org.w3c.css.properties.css3.CssTextOrientation
228228
glyph-orientation-vertical: org.w3c.css.properties.css3.CssGlyphOrientationVertical
229+
word-space-transform: org.w3c.css.properties.css3.CssWordSpaceTransform
229230

230231

231232
# marquee
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022.
5+
// Please first read the full copyright statement in file COPYRIGHT.html
6+
package org.w3c.css.properties.css;
7+
8+
import org.w3c.css.parser.CssStyle;
9+
import org.w3c.css.properties.css3.Css3Style;
10+
import org.w3c.css.util.ApplContext;
11+
import org.w3c.css.util.InvalidParamException;
12+
import org.w3c.css.values.CssExpression;
13+
14+
/**
15+
* @since CSS3
16+
*/
17+
public class CssWordSpaceTransform extends CssProperty {
18+
19+
/**
20+
* Create a new CssWordSpaceTransform
21+
*/
22+
public CssWordSpaceTransform() {
23+
}
24+
25+
/**
26+
* Creates a new CssWordSpaceTransform
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssWordSpaceTransform(ApplContext ac, CssExpression expression, boolean check)
33+
throws InvalidParamException {
34+
throw new InvalidParamException("value",
35+
expression.getValue().toString(),
36+
getPropertyName(), ac);
37+
}
38+
39+
public CssWordSpaceTransform(ApplContext ac, CssExpression expression)
40+
throws InvalidParamException {
41+
this(ac, expression, false);
42+
}
43+
44+
/**
45+
* Returns the value of this property
46+
*/
47+
public Object get() {
48+
return value;
49+
}
50+
51+
52+
/**
53+
* Returns the name of this property
54+
*/
55+
public final String getPropertyName() {
56+
return "content-visibility";
57+
}
58+
59+
/**
60+
* Returns true if this property is "softly" inherited
61+
* e.g. his value is equals to inherit
62+
*/
63+
public boolean isSoftlyInherited() {
64+
return value.equals(inherit);
65+
}
66+
67+
/**
68+
* Returns a string representation of the object.
69+
*/
70+
public String toString() {
71+
return value.toString();
72+
}
73+
74+
/**
75+
* Add this property to the CssStyle.
76+
*
77+
* @param style The CssStyle
78+
*/
79+
public void addToStyle(ApplContext ac, CssStyle style) {
80+
Css3Style s = (Css3Style) style;
81+
if (s.cssWordSpaceTransform != null) {
82+
style.addRedefinitionWarning(ac, this);
83+
}
84+
s.cssWordSpaceTransform = this;
85+
}
86+
87+
88+
/**
89+
* Compares two properties for equality.
90+
*
91+
* @param property The other property.
92+
*/
93+
public boolean equals(CssProperty property) {
94+
return (property instanceof CssWordSpaceTransform &&
95+
value.equals(((CssWordSpaceTransform) property).value));
96+
}
97+
98+
99+
/**
100+
* Get this property in the style.
101+
*
102+
* @param style The style where the property is
103+
* @param resolve if true, resolve the style to find this property
104+
*/
105+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
106+
if (resolve) {
107+
return ((Css3Style) style).getWordSpaceTransform();
108+
} else {
109+
return ((Css3Style) style).cssWordSpaceTransform;
110+
}
111+
}
112+
}
113+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
import org.w3c.css.properties.css.CssVoiceVolume;
298298
import org.w3c.css.properties.css.CssWillChange;
299299
import org.w3c.css.properties.css.CssWordBreak;
300+
import org.w3c.css.properties.css.CssWordSpaceTransform;
300301
import org.w3c.css.properties.css.CssWritingMode;
301302
import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols;
302303
import org.w3c.css.properties.css.counterstyle.CssFallback;
@@ -684,7 +685,17 @@ public class Css3Style extends ATSCStyle {
684685
public CssOverscrollBehaviorBlock cssOverscrollBehaviorBlock;
685686
public CssOverscrollBehaviorInline cssOverscrollBehaviorInline;
686687
public CssContentVisibility cssContentVisibility;
688+
689+
public CssWordSpaceTransform cssWordSpaceTransform;
687690

691+
public CssWordSpaceTransform getWordSpaceTransform() {
692+
if (cssWordSpaceTransform == null) {
693+
cssWordSpaceTransform =
694+
(CssWordSpaceTransform) style.CascadingOrder(new CssWordSpaceTransform(),
695+
style, selector);
696+
}
697+
return cssWordSpaceTransform;
698+
}
688699
public CssContentVisibility getContentVisibility() {
689700
if (cssContentVisibility == null) {
690701
cssContentVisibility =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import static org.w3c.css.values.CssOperator.SPACE;
1919

2020
/**
21-
* @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-transform
21+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-transform
2222
*/
2323
public class CssTextTransform extends org.w3c.css.properties.css.CssTextTransform {
2424

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012.
5+
// Please first read the full copyright statement in file COPYRIGHT.html
6+
package org.w3c.css.properties.css3;
7+
8+
import org.w3c.css.util.ApplContext;
9+
import org.w3c.css.util.InvalidParamException;
10+
import org.w3c.css.values.CssExpression;
11+
import org.w3c.css.values.CssIdent;
12+
import org.w3c.css.values.CssTypes;
13+
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;
19+
20+
/**
21+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-space-transform
22+
*/
23+
public class CssWordSpaceTransform extends org.w3c.css.properties.css.CssWordSpaceTransform {
24+
25+
private static CssIdent[] allowed_action_values;
26+
private static CssIdent autoPhrase;
27+
28+
29+
static {
30+
autoPhrase = CssIdent.getIdent("auto-phrase");
31+
32+
String id_values[] = {"space", "ideographic-space"};
33+
allowed_action_values = new CssIdent[id_values.length];
34+
int i = 0;
35+
for (String s : id_values) {
36+
allowed_action_values[i++] = CssIdent.getIdent(s);
37+
}
38+
}
39+
40+
public static CssIdent getMatchingMainIdent(CssIdent ident) {
41+
for (CssIdent id : allowed_action_values) {
42+
if (id.equals(ident)) {
43+
return id;
44+
}
45+
}
46+
return null;
47+
}
48+
49+
/**
50+
* Create a new CssWordSpaceTransform
51+
*/
52+
public CssWordSpaceTransform() {
53+
value = initial;
54+
}
55+
56+
/**
57+
* Creates a new CssWordSPaceTransform
58+
*
59+
* @param expression The expression for this property
60+
* @throws InvalidParamException
61+
* Expressions are incorrect
62+
*/
63+
public CssWordSpaceTransform(ApplContext ac, CssExpression expression, boolean check)
64+
throws InvalidParamException {
65+
setByUser();
66+
CssValue val = expression.getValue();
67+
char op;
68+
ArrayList<CssValue> values = new ArrayList<>();
69+
boolean got_main = false;
70+
boolean got_auto = false;
71+
72+
if (check && expression.getCount() > 2) {
73+
throw new InvalidParamException("unrecognize", ac);
74+
}
75+
76+
while (!expression.end()) {
77+
val = expression.getValue();
78+
op = expression.getOperator();
79+
80+
if (val.getType() != CssTypes.CSS_IDENT) {
81+
throw new InvalidParamException("value",
82+
expression.getValue(),
83+
getPropertyName(), ac);
84+
}
85+
// ident, so inherit, or allowed value
86+
if (CssIdent.isCssWide(val.getIdent())) {
87+
if (expression.getCount() > 1) {
88+
throw new InvalidParamException("value",
89+
expression.getValue(),
90+
getPropertyName(), ac);
91+
}
92+
values.add(val);
93+
} else if (none.equals(val.getIdent())) {
94+
if (expression.getCount() > 1) {
95+
throw new InvalidParamException("value",
96+
expression.getValue(),
97+
getPropertyName(), ac);
98+
}
99+
values.add(val);
100+
} else if (autoPhrase.equals(val.getIdent()) && !got_auto) {
101+
got_auto = true;
102+
values.add(val);
103+
} else if (!got_main) {
104+
if (getMatchingMainIdent(val.getIdent()) == null) {
105+
throw new InvalidParamException("value",
106+
expression.getValue(),
107+
getPropertyName(), ac);
108+
}
109+
got_main = true;
110+
values.add(val);
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();
121+
}
122+
value = (values.size() == 1) ? values.get(0) : new CssValueList(values);
123+
}
124+
125+
public CssWordSpaceTransform(ApplContext ac, CssExpression expression)
126+
throws InvalidParamException {
127+
this(ac, expression, false);
128+
}
129+
}
130+

0 commit comments

Comments
 (0)