Skip to content

Commit 34ae5fa

Browse files
committed
1 parent 493dd9f commit 34ae5fa

4 files changed

Lines changed: 214 additions & 1 deletion

File tree

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ text-underline-position: org.w3c.css.properties.css3.CssTextUnder
223223
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
226+
wrap-inside: org.w3c.css.properties.css3.CssWrapInside
226227

227228
text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright
228229
text-orientation: org.w3c.css.properties.css3.CssTextOrientation
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 CssWrapInside extends CssProperty {
18+
19+
/**
20+
* Create a new CssWrapInside
21+
*/
22+
public CssWrapInside() {
23+
}
24+
25+
/**
26+
* Creates a new CssWrapInside
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssWrapInside(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 CssWrapInside(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.cssWrapInside != null) {
82+
style.addRedefinitionWarning(ac, this);
83+
}
84+
s.cssWrapInside = 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 CssWrapInside &&
95+
value.equals(((CssWrapInside) 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).getWrapInside();
108+
} else {
109+
return ((Css3Style) style).cssWrapInside;
110+
}
111+
}
112+
}
113+

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@
299299
import org.w3c.css.properties.css.CssWillChange;
300300
import org.w3c.css.properties.css.CssWordBreak;
301301
import org.w3c.css.properties.css.CssWordSpaceTransform;
302+
import org.w3c.css.properties.css.CssWrapInside;
302303
import org.w3c.css.properties.css.CssWritingMode;
303304
import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols;
304305
import org.w3c.css.properties.css.counterstyle.CssFallback;
@@ -686,10 +687,19 @@ public class Css3Style extends ATSCStyle {
686687
public CssOverscrollBehaviorBlock cssOverscrollBehaviorBlock;
687688
public CssOverscrollBehaviorInline cssOverscrollBehaviorInline;
688689
public CssContentVisibility cssContentVisibility;
689-
690+
690691
public CssWordSpaceTransform cssWordSpaceTransform;
691692
public CssTextWrapMode cssTextWrapMode;
693+
public CssWrapInside cssWrapInside;
692694

695+
public CssWrapInside getWrapInside() {
696+
if (cssWrapInside == null) {
697+
cssWrapInside =
698+
(CssWrapInside) style.CascadingOrder(new CssWrapInside(),
699+
style, selector);
700+
}
701+
return cssWrapInside;
702+
}
693703

694704
public CssTextWrapMode getTextWrapMode() {
695705
if (cssTextWrapMode == null) {
@@ -699,6 +709,7 @@ public CssTextWrapMode getTextWrapMode() {
699709
}
700710
return cssTextWrapMode;
701711
}
712+
702713
public CssWordSpaceTransform getWordSpaceTransform() {
703714
if (cssWordSpaceTransform == null) {
704715
cssWordSpaceTransform =
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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-inside
17+
*/
18+
public class CssWrapInside extends org.w3c.css.properties.css.CssWrapInside {
19+
20+
private static CssIdent[] allowed_idents;
21+
22+
23+
static {
24+
25+
String[] id_values = {"auto", "avoid"};
26+
allowed_idents = new CssIdent[id_values.length];
27+
int i = 0;
28+
for (String s : id_values) {
29+
allowed_idents[i++] = CssIdent.getIdent(s);
30+
}
31+
}
32+
33+
public static CssIdent getAllowedIdent(CssIdent ident) {
34+
for (CssIdent id : allowed_idents) {
35+
if (id.equals(ident)) {
36+
return id;
37+
}
38+
}
39+
return null;
40+
}
41+
42+
/**
43+
* Create a new CssWrapInside
44+
*/
45+
public CssWrapInside() {
46+
value = initial;
47+
}
48+
49+
/**
50+
* Creates a new CssWrapInside
51+
*
52+
* @param expression The expression for this property
53+
* @throws InvalidParamException Expressions are incorrect
54+
*/
55+
public CssWrapInside(ApplContext ac, CssExpression expression, boolean check)
56+
throws InvalidParamException {
57+
58+
if (check && expression.getCount() > 1) {
59+
throw new InvalidParamException("unrecognize", ac);
60+
}
61+
setByUser();
62+
63+
CssValue val;
64+
char op;
65+
66+
val = expression.getValue();
67+
op = expression.getOperator();
68+
69+
if (val.getType() != CssTypes.CSS_IDENT) {
70+
throw new InvalidParamException("value", val,
71+
getPropertyName(), ac);
72+
}
73+
CssIdent id = val.getIdent();
74+
if (!CssIdent.isCssWide(id) && (getAllowedIdent(id) == null)) {
75+
throw new InvalidParamException("value",
76+
val.toString(),
77+
getPropertyName(), ac);
78+
}
79+
value = val;
80+
expression.next();
81+
}
82+
83+
public CssWrapInside(ApplContext ac, CssExpression expression)
84+
throws InvalidParamException {
85+
this(ac, expression, false);
86+
}
87+
}
88+

0 commit comments

Comments
 (0)