Skip to content

Commit d2c46fd

Browse files
authored
Merge pull request #318 from w3c/scrollbar-1
Scrollbar 1
2 parents 6980354 + 993902a commit d2c46fd

File tree

6 files changed

+562
-0
lines changed

6 files changed

+562
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ scroll-margin-top: org.w3c.css.properties.css3.CssScrollMar
143143
scroll-snap-stop: org.w3c.css.properties.css3.CssScrollSnapStop
144144
scroll-snap-type: org.w3c.css.properties.css3.CssScrollSnapType
145145

146+
#scrollbar
147+
scrollbar-color: org.w3c.css.properties.css3.CssScrollbarColor
148+
scrollbar-width: org.w3c.css.properties.css3.CssScrollbarWidth
149+
146150
# grid
147151
grid: org.w3c.css.properties.css3.CssGrid
148152
grid-area: org.w3c.css.properties.css3.CssGridArea
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021.
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+
import org.w3c.css.values.CssValue;
14+
15+
/**
16+
* @since CSS3
17+
*/
18+
public class CssScrollbarColor extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssScrollbarColor
24+
*/
25+
public CssScrollbarColor() {
26+
}
27+
28+
/**
29+
* Creates a new CssScrollbarColor
30+
*
31+
* @param expression The expression for this property
32+
* @throws InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssScrollbarColor(ApplContext ac, CssExpression expression, //
36+
boolean check) throws InvalidParamException {
37+
throw new InvalidParamException("value",
38+
expression.getValue().toString(),
39+
getPropertyName(), ac);
40+
}
41+
42+
public CssScrollbarColor(ApplContext ac, CssExpression expression)
43+
throws InvalidParamException {
44+
this(ac, expression, false);
45+
}
46+
47+
/**
48+
* Returns the value of this property
49+
*/
50+
public Object get() {
51+
return value;
52+
}
53+
54+
55+
/**
56+
* Returns the name of this property
57+
*/
58+
public final String getPropertyName() {
59+
return "scrollbar-color";
60+
}
61+
62+
/**
63+
* Returns true if this property is "softly" inherited
64+
* e.g. his value is equals to inherit
65+
*/
66+
public boolean isSoftlyInherited() {
67+
return value.equals(inherit);
68+
}
69+
70+
/**
71+
* Returns a string representation of the object.
72+
*/
73+
public String toString() {
74+
return value.toString();
75+
}
76+
77+
/**
78+
* Add this property to the CssStyle.
79+
*
80+
* @param style The CssStyle
81+
*/
82+
public void addToStyle(ApplContext ac, CssStyle style) {
83+
Css3Style s = (Css3Style) style;
84+
if (s.cssScrollbarColor != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssScrollbarColor = this;
88+
}
89+
90+
91+
/**
92+
* Compares two properties for equality.
93+
*
94+
* @param property The other property.
95+
*/
96+
public boolean equals(CssProperty property) {
97+
return (property instanceof CssScrollbarColor &&
98+
value.equals(((CssScrollbarColor) property).value));
99+
}
100+
101+
102+
/**
103+
* Get this property in the style.
104+
*
105+
* @param style The style where the property is
106+
* @param resolve if true, resolve the style to find this property
107+
*/
108+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
109+
if (resolve) {
110+
return ((Css3Style) style).getScrollbarColor();
111+
} else {
112+
return ((Css3Style) style).cssScrollbarColor;
113+
}
114+
}
115+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021.
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+
import org.w3c.css.values.CssValue;
14+
15+
/**
16+
* @since CSS3
17+
*/
18+
public class CssScrollbarWidth extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssScrollbarWidth
24+
*/
25+
public CssScrollbarWidth() {
26+
}
27+
28+
/**
29+
* Creates a new CssScrollbarWidth
30+
*
31+
* @param expression The expression for this property
32+
* @throws InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssScrollbarWidth(ApplContext ac, CssExpression expression, //
36+
boolean check) throws InvalidParamException {
37+
throw new InvalidParamException("value",
38+
expression.getValue().toString(),
39+
getPropertyName(), ac);
40+
}
41+
42+
public CssScrollbarWidth(ApplContext ac, CssExpression expression)
43+
throws InvalidParamException {
44+
this(ac, expression, false);
45+
}
46+
47+
/**
48+
* Returns the value of this property
49+
*/
50+
public Object get() {
51+
return value;
52+
}
53+
54+
55+
/**
56+
* Returns the name of this property
57+
*/
58+
public final String getPropertyName() {
59+
return "scrollbar-width";
60+
}
61+
62+
/**
63+
* Returns true if this property is "softly" inherited
64+
* e.g. his value is equals to inherit
65+
*/
66+
public boolean isSoftlyInherited() {
67+
return value.equals(inherit);
68+
}
69+
70+
/**
71+
* Returns a string representation of the object.
72+
*/
73+
public String toString() {
74+
return value.toString();
75+
}
76+
77+
/**
78+
* Add this property to the CssStyle.
79+
*
80+
* @param style The CssStyle
81+
*/
82+
public void addToStyle(ApplContext ac, CssStyle style) {
83+
Css3Style s = (Css3Style) style;
84+
if (s.cssScrollbarWidth != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssScrollbarWidth = this;
88+
}
89+
90+
91+
/**
92+
* Compares two properties for equality.
93+
*
94+
* @param property The other property.
95+
*/
96+
public boolean equals(CssProperty property) {
97+
return (property instanceof CssScrollbarWidth &&
98+
value.equals(((CssScrollbarWidth) property).value));
99+
}
100+
101+
102+
/**
103+
* Get this property in the style.
104+
*
105+
* @param style The style where the property is
106+
* @param resolve if true, resolve the style to find this property
107+
*/
108+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
109+
if (resolve) {
110+
return ((Css3Style) style).getScrollbarWidth();
111+
} else {
112+
return ((Css3Style) style).cssScrollbarWidth;
113+
}
114+
}
115+
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@
232232
import org.w3c.css.properties.css.CssScrollSnapAlign;
233233
import org.w3c.css.properties.css.CssScrollSnapStop;
234234
import org.w3c.css.properties.css.CssScrollSnapType;
235+
import org.w3c.css.properties.css.CssScrollbarColor;
236+
import org.w3c.css.properties.css.CssScrollbarWidth;
235237
import org.w3c.css.properties.css.CssSpeakAs;
236238
import org.w3c.css.properties.css.CssTabSize;
237239
import org.w3c.css.properties.css.CssTextAlignAll;
@@ -623,7 +625,27 @@ public class Css3Style extends ATSCStyle {
623625
public CssTextDecorationSkipInset cssTextDecorationSkipInset;
624626
public CssTextDecorationSkipInk cssTextDecorationSkipInk;
625627
public CssTextDecorationSkipSpaces cssTextDecorationSkipSpaces;
628+
public CssScrollbarWidth cssScrollbarWidth;
629+
public CssScrollbarColor cssScrollbarColor;
626630

631+
public CssScrollbarColor getScrollbarColor() {
632+
if (cssScrollbarColor == null) {
633+
cssScrollbarColor =
634+
(CssScrollbarColor) style.CascadingOrder(new CssScrollbarColor(),
635+
style, selector);
636+
}
637+
return cssScrollbarColor;
638+
}
639+
640+
public CssScrollbarWidth getScrollbarWidth() {
641+
if (cssScrollbarWidth == null) {
642+
cssScrollbarWidth =
643+
(CssScrollbarWidth) style.CascadingOrder(new CssScrollbarWidth(),
644+
style, selector);
645+
}
646+
return cssScrollbarWidth;
647+
}
648+
627649
public CssTextDecorationSkipSpaces getTextDecorationSkipSpaces() {
628650
if (cssTextDecorationSkipSpaces == null) {
629651
cssTextDecorationSkipSpaces =

0 commit comments

Comments
 (0)