Skip to content

Commit 53f265a

Browse files
committed
1 parent 6ade4a6 commit 53f265a

4 files changed

Lines changed: 201 additions & 0 deletions

File tree

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ word-wrap: org.w3c.css.properties.css3.CssOverflowW
196196
word-break: org.w3c.css.properties.css3.CssWordBreak
197197
hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation
198198
hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter
199+
hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone
199200
hyphens: org.w3c.css.properties.css3.CssHyphens
200201
line-break: org.w3c.css.properties.css3.CssLineBreak
201202
text-align: org.w3c.css.properties.css3.CssTextAlign
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 CssHyphenateLimitZone extends CssProperty {
18+
19+
/**
20+
* Create a new CssHyphenateLimitZone
21+
*/
22+
public CssHyphenateLimitZone() {
23+
}
24+
25+
/**
26+
* Creates a new CssHyphenateLimitZone
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException Expressions are incorrect
30+
*/
31+
public CssHyphenateLimitZone(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 CssHyphenateLimitZone(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-limit-zone";
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.cssHyphenateLimitZone != null) {
81+
style.addRedefinitionWarning(ac, this);
82+
}
83+
s.cssHyphenateLimitZone = 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 CssHyphenateLimitZone &&
94+
value.equals(((CssHyphenateLimitZone) 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).getHyphenateLimitZone();
107+
} else {
108+
return ((Css3Style) style).cssHyphenateLimitZone;
109+
}
110+
}
111+
}
112+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.w3c.css.properties.css.CssBorderEndEndRadius;
5454
import org.w3c.css.properties.css.CssBorderEndStartRadius;
5555
import org.w3c.css.properties.css.CssHyphenateCharacter;
56+
import org.w3c.css.properties.css.CssHyphenateLimitZone;
5657
import org.w3c.css.properties.css.CssImageRendering;
5758
import org.w3c.css.properties.css.CssBorderImageSource;
5859
import org.w3c.css.properties.css.CssBorderInline;
@@ -705,7 +706,17 @@ public class Css3Style extends ATSCStyle {
705706
public CssWhiteSpaceCollapse cssWhiteSpaceCollapse;
706707
public CssWhiteSpaceTrim cssWhiteSpaceTrim;
707708
public CssHyphenateCharacter cssHyphenateCharacter;
709+
public CssHyphenateLimitZone cssHyphenateLimitZone;
708710

711+
public CssHyphenateLimitZone getHyphenateLimitZone() {
712+
if (cssHyphenateLimitZone == null) {
713+
cssHyphenateLimitZone =
714+
(CssHyphenateLimitZone) style.CascadingOrder(new CssHyphenateLimitZone(),
715+
style, selector);
716+
}
717+
return cssHyphenateLimitZone;
718+
}
719+
709720
public CssHyphenateCharacter getHyphenateCharacter() {
710721
if (cssHyphenateCharacter == null) {
711722
cssHyphenateCharacter =
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.CssCheckableValue;
11+
import org.w3c.css.values.CssExpression;
12+
import org.w3c.css.values.CssIdent;
13+
import org.w3c.css.values.CssTypes;
14+
import org.w3c.css.values.CssValue;
15+
16+
/**
17+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-zone
18+
*/
19+
public class CssHyphenateLimitZone extends org.w3c.css.properties.css.CssHyphenateLimitZone {
20+
21+
/**
22+
* Create a new CssHyphenateLimitZone
23+
*/
24+
public CssHyphenateLimitZone() {
25+
value = initial;
26+
}
27+
28+
/**
29+
* Creates a new CssHyphenateLimitZone
30+
*
31+
* @param expression The expression for this property
32+
* @throws InvalidParamException Expressions are incorrect
33+
*/
34+
public CssHyphenateLimitZone(ApplContext ac, CssExpression expression, boolean check)
35+
throws InvalidParamException {
36+
setByUser();
37+
38+
if (check && expression.getCount() > 1) {
39+
throw new InvalidParamException("unrecognize", ac);
40+
}
41+
42+
CssValue val = expression.getValue();
43+
44+
switch (val.getType()) {
45+
case CssTypes.CSS_IDENT:
46+
CssIdent ident = val.getIdent();
47+
if (CssIdent.isCssWide(ident)) {
48+
value = val;
49+
break;
50+
}
51+
throw new InvalidParamException("value",
52+
expression.getValue(),
53+
getPropertyName(), ac);
54+
case CssTypes.CSS_NUMBER:
55+
CssCheckableValue p = val.getCheckableValue();
56+
p.checkEqualsZero(ac, this);
57+
// flow for other possible checks
58+
case CssTypes.CSS_LENGTH:
59+
case CssTypes.CSS_PERCENTAGE:
60+
value = val;
61+
break;
62+
default:
63+
throw new InvalidParamException("value",
64+
expression.getValue(),
65+
getPropertyName(), ac);
66+
67+
}
68+
expression.next();
69+
}
70+
71+
public CssHyphenateLimitZone(ApplContext ac, CssExpression expression)
72+
throws InvalidParamException {
73+
this(ac, expression, false);
74+
}
75+
76+
}
77+

0 commit comments

Comments
 (0)