Skip to content

Commit 1b29f64

Browse files
committed
1 parent 1f20091 commit 1b29f64

File tree

5 files changed

+236
-3
lines changed

5 files changed

+236
-3
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mask-position: org.w3c.css.properties.svg.CssMaskPositi
3333
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
36+
mask-border-mode: org.w3c.css.properties.svg.CssMaskBorderMode
3637
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
3738
fill: org.w3c.css.properties.svg.CssFill
3839
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
@@ -44,6 +44,7 @@ mask-position: org.w3c.css.properties.svg.CssMaskPosition
4444
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
47+
mask-border-mode: org.w3c.css.properties.svg.CssMaskBorderMode
4748
mask-border-source: org.w3c.css.properties.svg.CssMaskBorderSource
4849
stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
4950
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 CssMaskBorderMode extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssBorderMaskMode
24+
*/
25+
public CssMaskBorderMode() {
26+
}
27+
28+
/**
29+
* Creates a new CssBorderMaskMode
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskBorderMode(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 CssMaskBorderMode(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-mode";
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.cssMaskBorderMode != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskBorderMode = 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 CssMaskBorderMode &&
98+
value.equals(((CssMaskBorderMode) 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).getMaskBorderMode();
111+
} else {
112+
return ((SVGStyle) style).cssMaskBorderMode;
113+
}
114+
}
115+
}
116+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
15+
import static org.w3c.css.values.CssOperator.SPACE;
16+
17+
/**
18+
* @spec https://www.w3.org/TR/2014/CR-css-masking-1-20140826/#propdef-mask-border-mode
19+
*/
20+
public class CssMaskBorderMode extends org.w3c.css.properties.css.CssMaskBorderMode {
21+
22+
public static final CssIdent[] allowed_values;
23+
24+
static {
25+
String[] _allowed_values = {"alpha", "luminance"};
26+
allowed_values = new CssIdent[_allowed_values.length];
27+
int i = 0;
28+
for (String s : _allowed_values) {
29+
allowed_values[i++] = CssIdent.getIdent(s);
30+
}
31+
}
32+
33+
public static CssIdent getAllowedIdent(CssIdent ident) {
34+
for (CssIdent id : allowed_values) {
35+
if (id.equals(ident)) {
36+
return id;
37+
}
38+
}
39+
return null;
40+
}
41+
42+
43+
/**
44+
* Create a new CssMaskBorderMode
45+
*/
46+
public CssMaskBorderMode() {
47+
value = initial;
48+
}
49+
50+
/**
51+
* Creates a new CssMaskBorderMode
52+
*
53+
* @param expression The expression for this property
54+
* @throws org.w3c.css.util.InvalidParamException
55+
* Expressions are incorrect
56+
*/
57+
public CssMaskBorderMode(ApplContext ac, CssExpression expression, boolean check)
58+
throws InvalidParamException {
59+
60+
setByUser();
61+
62+
if (check && expression.getCount() > 1) {
63+
throw new InvalidParamException("unrecognize", ac);
64+
}
65+
66+
CssValue val;
67+
char op;
68+
69+
val = expression.getValue();
70+
op = expression.getOperator();
71+
72+
switch (val.getType()) {
73+
case CssTypes.CSS_IDENT:
74+
if (inherit.equals(val)) {
75+
if (expression.getCount() > 1) {
76+
throw new InvalidParamException("unrecognize", ac);
77+
}
78+
value = inherit;
79+
break;
80+
}
81+
CssIdent id = getAllowedIdent((CssIdent) val);
82+
if (id != null) {
83+
value = id;
84+
break;
85+
}
86+
default:
87+
throw new InvalidParamException("value",
88+
val.toString(),
89+
getPropertyName(), ac);
90+
}
91+
expression.next();
92+
if (op != SPACE) {
93+
throw new InvalidParamException("operator",
94+
Character.toString(op),
95+
ac);
96+
}
97+
}
98+
99+
public CssMaskBorderMode(ApplContext ac, CssExpression expression)
100+
throws InvalidParamException {
101+
this(ac, expression, false);
102+
}
103+
104+
}
105+

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
package org.w3c.css.properties.svg;
1010

11-
import org.w3c.css.properties.css.CssMaskBorderSource;
1211
import org.w3c.css.properties.css.CssMarker;
1312
import org.w3c.css.properties.css.CssMarkerEnd;
1413
import org.w3c.css.properties.css.CssMarkerMid;
1514
import org.w3c.css.properties.css.CssMarkerStart;
15+
import org.w3c.css.properties.css.CssMaskBorderMode;
16+
import org.w3c.css.properties.css.CssMaskBorderSource;
1617
import org.w3c.css.properties.css.CssMaskClip;
1718
import org.w3c.css.properties.css.CssMaskComposite;
1819
import org.w3c.css.properties.css.CssMaskImage;
@@ -47,8 +48,9 @@ public class SVGStyle extends SVGBasicStyle {
4748
public CssMaskRepeat cssMaskRepeat;
4849
public CssMaskSize cssMaskSize;
4950
public CssMaskType cssMaskType;
50-
51+
5152
public CssMaskBorderSource cssMaskBorderSource;
53+
public CssMaskBorderMode cssMaskBorderMode;
5254

5355
public CssMaskBorderSource getMaskBorderSource() {
5456
if (cssMaskBorderSource == null) {
@@ -58,6 +60,14 @@ public CssMaskBorderSource getMaskBorderSource() {
5860
return cssMaskBorderSource;
5961
}
6062

63+
public CssMaskBorderMode getMaskBorderMode() {
64+
if (cssMaskBorderMode == null) {
65+
cssMaskBorderMode = (CssMaskBorderMode) style.CascadingOrder(new CssMaskBorderMode(),
66+
style, selector);
67+
}
68+
return cssMaskBorderMode;
69+
}
70+
6171
public CssMaskType getMaskType() {
6272
if (cssMaskType == null) {
6373
cssMaskType = (CssMaskType) style.CascadingOrder(new CssMaskType(),
@@ -73,7 +83,7 @@ public CssMaskSize getMaskSize() {
7383
}
7484
return cssMaskSize;
7585
}
76-
86+
7787
public CssMaskPosition getMaskPosition() {
7888
if (cssMaskPosition == null) {
7989
cssMaskPosition = (CssMaskPosition) style.CascadingOrder(new CssMaskPosition(),

0 commit comments

Comments
 (0)