Skip to content

Commit 224aa35

Browse files
committed
1 parent 1b29f64 commit 224aa35

File tree

5 files changed

+232
-0
lines changed

5 files changed

+232
-0
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mask-repeat: org.w3c.css.properties.svg.CssMaskRepeat
3434
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
37+
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
3738
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
3839
fill: org.w3c.css.properties.svg.CssFill
3940
stroke: org.w3c.css.properties.svg.CssStroke

org/w3c/css/properties/SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mask-repeat: org.w3c.css.properties.svg.CssMaskRepeat
4545
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
48+
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
4849
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
4950
stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
5051
projection.stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
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 CssMaskBorderSlice extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssBorderMaskSlice
24+
*/
25+
public CssMaskBorderSlice() {
26+
}
27+
28+
/**
29+
* Creates a new CssBorderMaskSlice
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskBorderSlice(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 CssMaskBorderSlice(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-slice";
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.cssMaskBorderSlice != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskBorderSlice = 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 CssMaskBorderSlice &&
98+
value.equals(((CssMaskBorderSlice) 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).getMaskBorderSlice();
111+
} else {
112+
return ((SVGStyle) style).cssMaskBorderSlice;
113+
}
114+
}
115+
}
116+
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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-slice
22+
*/
23+
public class CssMaskBorderSlice extends org.w3c.css.properties.css.CssMaskBorderSlice {
24+
25+
public static final CssIdent fill = CssIdent.getIdent("fill");
26+
27+
/**
28+
* Create a new CssMaskBorderSlice
29+
*/
30+
public CssMaskBorderSlice() {
31+
value = initial;
32+
}
33+
34+
/**
35+
* Creates a new CssMaskBorderSlice
36+
*
37+
* @param expression The expression for this property
38+
* @throws org.w3c.css.util.InvalidParamException
39+
* Expressions are incorrect
40+
*/
41+
public CssMaskBorderSlice(ApplContext ac, CssExpression expression, boolean check)
42+
throws InvalidParamException {
43+
44+
setByUser();
45+
46+
ArrayList<CssValue> v = new ArrayList<>();
47+
CssValue val;
48+
char op;
49+
int nb_slice = 0;
50+
51+
while (!expression.end()) {
52+
val = expression.getValue();
53+
op = expression.getOperator();
54+
55+
switch (val.getType()) {
56+
case CssTypes.CSS_NUMBER:
57+
case CssTypes.CSS_PERCENTAGE:
58+
val.getCheckableValue().checkPositiveness(ac, this);
59+
if (nb_slice >= 4) {
60+
throw new InvalidParamException("unrecognize", val.toString(),
61+
getPropertyName(), ac);
62+
}
63+
nb_slice++;
64+
v.add(val);
65+
break;
66+
case CssTypes.CSS_IDENT:
67+
if (inherit.equals(val)) {
68+
if (expression.getCount() > 1) {
69+
throw new InvalidParamException("unrecognize", ac);
70+
}
71+
value = inherit;
72+
break;
73+
}
74+
if (fill.equals(val)) {
75+
if (nb_slice == 0 || expression.getRemainingCount() > 1) {
76+
throw new InvalidParamException("unrecognize", ac);
77+
}
78+
v.add(fill);
79+
break;
80+
}
81+
default:
82+
throw new InvalidParamException("value",
83+
val.toString(),
84+
getPropertyName(), ac);
85+
}
86+
expression.next();
87+
if (op != SPACE) {
88+
throw new InvalidParamException("operator",
89+
Character.toString(op),
90+
ac);
91+
}
92+
}
93+
if (!v.isEmpty()) {
94+
value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
95+
}
96+
}
97+
98+
public CssMaskBorderSlice(ApplContext ac, CssExpression expression)
99+
throws InvalidParamException {
100+
this(ac, expression, false);
101+
}
102+
103+
}
104+

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.w3c.css.properties.css.CssMarkerMid;
1414
import org.w3c.css.properties.css.CssMarkerStart;
1515
import org.w3c.css.properties.css.CssMaskBorderMode;
16+
import org.w3c.css.properties.css.CssMaskBorderSlice;
1617
import org.w3c.css.properties.css.CssMaskBorderSource;
1718
import org.w3c.css.properties.css.CssMaskClip;
1819
import org.w3c.css.properties.css.CssMaskComposite;
@@ -51,6 +52,7 @@ public class SVGStyle extends SVGBasicStyle {
5152

5253
public CssMaskBorderSource cssMaskBorderSource;
5354
public CssMaskBorderMode cssMaskBorderMode;
55+
public CssMaskBorderSlice cssMaskBorderSlice;
5456

5557
public CssMaskBorderSource getMaskBorderSource() {
5658
if (cssMaskBorderSource == null) {
@@ -60,6 +62,14 @@ public CssMaskBorderSource getMaskBorderSource() {
6062
return cssMaskBorderSource;
6163
}
6264

65+
public CssMaskBorderSlice getMaskBorderSlice() {
66+
if (cssMaskBorderSlice == null) {
67+
cssMaskBorderSlice = (CssMaskBorderSlice) style.CascadingOrder(new CssMaskBorderSlice(),
68+
style, selector);
69+
}
70+
return cssMaskBorderSlice;
71+
}
72+
6373
public CssMaskBorderMode getMaskBorderMode() {
6474
if (cssMaskBorderMode == null) {
6575
cssMaskBorderMode = (CssMaskBorderMode) style.CascadingOrder(new CssMaskBorderMode(),

0 commit comments

Comments
 (0)