Skip to content

Commit 11b79f3

Browse files
committed
1 parent 0cfd610 commit 11b79f3

File tree

5 files changed

+244
-0
lines changed

5 files changed

+244
-0
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mask-size: org.w3c.css.properties.svg.CssMaskSize
3535
mask-type: org.w3c.css.properties.svg.CssMaskType
3636
mask-border-mode: org.w3c.css.properties.svg.CssMaskBorderMode
3737
mask-border-outset: org.w3c.css.properties.svg.CssMaskBorderOutset
38+
mask-border-repeat: org.w3c.css.properties.svg.CssMaskBorderRepeat
3839
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
3940
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
4041
mask-border-width: org.w3c.css.properties.svg.CssMaskBorderWidth

org/w3c/css/properties/SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mask-size: org.w3c.css.properties.svg.CssMaskSize
4646
mask-type: org.w3c.css.properties.svg.CssMaskType
4747
mask-border-mode: org.w3c.css.properties.svg.CssMaskBorderMode
4848
mask-border-outset: org.w3c.css.properties.svg.CssMaskBorderOutset
49+
mask-border-repeat: org.w3c.css.properties.svg.CssMaskBorderRepeat
4950
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
5051
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
5152
mask-border-width: org.w3c.css.properties.svg.CssMaskBorderWidth
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 MIT, ERCIM, Keio, Beihang, 2018.
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.svg.SVGStyle;
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 SVG
17+
*/
18+
public class CssMaskBorderRepeat extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssBorderMaskRepeat
24+
*/
25+
public CssMaskBorderRepeat() {
26+
}
27+
28+
/**
29+
* Creates a new CssBorderMaskRepeat
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskBorderRepeat(ApplContext ac, CssExpression expression, boolean check)
36+
throws InvalidParamException {
37+
throw new InvalidParamException("value",
38+
expression.getValue().toString(),
39+
getPropertyName(), ac);
40+
}
41+
42+
public CssMaskBorderRepeat(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 "mask-border-repeat";
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+
SVGStyle s = (SVGStyle) style;
84+
if (s.cssMaskBorderRepeat != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskBorderRepeat = 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 CssMaskBorderRepeat &&
98+
value.equals(((CssMaskBorderRepeat) 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 ((SVGStyle) style).getMaskBorderRepeat();
111+
} else {
112+
return ((SVGStyle) style).cssMaskBorderRepeat;
113+
}
114+
}
115+
}
116+
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 MIT, ERCIM, Keio, Beihang, 2018.
5+
// Please first read the full copyright statement in file COPYRIGHT.html
6+
package org.w3c.css.properties.svg;
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/2014/CR-css-masking-1-20140826/#propdef-mask-border-repeat
22+
*/
23+
public class CssMaskBorderRepeat extends org.w3c.css.properties.css.CssMaskBorderRepeat {
24+
25+
public static final CssIdent[] allowed_values;
26+
27+
static {
28+
String[] _allowed_values = {"stretch", "repeat", "round", "space"};
29+
allowed_values = new CssIdent[_allowed_values.length];
30+
int i = 0;
31+
for (String s : _allowed_values) {
32+
allowed_values[i++] = CssIdent.getIdent(s);
33+
}
34+
}
35+
36+
public static CssIdent getAllowedIdent(CssIdent ident) {
37+
for (CssIdent id : allowed_values) {
38+
if (id.equals(ident)) {
39+
return id;
40+
}
41+
}
42+
return null;
43+
}
44+
45+
46+
/**
47+
* Create a new CssMaskBorderRepeat
48+
*/
49+
public CssMaskBorderRepeat() {
50+
value = initial;
51+
}
52+
53+
/**
54+
* Creates a new CssMaskBorderRepeat
55+
*
56+
* @param expression The expression for this property
57+
* @throws org.w3c.css.util.InvalidParamException
58+
* Expressions are incorrect
59+
*/
60+
public CssMaskBorderRepeat(ApplContext ac, CssExpression expression, boolean check)
61+
throws InvalidParamException {
62+
63+
ArrayList<CssValue> v = new ArrayList<CssValue>();
64+
setByUser();
65+
66+
if (check && expression.getCount() > 2) {
67+
throw new InvalidParamException("unrecognize", ac);
68+
}
69+
70+
CssValue val;
71+
char op;
72+
73+
while (!expression.end()) {
74+
val = expression.getValue();
75+
op = expression.getOperator();
76+
77+
78+
switch (val.getType()) {
79+
case CssTypes.CSS_IDENT:
80+
if (inherit.equals(val)) {
81+
if (expression.getCount() > 1) {
82+
throw new InvalidParamException("unrecognize", ac);
83+
}
84+
value = inherit;
85+
break;
86+
}
87+
CssIdent id = getAllowedIdent((CssIdent) val);
88+
if (id != null) {
89+
v.add(id);
90+
break;
91+
}
92+
default:
93+
throw new InvalidParamException("value",
94+
val.toString(),
95+
getPropertyName(), ac);
96+
}
97+
expression.next();
98+
if (op != SPACE) {
99+
throw new InvalidParamException("operator",
100+
Character.toString(op),
101+
ac);
102+
}
103+
}
104+
if (!v.isEmpty()) {
105+
value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
106+
}
107+
108+
}
109+
110+
public CssMaskBorderRepeat(ApplContext ac, CssExpression expression)
111+
throws InvalidParamException {
112+
this(ac, expression, false);
113+
}
114+
115+
}
116+

org/w3c/css/properties/svg/SVGStyle.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.w3c.css.properties.css.CssMarkerStart;
1515
import org.w3c.css.properties.css.CssMaskBorderMode;
1616
import org.w3c.css.properties.css.CssMaskBorderOutset;
17+
import org.w3c.css.properties.css.CssMaskBorderRepeat;
1718
import org.w3c.css.properties.css.CssMaskBorderSlice;
1819
import org.w3c.css.properties.css.CssMaskBorderSource;
1920
import org.w3c.css.properties.css.CssMaskBorderWidth;
@@ -57,6 +58,7 @@ public class SVGStyle extends SVGBasicStyle {
5758
public CssMaskBorderSlice cssMaskBorderSlice;
5859
public CssMaskBorderWidth cssMaskBorderWidth;
5960
public CssMaskBorderOutset cssMaskBorderOutset;
61+
public CssMaskBorderRepeat cssMaskBorderRepeat;
6062

6163
public CssMaskBorderWidth getMaskBorderWidth() {
6264
if (cssMaskBorderWidth == null) {
@@ -82,6 +84,14 @@ public CssMaskBorderSlice getMaskBorderSlice() {
8284
return cssMaskBorderSlice;
8385
}
8486

87+
public CssMaskBorderRepeat getMaskBorderRepeat() {
88+
if (cssMaskBorderRepeat == null) {
89+
cssMaskBorderRepeat = (CssMaskBorderRepeat) style.CascadingOrder(new CssMaskBorderRepeat(),
90+
style, selector);
91+
}
92+
return cssMaskBorderRepeat;
93+
}
94+
8595
public CssMaskBorderOutset getMaskBorderOutset() {
8696
if (cssMaskBorderOutset == null) {
8797
cssMaskBorderOutset = (CssMaskBorderOutset) style.CascadingOrder(new CssMaskBorderOutset(),

0 commit comments

Comments
 (0)