Skip to content

Commit f7bf460

Browse files
committed
1 parent f0b7056 commit f7bf460

4 files changed

Lines changed: 215 additions & 4 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-last: org.w3c.css.properties.css3.CssHyphenateLimitLast
200201
hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines
201202
hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone
202203
hyphens: org.w3c.css.properties.css3.CssHyphens
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 CssHyphenateLimitLast extends CssProperty {
18+
19+
/**
20+
* Create a new CssHyphenateLimitLast
21+
*/
22+
public CssHyphenateLimitLast() {
23+
}
24+
25+
/**
26+
* Creates a new CssHyphenateLimitLast
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException Expressions are incorrect
30+
*/
31+
public CssHyphenateLimitLast(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 CssHyphenateLimitLast(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-last";
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.cssHyphenateLimitLast != null) {
81+
style.addRedefinitionWarning(ac, this);
82+
}
83+
s.cssHyphenateLimitLast = 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 CssHyphenateLimitLast &&
94+
value.equals(((CssHyphenateLimitLast) 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).getHyphenateLimitLast();
107+
} else {
108+
return ((Css3Style) style).cssHyphenateLimitLast;
109+
}
110+
}
111+
}
112+

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

Lines changed: 15 additions & 4 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.CssHyphenateLimitLast;
5758
import org.w3c.css.properties.css.CssHyphenateLimitLines;
5859
import org.w3c.css.properties.css.CssHyphenateLimitZone;
5960
import org.w3c.css.properties.css.CssImageRendering;
@@ -711,6 +712,16 @@ public class Css3Style extends ATSCStyle {
711712
public CssHyphenateLimitZone cssHyphenateLimitZone;
712713
public CssHyphenateLimitChars cssHyphenateLimitChars;
713714
public CssHyphenateLimitLines cssHyphenateLimitLines;
715+
public CssHyphenateLimitLast cssHyphenateLimitLast;
716+
717+
public CssHyphenateLimitLast getHyphenateLimitLast() {
718+
if (cssHyphenateLimitLast == null) {
719+
cssHyphenateLimitLast =
720+
(CssHyphenateLimitLast) style.CascadingOrder(new CssHyphenateLimitLast(),
721+
style, selector);
722+
}
723+
return cssHyphenateLimitLast;
724+
}
714725

715726
public CssHyphenateLimitLines getHyphenateLimitLines() {
716727
if (cssHyphenateLimitLines == null) {
@@ -720,7 +731,7 @@ public CssHyphenateLimitLines getHyphenateLimitLines() {
720731
}
721732
return cssHyphenateLimitLines;
722733
}
723-
734+
724735
public CssHyphenateLimitChars getHyphenateLimitChars() {
725736
if (cssHyphenateLimitChars == null) {
726737
cssHyphenateLimitChars =
@@ -729,7 +740,7 @@ public CssHyphenateLimitChars getHyphenateLimitChars() {
729740
}
730741
return cssHyphenateLimitChars;
731742
}
732-
743+
733744
public CssHyphenateLimitZone getHyphenateLimitZone() {
734745
if (cssHyphenateLimitZone == null) {
735746
cssHyphenateLimitZone =
@@ -738,7 +749,7 @@ public CssHyphenateLimitZone getHyphenateLimitZone() {
738749
}
739750
return cssHyphenateLimitZone;
740751
}
741-
752+
742753
public CssHyphenateCharacter getHyphenateCharacter() {
743754
if (cssHyphenateCharacter == null) {
744755
cssHyphenateCharacter =
@@ -747,7 +758,7 @@ public CssHyphenateCharacter getHyphenateCharacter() {
747758
}
748759
return cssHyphenateCharacter;
749760
}
750-
761+
751762
public CssWhiteSpaceTrim getWhiteSpaceTrim() {
752763
if (cssWhiteSpaceTrim == null) {
753764
cssWhiteSpaceTrim =
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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-limit-zone
17+
*/
18+
public class CssHyphenateLimitLast extends org.w3c.css.properties.css.CssHyphenateLimitZone {
19+
private final static CssIdent[] allowed_values;
20+
21+
static {
22+
String[] id_values = {"none", "always", "column", "page", "spread"};
23+
allowed_values = new CssIdent[id_values.length];
24+
int i = 0;
25+
for (String s : id_values) {
26+
allowed_values[i++] = CssIdent.getIdent(s);
27+
}
28+
}
29+
30+
public static CssIdent getAllowedIdent(CssIdent ident) {
31+
for (CssIdent id : allowed_values) {
32+
if (id.equals(ident)) {
33+
return id;
34+
}
35+
}
36+
return null;
37+
}
38+
39+
/**
40+
* Create a new CssHyphenateLimitZone
41+
*/
42+
public CssHyphenateLimitLast() {
43+
value = initial;
44+
}
45+
46+
/**
47+
* Creates a new CssHyphenateLimitZone
48+
*
49+
* @param expression The expression for this property
50+
* @throws InvalidParamException Expressions are incorrect
51+
*/
52+
public CssHyphenateLimitLast(ApplContext ac, CssExpression expression, boolean check)
53+
throws InvalidParamException {
54+
setByUser();
55+
56+
if (check && expression.getCount() > 1) {
57+
throw new InvalidParamException("unrecognize", ac);
58+
}
59+
60+
CssValue val = expression.getValue();
61+
62+
if (val.getType() != CssTypes.CSS_IDENT) {
63+
throw new InvalidParamException("value",
64+
expression.getValue(),
65+
getPropertyName(), ac);
66+
}
67+
68+
CssIdent ident = val.getIdent();
69+
if (CssIdent.isCssWide(ident)) {
70+
value = val;
71+
} else if (getAllowedIdent(ident) != null) {
72+
value = val;
73+
} else {
74+
throw new InvalidParamException("value",
75+
expression.getValue(),
76+
getPropertyName(), ac);
77+
}
78+
expression.next();
79+
}
80+
81+
public CssHyphenateLimitLast(ApplContext ac, CssExpression expression)
82+
throws InvalidParamException {
83+
this(ac, expression, false);
84+
}
85+
86+
}
87+

0 commit comments

Comments
 (0)