Skip to content

Commit f0b7056

Browse files
committed
1 parent e302a50 commit f0b7056

4 files changed

Lines changed: 221 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
@@ -197,6 +197,7 @@ 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
199199
hyphenate-limit-chars: org.w3c.css.properties.css3.CssHyphenateLimitChars
200+
hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines
200201
hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone
201202
hyphens: org.w3c.css.properties.css3.CssHyphens
202203
line-break: org.w3c.css.properties.css3.CssLineBreak
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 CssHyphenateLimitLines extends CssProperty {
18+
19+
/**
20+
* Create a new CssHyphenateLimitLines
21+
*/
22+
public CssHyphenateLimitLines() {
23+
}
24+
25+
/**
26+
* Creates a new CssHyphenateLimitLines
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException Expressions are incorrect
30+
*/
31+
public CssHyphenateLimitLines(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 CssHyphenateLimitLines(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-lines";
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.cssHyphenateLimitLines != null) {
81+
style.addRedefinitionWarning(ac, this);
82+
}
83+
s.cssHyphenateLimitLines = 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 CssHyphenateLimitLines &&
94+
value.equals(((CssHyphenateLimitLines) 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).getHyphenateLimitLines();
107+
} else {
108+
return ((Css3Style) style).cssHyphenateLimitLines;
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
@@ -54,6 +54,7 @@
5454
import org.w3c.css.properties.css.CssBorderEndStartRadius;
5555
import org.w3c.css.properties.css.CssHyphenateCharacter;
5656
import org.w3c.css.properties.css.CssHyphenateLimitChars;
57+
import org.w3c.css.properties.css.CssHyphenateLimitLines;
5758
import org.w3c.css.properties.css.CssHyphenateLimitZone;
5859
import org.w3c.css.properties.css.CssImageRendering;
5960
import org.w3c.css.properties.css.CssBorderImageSource;
@@ -709,7 +710,17 @@ public class Css3Style extends ATSCStyle {
709710
public CssHyphenateCharacter cssHyphenateCharacter;
710711
public CssHyphenateLimitZone cssHyphenateLimitZone;
711712
public CssHyphenateLimitChars cssHyphenateLimitChars;
713+
public CssHyphenateLimitLines cssHyphenateLimitLines;
712714

715+
public CssHyphenateLimitLines getHyphenateLimitLines() {
716+
if (cssHyphenateLimitLines == null) {
717+
cssHyphenateLimitLines =
718+
(CssHyphenateLimitLines) style.CascadingOrder(new CssHyphenateLimitLines(),
719+
style, selector);
720+
}
721+
return cssHyphenateLimitLines;
722+
}
723+
713724
public CssHyphenateLimitChars getHyphenateLimitChars() {
714725
if (cssHyphenateLimitChars == null) {
715726
cssHyphenateLimitChars =
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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-lines
18+
*/
19+
public class CssHyphenateLimitLines extends org.w3c.css.properties.css.CssHyphenateLimitLines {
20+
private final static CssIdent[] allowed_values;
21+
22+
static {
23+
String[] id_values = {"no-limit"};
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 CssHyphenateLimitLines
42+
*/
43+
public CssHyphenateLimitLines() {
44+
value = initial;
45+
}
46+
47+
/**
48+
* Creates a new CssHyphenateLimitLines
49+
*
50+
* @param expression The expression for this property
51+
* @throws InvalidParamException Expressions are incorrect
52+
*/
53+
public CssHyphenateLimitLines(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(val.getIdent()) != null) {
71+
value = val;
72+
break;
73+
}
74+
throw new InvalidParamException("value",
75+
expression.getValue(),
76+
getPropertyName(), ac);
77+
case CssTypes.CSS_NUMBER:
78+
CssCheckableValue p = val.getCheckableValue();
79+
p.checkInteger(ac, this);
80+
value = val;
81+
break;
82+
default:
83+
throw new InvalidParamException("value",
84+
expression.getValue(),
85+
getPropertyName(), ac);
86+
87+
}
88+
expression.next();
89+
}
90+
91+
public CssHyphenateLimitLines(ApplContext ac, CssExpression expression)
92+
throws InvalidParamException {
93+
this(ac, expression, false);
94+
}
95+
96+
}
97+

0 commit comments

Comments
 (0)