Skip to content

Commit cec49d9

Browse files
committed
1 parent 224aa35 commit cec49d9

File tree

5 files changed

+239
-0
lines changed

5 files changed

+239
-0
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ mask-type: org.w3c.css.properties.svg.CssMaskType
3636
mask-border-mode: org.w3c.css.properties.svg.CssMaskBorderMode
3737
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
3838
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
39+
mask-border-width: org.w3c.css.properties.svg.CssMaskBorderWidth
3940
fill: org.w3c.css.properties.svg.CssFill
4041
stroke: org.w3c.css.properties.svg.CssStroke
4142
color-profile: org.w3c.css.properties.svg.CssColorProfile

org/w3c/css/properties/SVGProperties.properties

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.w3c.css.properties.css.CssMaskBorderMode;
1616
import org.w3c.css.properties.css.CssMaskBorderSlice;
1717
import org.w3c.css.properties.css.CssMaskBorderSource;
18+
import org.w3c.css.properties.css.CssMaskBorderWidth;
1819
import org.w3c.css.properties.css.CssMaskClip;
1920
import org.w3c.css.properties.css.CssMaskComposite;
2021
import org.w3c.css.properties.css.CssMaskImage;
@@ -53,7 +54,16 @@ public class SVGStyle extends SVGBasicStyle {
5354
public CssMaskBorderSource cssMaskBorderSource;
5455
public CssMaskBorderMode cssMaskBorderMode;
5556
public CssMaskBorderSlice cssMaskBorderSlice;
57+
public CssMaskBorderWidth cssMaskBorderWidth;
5658

59+
public CssMaskBorderWidth getMaskBorderWidth() {
60+
if (cssMaskBorderWidth == null) {
61+
cssMaskBorderWidth = (CssMaskBorderWidth) style.CascadingOrder(new CssMaskBorderWidth(),
62+
style, selector);
63+
}
64+
return cssMaskBorderWidth;
65+
}
66+
5767
public CssMaskBorderSource getMaskBorderSource() {
5868
if (cssMaskBorderSource == null) {
5969
cssMaskBorderSource = (CssMaskBorderSource) style.CascadingOrder(new CssMaskBorderSource(),

0 commit comments

Comments
 (0)