Skip to content

Commit 4363bdc

Browse files
committed
1 parent 55875a1 commit 4363bdc

4 files changed

Lines changed: 260 additions & 10 deletions

File tree

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ text-emphasis-style: org.w3c.css.properties.css3.CssTextEmpha
220220
text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust
221221
text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset
222222
text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition
223+
text-wrap: org.w3c.css.properties.css3.CssTextWrap
223224
text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode
224225
text-wrap-style: org.w3c.css.properties.css3.CssTextWrapStyle
225226
tab-size: org.w3c.css.properties.css3.CssTabSize
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 CssTextWrap extends CssProperty {
18+
19+
/**
20+
* Create a new CssTextWrap
21+
*/
22+
public CssTextWrap() {
23+
}
24+
25+
/**
26+
* Creates a new CssTextWrap
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssTextWrap(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 CssTextWrap(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 "text-wrap";
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.cssTextWrap != null) {
82+
style.addRedefinitionWarning(ac, this);
83+
}
84+
s.cssTextWrap = 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 CssTextWrap &&
95+
value.equals(((CssTextWrap) 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).getTextWrap();
108+
} else {
109+
return ((Css3Style) style).cssTextWrap;
110+
}
111+
}
112+
}
113+

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
import org.w3c.css.properties.css.CssTextSizeAdjust;
278278
import org.w3c.css.properties.css.CssTextUnderlineOffset;
279279
import org.w3c.css.properties.css.CssTextUnderlinePosition;
280+
import org.w3c.css.properties.css.CssTextWrap;
280281
import org.w3c.css.properties.css.CssTextWrapMode;
281282
import org.w3c.css.properties.css.CssTextWrapStyle;
282283
import org.w3c.css.properties.css.CssTouchAction;
@@ -612,7 +613,7 @@ public class Css3Style extends ATSCStyle {
612613
public org.w3c.css.properties.css.fontface.CssFontFamily fontFaceCssFontFamily;
613614
public org.w3c.css.properties.css.fontface.CssFontFeatureSettings fontFaceCssFontFeatureSettings;
614615
public org.w3c.css.properties.css.fontface.CssFontVariationSettings fontFaceCssFontVariationSettings;
615-
616+
616617
public CssColorAdjust cssColorAdjust;
617618
public CssForcedColorAdjust cssForcedColorAdjust;
618619
public CssColorScheme cssColorScheme;
@@ -697,6 +698,7 @@ public class Css3Style extends ATSCStyle {
697698
public CssWrapInside cssWrapInside;
698699
public CssWrapAfter cssWrapAfter;
699700
public CssWrapBefore cssWrapBefore;
701+
public CssTextWrap cssTextWrap;
700702

701703
public CssWrapBefore getWrapBefore() {
702704
if (cssWrapBefore == null) {
@@ -706,7 +708,7 @@ public CssWrapBefore getWrapBefore() {
706708
}
707709
return cssWrapBefore;
708710
}
709-
711+
710712
public CssWrapAfter getWrapAfter() {
711713
if (cssWrapAfter == null) {
712714
cssWrapAfter =
@@ -715,7 +717,7 @@ public CssWrapAfter getWrapAfter() {
715717
}
716718
return cssWrapAfter;
717719
}
718-
720+
719721
public CssWrapInside getWrapInside() {
720722
if (cssWrapInside == null) {
721723
cssWrapInside =
@@ -725,6 +727,15 @@ public CssWrapInside getWrapInside() {
725727
return cssWrapInside;
726728
}
727729

730+
public CssTextWrap getTextWrap() {
731+
if (cssTextWrap == null) {
732+
cssTextWrap =
733+
(CssTextWrap) style.CascadingOrder(new CssTextWrap(),
734+
style, selector);
735+
}
736+
return cssTextWrap;
737+
}
738+
728739
public CssTextWrapStyle getTextWrapStyle() {
729740
if (cssTextWrapStyle == null) {
730741
cssTextWrapStyle =
@@ -733,7 +744,7 @@ public CssTextWrapStyle getTextWrapStyle() {
733744
}
734745
return cssTextWrapStyle;
735746
}
736-
747+
737748
public CssTextWrapMode getTextWrapMode() {
738749
if (cssTextWrapMode == null) {
739750
cssTextWrapMode =
@@ -751,6 +762,7 @@ public CssWordSpaceTransform getWordSpaceTransform() {
751762
}
752763
return cssWordSpaceTransform;
753764
}
765+
754766
public CssContentVisibility getContentVisibility() {
755767
if (cssContentVisibility == null) {
756768
cssContentVisibility =
@@ -759,7 +771,7 @@ public CssContentVisibility getContentVisibility() {
759771
}
760772
return cssContentVisibility;
761773
}
762-
774+
763775
public CssOverscrollBehavior getOverscrollBehavior() {
764776
if (cssOverscrollBehavior == null) {
765777
cssOverscrollBehavior =
@@ -795,7 +807,7 @@ public CssOverscrollBehaviorBlock getOverscrollBehaviorBlock() {
795807
}
796808
return cssOverscrollBehaviorBlock;
797809
}
798-
810+
799811
public CssOverscrollBehaviorInline getOverscrollBehaviorInline() {
800812
if (cssOverscrollBehaviorInline == null) {
801813
cssOverscrollBehaviorInline =
@@ -1461,7 +1473,7 @@ public org.w3c.css.properties.css.fontface.CssFontVariationSettings getFontFaceC
14611473
}
14621474
return fontFaceCssFontVariationSettings;
14631475
}
1464-
1476+
14651477
public CssUnicodeRange getFontFaceCssUnicodeRange() {
14661478
if (fontFaceCssUnicodeRange == null) {
14671479
fontFaceCssUnicodeRange =
@@ -1479,7 +1491,7 @@ public org.w3c.css.properties.css.fontface.CssFontLanguageOverride getFontFaceCs
14791491
}
14801492
return fontFaceCssFontLanguageOverride;
14811493
}
1482-
1494+
14831495
public CssAscentOverride getFontFaceCssAscentOverride() {
14841496
if (fontFaceCssAscentOverride == null) {
14851497
fontFaceCssAscentOverride =
@@ -1515,7 +1527,7 @@ public CssFontNamedInstance getFontFaceCssFontNamedInstance() {
15151527
}
15161528
return fontFaceCssFontNamedInstance;
15171529
}
1518-
1530+
15191531
public CssFontDisplay getFontFaceCssFontDisplay() {
15201532
if (fontFaceCssFontDisplay == null) {
15211533
fontFaceCssFontDisplay =
@@ -1542,7 +1554,7 @@ public CssFontStyle getFontFaceCssFontStyle() {
15421554
}
15431555
return fontFaceCssFontStyle;
15441556
}
1545-
1557+
15461558
public CssFontWeight getFontFaceCssFontWeight() {
15471559
if (fontFaceCssFontWeight == null) {
15481560
fontFaceCssFontWeight =
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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.parser.CssStyle;
9+
import org.w3c.css.util.ApplContext;
10+
import org.w3c.css.util.InvalidParamException;
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+
import org.w3c.css.values.CssValueList;
16+
17+
import java.util.ArrayList;
18+
19+
import static org.w3c.css.values.CssOperator.SPACE;
20+
21+
/**
22+
* @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-wrap
23+
*/
24+
public class CssTextWrap extends org.w3c.css.properties.css.CssTextWrap {
25+
26+
private CssTextWrapMode _longhand_mode;
27+
private CssTextWrapStyle _longhand_style;
28+
29+
/**
30+
* Create a new CssTextWrap
31+
*/
32+
public CssTextWrap() {
33+
value = initial;
34+
_longhand_mode = new CssTextWrapMode();
35+
_longhand_style = new CssTextWrapStyle();
36+
}
37+
38+
/**
39+
* Creates a new CssTextWrap
40+
*
41+
* @param expression The expression for this property
42+
* @throws InvalidParamException Expressions are incorrect
43+
*/
44+
public CssTextWrap(ApplContext ac, CssExpression expression, boolean check)
45+
throws InvalidParamException {
46+
CssValue val;
47+
char op;
48+
ArrayList<CssValue> values = new ArrayList<>();
49+
_longhand_mode = new CssTextWrapMode();
50+
_longhand_style = new CssTextWrapStyle();
51+
boolean _got_mode = false;
52+
boolean _got_style = false;
53+
54+
if (check && expression.getCount() > 2) {
55+
throw new InvalidParamException("unrecognize", ac);
56+
}
57+
setByUser();
58+
59+
for (int i = 0; i < 2 && !expression.end(); i++) {
60+
val = expression.getValue();
61+
op = expression.getOperator();
62+
63+
if (val.getType() != CssTypes.CSS_IDENT) {
64+
throw new InvalidParamException("value", val,
65+
getPropertyName(), ac);
66+
}
67+
if (CssIdent.isCssWide(val.getIdent())) {
68+
if (expression.getCount() > 1) {
69+
throw new InvalidParamException("value",
70+
expression.getValue(),
71+
getPropertyName(), ac);
72+
}
73+
values.add(val);
74+
_longhand_mode.value = val;
75+
_longhand_style.value = val;
76+
break;
77+
} else {
78+
CssIdent id = CssTextWrapMode.getAllowedIdent(val.getIdent());
79+
if (_got_mode && (id != null)) {
80+
throw new InvalidParamException("value",
81+
expression.getValue(),
82+
getPropertyName(), ac);
83+
} else if (id != null) {
84+
values.add(val);
85+
_got_mode = true;
86+
_longhand_mode.value = val;
87+
} else {
88+
id = CssTextWrapStyle.getAllowedIdent(val.getIdent());
89+
if (_got_style || (id == null)) {
90+
throw new InvalidParamException("value",
91+
expression.getValue(),
92+
getPropertyName(), ac);
93+
}
94+
values.add(val);
95+
_got_style = true;
96+
_longhand_style.value = val;
97+
}
98+
}
99+
if (op != SPACE) {
100+
throw new InvalidParamException("operator", op,
101+
getPropertyName(), ac);
102+
}
103+
expression.next();
104+
}
105+
value = (values.size() == 1) ? values.get(0) : new CssValueList(values);
106+
}
107+
108+
public CssTextWrap(ApplContext ac, CssExpression expression)
109+
throws InvalidParamException {
110+
this(ac, expression, false);
111+
}
112+
113+
/**
114+
* Add this property to the CssStyle.
115+
*
116+
* @param style The CssStyle
117+
*/
118+
public void addToStyle(ApplContext ac, CssStyle style) {
119+
super.addToStyle(ac, style);
120+
_longhand_mode.addToStyle(ac, style);
121+
_longhand_style.addToStyle(ac, style);
122+
}
123+
}
124+

0 commit comments

Comments
 (0)