Skip to content

Commit cd24dfc

Browse files
committed
1 parent 9430975 commit cd24dfc

File tree

4 files changed

+209
-0
lines changed

4 files changed

+209
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ text-emphasis: org.w3c.css.properties.css3.CssTextEmpha
223223
text-emphasis-color: org.w3c.css.properties.css3.CssTextEmphasisColor
224224
text-emphasis-position: org.w3c.css.properties.css3.CssTextEmphasisPosition
225225
text-emphasis-style: org.w3c.css.properties.css3.CssTextEmphasisStyle
226+
text-group-align: org.w3c.css.properties.css3.CssTextGroupAlign
226227
text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust
227228
text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset
228229
text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition
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 CssTextGroupAlign extends CssProperty {
18+
19+
/**
20+
* Create a new CssTextGroupAlign
21+
*/
22+
public CssTextGroupAlign() {
23+
}
24+
25+
/**
26+
* Creates a new CssTextgroupAlign
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssTextGroupAlign(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 CssTextGroupAlign(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 "text-group-align";
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.cssTextGroupAlign != null) {
82+
style.addRedefinitionWarning(ac, this);
83+
}
84+
s.cssTextGroupAlign = 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 CssTextGroupAlign &&
95+
value.equals(((CssTextGroupAlign) 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).getTextGroupAlign();
108+
} else {
109+
return ((Css3Style) style).cssTextGroupAlign;
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
@@ -276,6 +276,7 @@
276276
import org.w3c.css.properties.css.CssTextEmphasisColor;
277277
import org.w3c.css.properties.css.CssTextEmphasisPosition;
278278
import org.w3c.css.properties.css.CssTextEmphasisStyle;
279+
import org.w3c.css.properties.css.CssTextGroupAlign;
279280
import org.w3c.css.properties.css.CssTextJustify;
280281
import org.w3c.css.properties.css.CssTextOrientation;
281282
import org.w3c.css.properties.css.CssTextOverflow;
@@ -713,6 +714,16 @@ public class Css3Style extends ATSCStyle {
713714
public CssHyphenateLimitChars cssHyphenateLimitChars;
714715
public CssHyphenateLimitLines cssHyphenateLimitLines;
715716
public CssHyphenateLimitLast cssHyphenateLimitLast;
717+
public CssTextGroupAlign cssTextGroupAlign;
718+
719+
public CssTextGroupAlign getTextGroupAlign() {
720+
if (cssTextGroupAlign == null) {
721+
cssTextGroupAlign =
722+
(CssTextGroupAlign) style.CascadingOrder(new CssTextGroupAlign(),
723+
style, selector);
724+
}
725+
return cssTextGroupAlign;
726+
}
716727

717728
public CssHyphenateLimitLast getHyphenateLimitLast() {
718729
if (cssHyphenateLimitLast == null) {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM and 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+
15+
/**
16+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-group-align
17+
*/
18+
public class CssTextGroupAlign extends org.w3c.css.properties.css.CssTextGroupAlign {
19+
20+
private static CssIdent[] allowed_values;
21+
22+
//
23+
static {
24+
String id_values[] = {"none", "start", "end", "left", "right", "center"};
25+
allowed_values = new CssIdent[id_values.length];
26+
int i = 0;
27+
for (String s : id_values) {
28+
allowed_values[i++] = CssIdent.getIdent(s);
29+
}
30+
}
31+
32+
public static CssIdent getMatchingIdent(CssIdent ident) {
33+
for (CssIdent id : allowed_values) {
34+
if (id.equals(ident)) {
35+
return id;
36+
}
37+
}
38+
return null;
39+
}
40+
41+
/**
42+
* Create a new CssTextGroupAlign
43+
*/
44+
public CssTextGroupAlign() {
45+
value = initial;
46+
}
47+
48+
/**
49+
* Creates a new CssTextGroupAlign
50+
*
51+
* @param expression The expression for this property
52+
* @throws InvalidParamException Expressions are incorrect
53+
*/
54+
public CssTextGroupAlign(ApplContext ac, CssExpression expression, boolean check)
55+
throws InvalidParamException {
56+
setByUser();
57+
CssValue val = expression.getValue();
58+
59+
if (check && expression.getCount() > 1) {
60+
throw new InvalidParamException("unrecognize", ac);
61+
}
62+
63+
if (val.getType() != CssTypes.CSS_IDENT) {
64+
throw new InvalidParamException("value",
65+
expression.getValue(),
66+
getPropertyName(), ac);
67+
}
68+
// ident, so inherit, or allowed value
69+
if (!CssIdent.isCssWide(val.getIdent()) && getMatchingIdent(val.getIdent()) == null) {
70+
throw new InvalidParamException("value",
71+
expression.getValue(),
72+
getPropertyName(), ac);
73+
}
74+
value = val;
75+
expression.next();
76+
}
77+
78+
public CssTextGroupAlign(ApplContext ac, CssExpression expression)
79+
throws InvalidParamException {
80+
this(ac, expression, false);
81+
}
82+
83+
}
84+

0 commit comments

Comments
 (0)