Skip to content

Commit 032af0c

Browse files
committed
1 parent 5ce8f4b commit 032af0c

4 files changed

Lines changed: 194 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
@@ -202,6 +202,7 @@ hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines
202202
hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone
203203
hyphens: org.w3c.css.properties.css3.CssHyphens
204204
line-break: org.w3c.css.properties.css3.CssLineBreak
205+
line-padding: org.w3c.css.properties.css3.CssLinePadding
205206
text-align: org.w3c.css.properties.css3.CssTextAlign
206207
text-align-all: org.w3c.css.properties.css3.CssTextAlignAll
207208
text-align-last: org.w3c.css.properties.css3.CssTextAlignLast
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 World Wide Web Consortium, 2024.
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 CssLinePadding extends CssProperty {
18+
19+
/**
20+
* Create a new CssLinePadding
21+
*/
22+
public CssLinePadding() {
23+
}
24+
25+
/**
26+
* Creates a new CssLinePadding
27+
*
28+
* @param expression The expression for this property
29+
* @throws InvalidParamException Expressions are incorrect
30+
*/
31+
public CssLinePadding(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 CssLinePadding(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 "line-padding";
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.cssLinePadding != null) {
81+
style.addRedefinitionWarning(ac, this);
82+
}
83+
s.cssLinePadding = 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 CssLinePadding &&
94+
value.equals(((CssLinePadding) 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).getLinePadding();
107+
} else {
108+
return ((Css3Style) style).cssLinePadding;
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
@@ -174,6 +174,7 @@
174174
import org.w3c.css.properties.css.CssJustifySelf;
175175
import org.w3c.css.properties.css.CssLightingColor;
176176
import org.w3c.css.properties.css.CssLineBreak;
177+
import org.w3c.css.properties.css.CssLinePadding;
177178
import org.w3c.css.properties.css.CssMarginBlock;
178179
import org.w3c.css.properties.css.CssMarginBlockEnd;
179180
import org.w3c.css.properties.css.CssMarginBlockStart;
@@ -715,7 +716,17 @@ public class Css3Style extends ATSCStyle {
715716
public CssHyphenateLimitLines cssHyphenateLimitLines;
716717
public CssHyphenateLimitLast cssHyphenateLimitLast;
717718
public CssTextGroupAlign cssTextGroupAlign;
719+
public CssLinePadding cssLinePadding;
718720

721+
public CssLinePadding getLinePadding() {
722+
if (cssLinePadding == null) {
723+
cssLinePadding =
724+
(CssLinePadding) style.CascadingOrder(new CssLinePadding(),
725+
style, selector);
726+
}
727+
return cssLinePadding;
728+
}
729+
719730
public CssTextGroupAlign getTextGroupAlign() {
720731
if (cssTextGroupAlign == null) {
721732
cssTextGroupAlign =
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 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-line-padding
17+
*/
18+
public class CssLinePadding extends org.w3c.css.properties.css.CssLinePadding {
19+
20+
/**
21+
* Create a new CssLinePadding
22+
*/
23+
public CssLinePadding() {
24+
value = initial;
25+
}
26+
27+
/**
28+
* Creates a new CssLinePadding
29+
*
30+
* @param expression The expression for this property
31+
* @throws InvalidParamException Expressions are incorrect
32+
*/
33+
public CssLinePadding(ApplContext ac, CssExpression expression, boolean check)
34+
throws InvalidParamException {
35+
setByUser();
36+
CssValue val = expression.getValue();
37+
38+
if (check && expression.getCount() > 1) {
39+
throw new InvalidParamException("unrecognize", ac);
40+
}
41+
42+
switch (val.getType()) {
43+
case CssTypes.CSS_IDENT:
44+
if (CssIdent.isCssWide(val.getIdent())) {
45+
value = val;
46+
break;
47+
}
48+
throw new InvalidParamException("value",
49+
expression.getValue(),
50+
getPropertyName(), ac);
51+
case CssTypes.CSS_NUMBER:
52+
val.getCheckableValue().checkEqualsZero(ac, this);
53+
case CssTypes.CSS_LENGTH:
54+
value = val;
55+
break;
56+
default:
57+
throw new InvalidParamException("value",
58+
expression.getValue(),
59+
getPropertyName(), ac);
60+
}
61+
expression.next();
62+
}
63+
64+
public CssLinePadding(ApplContext ac, CssExpression expression)
65+
throws InvalidParamException {
66+
this(ac, expression, false);
67+
}
68+
69+
}
70+

0 commit comments

Comments
 (0)