Skip to content

Commit 6ade4a6

Browse files
committed
1 parent 1b751a4 commit 6ade4a6

4 files changed

Lines changed: 221 additions & 2 deletions

File tree

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ overflow-wrap: org.w3c.css.properties.css3.CssOverflowW
194194
#alias per spec
195195
word-wrap: org.w3c.css.properties.css3.CssOverflowWrap
196196
word-break: org.w3c.css.properties.css3.CssWordBreak
197+
hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation
198+
hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter
197199
hyphens: org.w3c.css.properties.css3.CssHyphens
198200
line-break: org.w3c.css.properties.css3.CssLineBreak
199201
text-align: org.w3c.css.properties.css3.CssTextAlign
@@ -224,7 +226,6 @@ text-wrap: org.w3c.css.properties.css3.CssTextWrap
224226
text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode
225227
text-wrap-style: org.w3c.css.properties.css3.CssTextWrapStyle
226228
tab-size: org.w3c.css.properties.css3.CssTabSize
227-
hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation
228229
wrap-after: org.w3c.css.properties.css3.CssWrapAfter
229230
wrap-before: org.w3c.css.properties.css3.CssWrapBefore
230231
wrap-inside: org.w3c.css.properties.css3.CssWrapInside
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 CssHyphenateCharacter extends CssProperty {
18+
19+
/**
20+
* Create a new CssHyphenateCharacter
21+
*/
22+
public CssHyphenateCharacter() {
23+
}
24+
25+
/**
26+
* Creates a new CssHyphenateCharacter
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException Expressions are incorrect
30+
*/
31+
public CssHyphenateCharacter(ApplContext ac, CssExpression expression, boolean check)
32+
throws InvalidParamException {
33+
throw new InvalidParamException("value",
34+
expression.getValue().toString(),
35+
getPropertyName(), ac);
36+
}
37+
38+
public CssHyphenateCharacter(ApplContext ac, CssExpression expression)
39+
throws InvalidParamException {
40+
this(ac, expression, false);
41+
}
42+
43+
/**
44+
* Returns the value of this property
45+
*/
46+
public Object get() {
47+
return value;
48+
}
49+
50+
51+
/**
52+
* Returns the name of this property
53+
*/
54+
public final String getPropertyName() {
55+
return "hyphenate-character";
56+
}
57+
58+
/**
59+
* Returns true if this property is "softly" inherited
60+
* e.g. his value is equals to inherit
61+
*/
62+
public boolean isSoftlyInherited() {
63+
return value.equals(inherit);
64+
}
65+
66+
/**
67+
* Returns a string representation of the object.
68+
*/
69+
public String toString() {
70+
return value.toString();
71+
}
72+
73+
/**
74+
* Add this property to the CssStyle.
75+
*
76+
* @param style The CssStyle
77+
*/
78+
public void addToStyle(ApplContext ac, CssStyle style) {
79+
Css3Style s = (Css3Style) style;
80+
if (s.cssHyphenateCharacter != null) {
81+
style.addRedefinitionWarning(ac, this);
82+
}
83+
s.cssHyphenateCharacter = this;
84+
}
85+
86+
87+
/**
88+
* Compares two properties for equality.
89+
*
90+
* @param property The other property.
91+
*/
92+
public boolean equals(CssProperty property) {
93+
return (property instanceof CssHyphenateCharacter &&
94+
value.equals(((CssHyphenateCharacter) property).value));
95+
}
96+
97+
98+
/**
99+
* Get this property in the style.
100+
*
101+
* @param style The style where the property is
102+
* @param resolve if true, resolve the style to find this property
103+
*/
104+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
105+
if (resolve) {
106+
return ((Css3Style) style).getHyphenateCharacter();
107+
} else {
108+
return ((Css3Style) style).cssHyphenateCharacter;
109+
}
110+
}
111+
}
112+

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.w3c.css.properties.css.CssBorderBlockWidth;
5353
import org.w3c.css.properties.css.CssBorderEndEndRadius;
5454
import org.w3c.css.properties.css.CssBorderEndStartRadius;
55+
import org.w3c.css.properties.css.CssHyphenateCharacter;
5556
import org.w3c.css.properties.css.CssImageRendering;
5657
import org.w3c.css.properties.css.CssBorderImageSource;
5758
import org.w3c.css.properties.css.CssBorderInline;
@@ -703,7 +704,17 @@ public class Css3Style extends ATSCStyle {
703704
public CssTextWrap cssTextWrap;
704705
public CssWhiteSpaceCollapse cssWhiteSpaceCollapse;
705706
public CssWhiteSpaceTrim cssWhiteSpaceTrim;
707+
public CssHyphenateCharacter cssHyphenateCharacter;
706708

709+
public CssHyphenateCharacter getHyphenateCharacter() {
710+
if (cssHyphenateCharacter == null) {
711+
cssHyphenateCharacter =
712+
(CssHyphenateCharacter) style.CascadingOrder(new CssHyphenateCharacter(),
713+
style, selector);
714+
}
715+
return cssHyphenateCharacter;
716+
}
717+
707718
public CssWhiteSpaceTrim getWhiteSpaceTrim() {
708719
if (cssWhiteSpaceTrim == null) {
709720
cssWhiteSpaceTrim =
@@ -721,7 +732,7 @@ public CssWhiteSpaceCollapse getWhiteSpaceCollapse() {
721732
}
722733
return cssWhiteSpaceCollapse;
723734
}
724-
735+
725736
public CssWrapBefore getWrapBefore() {
726737
if (cssWrapBefore == null) {
727738
cssWrapBefore =
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT World Wide Web Consortium, 2024.
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-hyphenate-character
17+
*/
18+
public class CssHyphenateCharacter extends org.w3c.css.properties.css.CssHyphenateCharacter {
19+
20+
private final static CssIdent[] allowed_values;
21+
22+
static {
23+
String[] id_values = {"auto"};
24+
allowed_values = new CssIdent[id_values.length];
25+
int i = 0;
26+
for (String s : id_values) {
27+
allowed_values[i++] = CssIdent.getIdent(s);
28+
}
29+
}
30+
31+
public static CssIdent getAllowedIdent(CssIdent ident) {
32+
for (CssIdent id : allowed_values) {
33+
if (id.equals(ident)) {
34+
return id;
35+
}
36+
}
37+
return null;
38+
}
39+
40+
/**
41+
* Create a new CssHyphenateCharacter
42+
*/
43+
public CssHyphenateCharacter() {
44+
value = initial;
45+
}
46+
47+
/**
48+
* Creates a new CssHyphenateCharacter
49+
*
50+
* @param expression The expression for this property
51+
* @throws InvalidParamException Expressions are incorrect
52+
*/
53+
public CssHyphenateCharacter(ApplContext ac, CssExpression expression, boolean check)
54+
throws InvalidParamException {
55+
setByUser();
56+
57+
if (check && expression.getCount() > 1) {
58+
throw new InvalidParamException("unrecognize", ac);
59+
}
60+
61+
CssValue val = expression.getValue();
62+
63+
switch (val.getType()) {
64+
case CssTypes.CSS_IDENT:
65+
CssIdent ident = val.getIdent();
66+
if (CssIdent.isCssWide(ident)) {
67+
value = val;
68+
break;
69+
}
70+
if (getAllowedIdent(ident) != null) {
71+
value = val;
72+
break;
73+
}
74+
throw new InvalidParamException("value",
75+
expression.getValue(),
76+
getPropertyName(), ac);
77+
case CssTypes.CSS_STRING:
78+
value = val;
79+
break;
80+
default:
81+
throw new InvalidParamException("value",
82+
expression.getValue(),
83+
getPropertyName(), ac);
84+
85+
}
86+
expression.next();
87+
}
88+
89+
public CssHyphenateCharacter(ApplContext ac, CssExpression expression)
90+
throws InvalidParamException {
91+
this(ac, expression, false);
92+
}
93+
94+
}
95+

0 commit comments

Comments
 (0)