Skip to content

Commit 629ef67

Browse files
committed
1 parent a20b163 commit 629ef67

File tree

4 files changed

+239
-0
lines changed

4 files changed

+239
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ overflow-clip-margin: org.w3c.css.properties.css3.CssOverflowClipMargin
523523
overflow-inline: org.w3c.css.properties.css3.CssOverflowInline
524524
overflow-x: org.w3c.css.properties.css3.CssOverflowX
525525
overflow-y: org.w3c.css.properties.css3.CssOverflowY
526+
scrollbar-gutter: org.w3c.css.properties.css3.CssScrollbarGutter
526527
ruby-span: org.w3c.css.properties.css3.CssRubySpan
527528

528529
filter: org.w3c.css.properties.css3.CssFilter
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 CssScrollbarGutter extends CssProperty {
18+
19+
20+
/**
21+
* Create a new CssScrollbarGutter
22+
*/
23+
public CssScrollbarGutter() {
24+
}
25+
26+
/**
27+
* Creates a new CssScrollbarGutter
28+
*
29+
* @param expression The expression for this property
30+
* @throws InvalidParamException
31+
* Expressions are incorrect
32+
*/
33+
public CssScrollbarGutter(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 CssScrollbarGutter(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 "scrollbar-gutter";
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).cssScrollbarGutter != null)
82+
style.addRedefinitionWarning(ac, this);
83+
((Css3Style) style).cssScrollbarGutter = 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 CssScrollbarGutter &&
93+
value.equals(((CssScrollbarGutter) 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).getScrollbarGutter();
106+
} else {
107+
return ((Css3Style) style).cssScrollbarGutter;
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
@@ -262,6 +262,7 @@
262262
import org.w3c.css.properties.css.CssScrollSnapStop;
263263
import org.w3c.css.properties.css.CssScrollSnapType;
264264
import org.w3c.css.properties.css.CssScrollbarColor;
265+
import org.w3c.css.properties.css.CssScrollbarGutter;
265266
import org.w3c.css.properties.css.CssScrollbarWidth;
266267
import org.w3c.css.properties.css.CssSpeakAs;
267268
import org.w3c.css.properties.css.CssTabSize;
@@ -596,6 +597,7 @@ public class Css3Style extends ATSCStyle {
596597
public CssOverflowBlock cssOverflowBlock;
597598
public CssOverflowInline cssOverflowInline;
598599
public CssOverflowClipMargin cssOverflowClipMargin;
600+
public CssScrollbarGutter cssScrollbarGutter;
599601

600602
public CssObjectFit cssObjectFit;
601603
public CssObjectPosition cssObjectPosition;
@@ -3037,6 +3039,15 @@ public CssOverflowClipMargin getOverflowClipMargin() {
30373039
return cssOverflowClipMargin;
30383040
}
30393041

3042+
public CssScrollbarGutter getScrollbarGutter() {
3043+
if (cssScrollbarGutter == null) {
3044+
cssScrollbarGutter =
3045+
(CssScrollbarGutter) style.CascadingOrder(
3046+
new CssScrollbarGutter(), style, selector);
3047+
}
3048+
return cssScrollbarGutter;
3049+
}
3050+
30403051
public CssRubySpan getRubySpan() {
30413052
if (cssRubySpan == null) {
30423053
cssRubySpan =
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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-scrollbar-gutter
22+
*/
23+
public class CssScrollbarGutter extends org.w3c.css.properties.css.CssScrollbarGutter {
24+
25+
private static CssIdent auto, stable, both_edges;
26+
27+
static {
28+
auto = new CssIdent("auto");
29+
stable = new CssIdent("stable");
30+
both_edges = new CssIdent("both-edges");
31+
}
32+
33+
/**
34+
* Create a new CssScrollbarGutter
35+
*/
36+
public CssScrollbarGutter() {
37+
value = initial;
38+
}
39+
40+
/**
41+
* Creates a new CssScrollbarGutter
42+
*
43+
* @param expression The expression for this property
44+
* @throws InvalidParamException Expressions are incorrect
45+
*/
46+
public CssScrollbarGutter(ApplContext ac, CssExpression expression, boolean check)
47+
throws InvalidParamException {
48+
setByUser();
49+
50+
boolean got_stable = false;
51+
boolean got_both_edges = false;
52+
CssValue val;
53+
char op;
54+
55+
if (check && expression.getCount() > 2) {
56+
throw new InvalidParamException("unrecognize", ac);
57+
}
58+
59+
ArrayList<CssValue> v = new ArrayList<CssValue>();
60+
61+
while (!expression.end()) {
62+
val = expression.getValue();
63+
op = expression.getOperator();
64+
65+
switch (val.getType()) {
66+
case CssTypes.CSS_IDENT:
67+
CssIdent id = val.getIdent();
68+
if (CssIdent.isCssWide(id) || auto.equals(id)) {
69+
if (expression.getCount() > 1) {
70+
throw new InvalidParamException("value", val,
71+
getPropertyName(), ac);
72+
}
73+
v.add(val);
74+
break;
75+
}
76+
if (stable.equals(id)) {
77+
if (!got_stable) {
78+
v.add(val);
79+
got_stable = true;
80+
break;
81+
}
82+
}
83+
if (both_edges.equals(id)) {
84+
if (!got_both_edges) {
85+
v.add(val);
86+
got_both_edges = true;
87+
break;
88+
}
89+
}
90+
// let it fail
91+
default:
92+
throw new InvalidParamException("value", val,
93+
getPropertyName(), ac);
94+
}
95+
if (op != SPACE) {
96+
throw new InvalidParamException("operator", val,
97+
getPropertyName(), ac);
98+
}
99+
expression.next();
100+
}
101+
// per grammar, both-edges cannot be alone
102+
if (got_both_edges && !got_stable) {
103+
throw new InvalidParamException("value", both_edges,
104+
getPropertyName(), ac);
105+
}
106+
value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
107+
}
108+
109+
public CssScrollbarGutter(ApplContext ac, CssExpression expression)
110+
throws InvalidParamException {
111+
this(ac, expression, false);
112+
}
113+
114+
115+
}
116+

0 commit comments

Comments
 (0)