Skip to content

Commit 1f20091

Browse files
committed
1 parent a8b9239 commit 1f20091

File tree

5 files changed

+225
-0
lines changed

5 files changed

+225
-0
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-source: org.w3c.css.properties.svg.CssMaskBorderSource
3637
fill: org.w3c.css.properties.svg.CssFill
3738
stroke: org.w3c.css.properties.svg.CssStroke
3839
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
@@ -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-source: org.w3c.css.properties.svg.CssMaskBorderSource
4748
stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
4849
projection.stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
4950
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 CssMaskBorderSource extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssBorderMaskSource
24+
*/
25+
public CssMaskBorderSource() {
26+
}
27+
28+
/**
29+
* Creates a new CssBorderMaskSource
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskBorderSource(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 CssMaskBorderSource(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-source";
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.cssMaskBorderSource != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskBorderSource = 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 CssMaskBorderSource &&
98+
value.equals(((CssMaskBorderSource) 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).getMaskBorderSource();
111+
} else {
112+
return ((SVGStyle) style).cssMaskBorderSource;
113+
}
114+
}
115+
}
116+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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-source
19+
*/
20+
public class CssMaskBorderSource extends org.w3c.css.properties.css.CssMaskBorderSource {
21+
22+
public static CssIdent getAllowedIdent(CssIdent ident) {
23+
if (none.equals(ident)) {
24+
return none;
25+
}
26+
return null;
27+
}
28+
29+
30+
/**
31+
* Create a new CssMaskBorderSource
32+
*/
33+
public CssMaskBorderSource() {
34+
value = initial;
35+
}
36+
37+
/**
38+
* Creates a new CssMaskBorderSource
39+
*
40+
* @param expression The expression for this property
41+
* @throws org.w3c.css.util.InvalidParamException
42+
* Expressions are incorrect
43+
*/
44+
public CssMaskBorderSource(ApplContext ac, CssExpression expression, boolean check)
45+
throws InvalidParamException {
46+
47+
setByUser();
48+
49+
CssValue val;
50+
char op;
51+
52+
if (check && expression.getCount() > 1) {
53+
throw new InvalidParamException("unrecognize", ac);
54+
}
55+
56+
val = expression.getValue();
57+
op = expression.getOperator();
58+
59+
switch (val.getType()) {
60+
case CssTypes.CSS_URL:
61+
case CssTypes.CSS_IMAGE:
62+
value = val;
63+
break;
64+
case CssTypes.CSS_IDENT:
65+
if (inherit.equals(val)) {
66+
if (expression.getCount() > 1) {
67+
throw new InvalidParamException("unrecognize", ac);
68+
}
69+
value = inherit;
70+
break;
71+
}
72+
CssIdent id = getAllowedIdent((CssIdent) val);
73+
if (id != null) {
74+
value = id;
75+
break;
76+
}
77+
default:
78+
throw new InvalidParamException("value",
79+
val.toString(),
80+
getPropertyName(), ac);
81+
}
82+
expression.next();
83+
if (op != SPACE) {
84+
throw new InvalidParamException("operator",
85+
Character.toString(op),
86+
ac);
87+
}
88+
}
89+
90+
public CssMaskBorderSource(ApplContext ac, CssExpression expression)
91+
throws InvalidParamException {
92+
this(ac, expression, false);
93+
}
94+
95+
}
96+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

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

11+
import org.w3c.css.properties.css.CssMaskBorderSource;
1112
import org.w3c.css.properties.css.CssMarker;
1213
import org.w3c.css.properties.css.CssMarkerEnd;
1314
import org.w3c.css.properties.css.CssMarkerMid;
@@ -46,6 +47,16 @@ public class SVGStyle extends SVGBasicStyle {
4647
public CssMaskRepeat cssMaskRepeat;
4748
public CssMaskSize cssMaskSize;
4849
public CssMaskType cssMaskType;
50+
51+
public CssMaskBorderSource cssMaskBorderSource;
52+
53+
public CssMaskBorderSource getMaskBorderSource() {
54+
if (cssMaskBorderSource == null) {
55+
cssMaskBorderSource = (CssMaskBorderSource) style.CascadingOrder(new CssMaskBorderSource(),
56+
style, selector);
57+
}
58+
return cssMaskBorderSource;
59+
}
4960

5061
public CssMaskType getMaskType() {
5162
if (cssMaskType == null) {

0 commit comments

Comments
 (0)