Skip to content

Commit 50510fb

Browse files
committed
1 parent 8cd1f6b commit 50510fb

4 files changed

Lines changed: 195 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
@@ -224,6 +224,7 @@ text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode
224224
tab-size: org.w3c.css.properties.css3.CssTabSize
225225
hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation
226226
wrap-after: org.w3c.css.properties.css3.CssWrapAfter
227+
wrap-before: org.w3c.css.properties.css3.CssWrapBefore
227228
wrap-inside: org.w3c.css.properties.css3.CssWrapInside
228229

229230
text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright
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 CssWrapBefore extends CssProperty {
18+
19+
/**
20+
* Create a new CssWrapBefore
21+
*/
22+
public CssWrapBefore() {
23+
}
24+
25+
/**
26+
* Creates a new CssWrapBefore
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssWrapBefore(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 CssWrapBefore(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 "content-visibility";
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.cssWrapBefore != null) {
82+
style.addRedefinitionWarning(ac, this);
83+
}
84+
s.cssWrapBefore = 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 CssWrapBefore &&
95+
value.equals(((CssWrapBefore) 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).getWrapBefore();
108+
} else {
109+
return ((Css3Style) style).cssWrapBefore;
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
@@ -300,6 +300,7 @@
300300
import org.w3c.css.properties.css.CssWordBreak;
301301
import org.w3c.css.properties.css.CssWordSpaceTransform;
302302
import org.w3c.css.properties.css.CssWrapAfter;
303+
import org.w3c.css.properties.css.CssWrapBefore;
303304
import org.w3c.css.properties.css.CssWrapInside;
304305
import org.w3c.css.properties.css.CssWritingMode;
305306
import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols;
@@ -693,7 +694,17 @@ public class Css3Style extends ATSCStyle {
693694
public CssTextWrapMode cssTextWrapMode;
694695
public CssWrapInside cssWrapInside;
695696
public CssWrapAfter cssWrapAfter;
697+
public CssWrapBefore cssWrapBefore;
696698

699+
public CssWrapBefore getWrapBefore() {
700+
if (cssWrapBefore == null) {
701+
cssWrapBefore =
702+
(CssWrapBefore) style.CascadingOrder(new CssWrapBefore(),
703+
style, selector);
704+
}
705+
return cssWrapBefore;
706+
}
707+
697708
public CssWrapAfter getWrapAfter() {
698709
if (cssWrapAfter == null) {
699710
cssWrapAfter =
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, 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-wrap-before
17+
*/
18+
public class CssWrapBefore extends org.w3c.css.properties.css.CssWrapBefore {
19+
/* See @CssWrapAfter */
20+
public static CssIdent getAllowedIdent(CssIdent ident) {
21+
return CssWrapAfter.getAllowedIdent(ident);
22+
}
23+
24+
/**
25+
* Create a new CssWrapBefore
26+
*/
27+
public CssWrapBefore() {
28+
value = initial;
29+
}
30+
31+
/**
32+
* Creates a new CssWrapBefore
33+
*
34+
* @param expression The expression for this property
35+
* @throws InvalidParamException Expressions are incorrect
36+
*/
37+
public CssWrapBefore(ApplContext ac, CssExpression expression, boolean check)
38+
throws InvalidParamException {
39+
40+
if (check && expression.getCount() > 1) {
41+
throw new InvalidParamException("unrecognize", ac);
42+
}
43+
setByUser();
44+
45+
CssValue val;
46+
char op;
47+
48+
val = expression.getValue();
49+
op = expression.getOperator();
50+
51+
if (val.getType() != CssTypes.CSS_IDENT) {
52+
throw new InvalidParamException("value", val,
53+
getPropertyName(), ac);
54+
}
55+
CssIdent id = val.getIdent();
56+
if (!CssIdent.isCssWide(id) && (getAllowedIdent(id) == null)) {
57+
throw new InvalidParamException("value",
58+
val.toString(),
59+
getPropertyName(), ac);
60+
}
61+
value = val;
62+
expression.next();
63+
}
64+
65+
public CssWrapBefore(ApplContext ac, CssExpression expression)
66+
throws InvalidParamException {
67+
this(ac, expression, false);
68+
}
69+
}
70+

0 commit comments

Comments
 (0)