Skip to content

Commit 483abaf

Browse files
committed
1 parent 10b5b24 commit 483abaf

File tree

7 files changed

+203
-162
lines changed

7 files changed

+203
-162
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ kerning: org.w3c.css.properties.svg.CssKerning
2222
writing-mode: org.w3c.css.properties.svg.CssWritingMode
2323
clip-path: org.w3c.css.properties.svg.CssClipPath
2424
clip-rule: org.w3c.css.properties.svg.CssClipRule
25+
mask: org.w3c.css.properties.svg.CssMask
2526

2627
# CSS3 Properties
2728
font-style: org.w3c.css.properties.css3.CssFontStyle

org/w3c/css/properties/SVGBasicProperties.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ glyph-orientation-vertical: org.w3c.css.properties.css3.CssGlyphOrVert
3030
image-rendering: org.w3c.css.properties.svg.CssImageRendering
3131
kerning: org.w3c.css.properties.svg.CssKerning
3232
letter-spacing: org.w3c.css.properties.css21.CssLetterSpacing
33-
mask: org.w3c.css.properties.svg.Mask
33+
mask: org.w3c.css.properties.svg.CssMask
3434
opacity: org.w3c.css.properties.css3.CssOpacity
3535
overflow: org.w3c.css.properties.css2.CssOverflow
3636
pointer-events: org.w3c.css.properties.svg.PointerEvents

org/w3c/css/properties/SVGProperties.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ filter: org.w3c.css.properties.css3.CssFilter
3434
fill-rule: org.w3c.css.properties.svg.CssFillRule
3535
fill-opacity: org.w3c.css.properties.svg.CssFillOpacity
3636
image-rendering: org.w3c.css.properties.svg.CssImageRendering
37-
mask: org.w3c.css.properties.svg.Mask
37+
mask: org.w3c.css.properties.svg.CssMask
3838
stop-opacity: org.w3c.css.properties.svg.StopOpacity
3939
projection.stop-opacity: org.w3c.css.properties.svg.StopOpacity
4040
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, 2016.
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.SVGBasicStyle;
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 CssMask extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssMask
24+
*/
25+
public CssMask() {
26+
}
27+
28+
/**
29+
* Creates a new CssMask
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMask(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 CssMask(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";
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+
SVGBasicStyle s = (SVGBasicStyle) style;
84+
if (s.cssMask != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMask = 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 CssMask &&
98+
value.equals(((CssMask) 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 ((SVGBasicStyle) style).getMask();
111+
} else {
112+
return ((SVGBasicStyle) style).cssMask;
113+
}
114+
}
115+
}
116+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016.
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+
14+
/**
15+
* @spec http://www.w3.org/TR/2011/REC-SVG11-20110816/masking.html#MaskProperty
16+
*/
17+
public class CssMask extends org.w3c.css.properties.css.CssMask {
18+
19+
/**
20+
* Create a new CssKerning
21+
*/
22+
public CssMask() {
23+
value = initial;
24+
}
25+
26+
/**
27+
* Creates a new CssKerning
28+
*
29+
* @param expression The expression for this property
30+
* @throws org.w3c.css.util.InvalidParamException
31+
* Expressions are incorrect
32+
*/
33+
public CssMask(ApplContext ac, CssExpression expression, boolean check)
34+
throws InvalidParamException {
35+
if (check && expression.getCount() > 1) {
36+
throw new InvalidParamException("unrecognize", ac);
37+
}
38+
setByUser();
39+
40+
CssValue val;
41+
char op;
42+
43+
val = expression.getValue();
44+
op = expression.getOperator();
45+
46+
switch (val.getType()) {
47+
case CssTypes.CSS_URL:
48+
value = val;
49+
break;
50+
case CssTypes.CSS_IDENT:
51+
if (inherit.equals(val)) {
52+
value = inherit;
53+
break;
54+
}
55+
if (none.equals(val)) {
56+
value = none;
57+
break;
58+
}
59+
default:
60+
throw new InvalidParamException("value",
61+
val.toString(),
62+
getPropertyName(), ac);
63+
}
64+
expression.next();
65+
}
66+
67+
public CssMask(ApplContext ac, CssExpression expression)
68+
throws InvalidParamException {
69+
this(ac, expression, false);
70+
}
71+
72+
}
73+

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

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)