Skip to content

Commit 0180af2

Browse files
committed
1 parent 283ee60 commit 0180af2

File tree

4 files changed

+246
-0
lines changed

4 files changed

+246
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ nav-right: org.w3c.css.properties.css3.CssNavRight
519519
nav-down: org.w3c.css.properties.css3.CssNavDown
520520
nav-left: org.w3c.css.properties.css3.CssNavLeft
521521
overflow-block: org.w3c.css.properties.css3.CssOverflowBlock
522+
overflow-clip-margin: org.w3c.css.properties.css3.CssOverflowClipMargin
522523
overflow-inline: org.w3c.css.properties.css3.CssOverflowInline
523524
overflow-x: org.w3c.css.properties.css3.CssOverflowX
524525
overflow-y: org.w3c.css.properties.css3.CssOverflowY
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT W3C, 2026.
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 CssOverflowClipMargin extends CssProperty {
18+
19+
20+
/**
21+
* Create a new CssOverflowClipMargin
22+
*/
23+
public CssOverflowClipMargin() {
24+
}
25+
26+
/**
27+
* Creates a new CssOverflowClipMargin
28+
*
29+
* @param expression The expression for this property
30+
* @throws InvalidParamException
31+
* Expressions are incorrect
32+
*/
33+
public CssOverflowClipMargin(ApplContext ac, CssExpression expression, boolean check)
34+
throws InvalidParamException {
35+
throw new InvalidParamException("value",
36+
expression.getValue().toString(),
37+
getPropertyName(), ac);
38+
}
39+
40+
public CssOverflowClipMargin(ApplContext ac, CssExpression expression)
41+
throws InvalidParamException {
42+
this(ac, expression, false);
43+
}
44+
45+
/**
46+
* Returns the value of this property
47+
*/
48+
public Object get() {
49+
return value;
50+
}
51+
52+
53+
/**
54+
* Returns the name of this property
55+
*/
56+
public final String getPropertyName() {
57+
return "overflow-clip-margin";
58+
}
59+
60+
/**
61+
* Returns true if this property is "softly" inherited
62+
* e.g. his value is equals to inherit
63+
*/
64+
public boolean isSoftlyInherited() {
65+
return inherit.equals(value);
66+
}
67+
68+
/**
69+
* Returns a string representation of the object.
70+
*/
71+
public String toString() {
72+
return value.toString();
73+
}
74+
75+
/**
76+
* Add this property to the CssStyle.
77+
*
78+
* @param style The CssStyle
79+
*/
80+
public void addToStyle(ApplContext ac, CssStyle style) {
81+
if (((Css3Style) style).cssOverflowClipMargin != null)
82+
style.addRedefinitionWarning(ac, this);
83+
((Css3Style) style).cssOverflowClipMargin = this;
84+
}
85+
86+
/**
87+
* Compares two properties for equality.
88+
*
89+
* @param property The other property.
90+
*/
91+
public boolean equals(CssProperty property) {
92+
return (property instanceof CssOverflowClipMargin &&
93+
value.equals(((CssOverflowClipMargin) property).value));
94+
}
95+
96+
97+
/**
98+
* Get this property in the style.
99+
*
100+
* @param style The style where the property is
101+
* @param resolve if true, resolve the style to find this property
102+
*/
103+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
104+
if (resolve) {
105+
return ((Css3Style) style).getOverflowClipMargin();
106+
} else {
107+
return ((Css3Style) style).cssOverflowClipMargin;
108+
}
109+
}
110+
}
111+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
import org.w3c.css.properties.css.CssOutlineOffset;
203203
import org.w3c.css.properties.css.CssOverflowAnchor;
204204
import org.w3c.css.properties.css.CssOverflowBlock;
205+
import org.w3c.css.properties.css.CssOverflowClipMargin;
205206
import org.w3c.css.properties.css.CssOverflowInline;
206207
import org.w3c.css.properties.css.CssOverflowStyle;
207208
import org.w3c.css.properties.css.CssOverflowWrap;
@@ -594,6 +595,7 @@ public class Css3Style extends ATSCStyle {
594595
public CssOverflowY cssOverflowY;
595596
public CssOverflowBlock cssOverflowBlock;
596597
public CssOverflowInline cssOverflowInline;
598+
public CssOverflowClipMargin cssOverflowClipMargin;
597599

598600
public CssObjectFit cssObjectFit;
599601
public CssObjectPosition cssObjectPosition;
@@ -3026,6 +3028,15 @@ public CssOverflowInline getOverflowInline() {
30263028
return cssOverflowInline;
30273029
}
30283030

3031+
public CssOverflowClipMargin getOverflowClipMargin() {
3032+
if (cssOverflowClipMargin == null) {
3033+
cssOverflowClipMargin =
3034+
(CssOverflowClipMargin) style.CascadingOrder(
3035+
new CssOverflowClipMargin(), style, selector);
3036+
}
3037+
return cssOverflowClipMargin;
3038+
}
3039+
30293040
public CssRubySpan getRubySpan() {
30303041
if (cssRubySpan == null) {
30313042
cssRubySpan =
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT W3C, 2026.
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+
import org.w3c.css.values.CssValueList;
15+
16+
import java.util.ArrayList;
17+
18+
import static org.w3c.css.values.CssOperator.SPACE;
19+
20+
/**
21+
* @spec https://www.w3.org/TR/2025/WD-css-overflow-3-20251007/#propdef-overflow-clip-margin
22+
*/
23+
public class CssOverflowClipMargin extends org.w3c.css.properties.css.CssOverflowClipMargin {
24+
25+
private static CssIdent[] visual_box_values;
26+
27+
static {
28+
String id_values[] = {"content-box", "padding-box", "border-box"};
29+
visual_box_values = new CssIdent[id_values.length];
30+
int i = 0;
31+
for (String s : id_values) {
32+
visual_box_values[i++] = CssIdent.getIdent(s);
33+
}
34+
}
35+
36+
public static CssIdent getVisualBoxIdent(CssIdent ident) {
37+
for (CssIdent id : visual_box_values) {
38+
if (id.equals(ident)) {
39+
return id;
40+
}
41+
}
42+
return null;
43+
}
44+
45+
/**
46+
* Create a new CssOverflowClipMargin
47+
*/
48+
public CssOverflowClipMargin() {
49+
value = initial;
50+
}
51+
52+
/**
53+
* Creates a new CssOverflowClipMargin
54+
*
55+
* @param expression The expression for this property
56+
* @throws InvalidParamException Expressions are incorrect
57+
*/
58+
public CssOverflowClipMargin(ApplContext ac, CssExpression expression, boolean check)
59+
throws InvalidParamException {
60+
setByUser();
61+
62+
boolean got_length = false;
63+
boolean got_visualbox = false;
64+
CssValue val;
65+
char op;
66+
67+
if (check && expression.getCount() > 2) {
68+
throw new InvalidParamException("unrecognize", ac);
69+
}
70+
71+
ArrayList<CssValue> v = new ArrayList<CssValue>();
72+
73+
while (!expression.end()) {
74+
val = expression.getValue();
75+
op = expression.getOperator();
76+
77+
switch (val.getType()) {
78+
case CssTypes.CSS_NUMBER:
79+
val.getCheckableValue().checkEqualsZero(ac, this);
80+
case CssTypes.CSS_LENGTH:
81+
val.getCheckableValue().checkPositiveness(ac, this);
82+
if (got_length) {
83+
throw new InvalidParamException("value", val, getPropertyName(), ac);
84+
}
85+
v.add(val);
86+
got_length = true;
87+
break;
88+
case CssTypes.CSS_IDENT:
89+
CssIdent id = val.getIdent();
90+
if (CssIdent.isCssWide(id) && expression.getCount() > 1) {
91+
throw new InvalidParamException("value", val,
92+
getPropertyName(), ac);
93+
}
94+
if (getVisualBoxIdent(id) != null) {
95+
if (got_visualbox) {
96+
throw new InvalidParamException("value", val,
97+
getPropertyName(), ac);
98+
}
99+
v.add(val);
100+
got_visualbox = true;
101+
break;
102+
}
103+
default:
104+
throw new InvalidParamException("value", val,
105+
getPropertyName(), ac);
106+
}
107+
if (op != SPACE) {
108+
throw new InvalidParamException("operator", val,
109+
getPropertyName(), ac);
110+
}
111+
expression.next();
112+
}
113+
value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
114+
}
115+
116+
public CssOverflowClipMargin(ApplContext ac, CssExpression expression)
117+
throws InvalidParamException {
118+
this(ac, expression, false);
119+
}
120+
121+
122+
}
123+

0 commit comments

Comments
 (0)