Skip to content

Commit 0cfd610

Browse files
committed
1 parent cec49d9 commit 0cfd610

File tree

5 files changed

+220
-0
lines changed

5 files changed

+220
-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-outset: org.w3c.css.properties.svg.CssMaskBorderOutset
3738
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
3839
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
3940
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
@@ -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-outset: org.w3c.css.properties.svg.CssMaskBorderOutset
4849
mask-border-slice: org.w3c.css.properties.svg.CssMaskBorderSlice
4950
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
5051
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 CssMaskBorderOutset extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssBorderMaskOutset
24+
*/
25+
public CssMaskBorderOutset() {
26+
}
27+
28+
/**
29+
* Creates a new CssBorderMaskOutset
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskBorderOutset(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 CssMaskBorderOutset(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-outset";
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.cssMaskBorderOutset != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskBorderOutset = 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 CssMaskBorderOutset &&
98+
value.equals(((CssMaskBorderOutset) 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).getMaskBorderOutset();
111+
} else {
112+
return ((SVGStyle) style).cssMaskBorderOutset;
113+
}
114+
}
115+
}
116+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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.CssTypes;
12+
import org.w3c.css.values.CssValue;
13+
import org.w3c.css.values.CssValueList;
14+
15+
import java.util.ArrayList;
16+
17+
import static org.w3c.css.values.CssOperator.SPACE;
18+
19+
/**
20+
* @spec https://www.w3.org/TR/2014/CR-css-masking-1-20140826/#propdef-mask-border-outset
21+
*/
22+
public class CssMaskBorderOutset extends org.w3c.css.properties.css.CssMaskBorderOutset {
23+
24+
/**
25+
* Create a new CssMaskBorderOutset
26+
*/
27+
public CssMaskBorderOutset() {
28+
value = initial;
29+
}
30+
31+
/**
32+
* Creates a new CssMaskBorderOutset
33+
*
34+
* @param expression The expression for this property
35+
* @throws org.w3c.css.util.InvalidParamException
36+
* Expressions are incorrect
37+
*/
38+
public CssMaskBorderOutset(ApplContext ac, CssExpression expression, boolean check)
39+
throws InvalidParamException {
40+
41+
setByUser();
42+
43+
ArrayList<CssValue> v = new ArrayList<>();
44+
CssValue val;
45+
char op;
46+
47+
if (check && expression.getCount() > 4) {
48+
throw new InvalidParamException("unrecognize", ac);
49+
}
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_LENGTH:
58+
val.getCheckableValue().checkPositiveness(ac, this);
59+
v.add(val);
60+
break;
61+
case CssTypes.CSS_IDENT:
62+
if (inherit.equals(val)) {
63+
if (expression.getCount() > 1) {
64+
throw new InvalidParamException("unrecognize", ac);
65+
}
66+
value = inherit;
67+
break;
68+
}
69+
default:
70+
throw new InvalidParamException("value",
71+
val.toString(),
72+
getPropertyName(), ac);
73+
}
74+
expression.next();
75+
if (op != SPACE) {
76+
throw new InvalidParamException("operator",
77+
Character.toString(op),
78+
ac);
79+
}
80+
}
81+
if (!v.isEmpty()) {
82+
value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
83+
}
84+
}
85+
86+
public CssMaskBorderOutset(ApplContext ac, CssExpression expression)
87+
throws InvalidParamException {
88+
this(ac, expression, false);
89+
}
90+
91+
}
92+

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.CssMaskBorderOutset;
1617
import org.w3c.css.properties.css.CssMaskBorderSlice;
1718
import org.w3c.css.properties.css.CssMaskBorderSource;
1819
import org.w3c.css.properties.css.CssMaskBorderWidth;
@@ -55,6 +56,7 @@ public class SVGStyle extends SVGBasicStyle {
5556
public CssMaskBorderMode cssMaskBorderMode;
5657
public CssMaskBorderSlice cssMaskBorderSlice;
5758
public CssMaskBorderWidth cssMaskBorderWidth;
59+
public CssMaskBorderOutset cssMaskBorderOutset;
5860

5961
public CssMaskBorderWidth getMaskBorderWidth() {
6062
if (cssMaskBorderWidth == null) {
@@ -79,6 +81,14 @@ public CssMaskBorderSlice getMaskBorderSlice() {
7981
}
8082
return cssMaskBorderSlice;
8183
}
84+
85+
public CssMaskBorderOutset getMaskBorderOutset() {
86+
if (cssMaskBorderOutset == null) {
87+
cssMaskBorderOutset = (CssMaskBorderOutset) style.CascadingOrder(new CssMaskBorderOutset(),
88+
style, selector);
89+
}
90+
return cssMaskBorderOutset;
91+
}
8292

8393
public CssMaskBorderMode getMaskBorderMode() {
8494
if (cssMaskBorderMode == null) {

0 commit comments

Comments
 (0)