Skip to content

Commit a8b9239

Browse files
committed
1 parent 291696e commit a8b9239

File tree

6 files changed

+195
-7
lines changed

6 files changed

+195
-7
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ mask-mode: org.w3c.css.properties.svg.CssMaskMode
3131
mask-origin: org.w3c.css.properties.svg.CssMaskOrigin
3232
mask-position: org.w3c.css.properties.svg.CssMaskPosition
3333
mask-repeat: org.w3c.css.properties.svg.CssMaskRepeat
34+
mask-size: org.w3c.css.properties.svg.CssMaskSize
3435
mask-type: org.w3c.css.properties.svg.CssMaskType
3536
fill: org.w3c.css.properties.svg.CssFill
3637
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
@@ -42,6 +42,7 @@ mask-mode: org.w3c.css.properties.svg.CssMaskMode
4242
mask-origin: org.w3c.css.properties.svg.CssMaskOrigin
4343
mask-position: org.w3c.css.properties.svg.CssMaskPosition
4444
mask-repeat: org.w3c.css.properties.svg.CssMaskRepeat
45+
mask-size: org.w3c.css.properties.svg.CssMaskSize
4546
mask-type: org.w3c.css.properties.svg.CssMaskType
4647
stop-opacity: org.w3c.css.properties.svg.CssStopOpacity
4748
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 CssMaskSize extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssMaskSize
24+
*/
25+
public CssMaskSize() {
26+
}
27+
28+
/**
29+
* Creates a new CssMaskSize
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssMaskSize(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 CssMaskSize(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-size";
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.cssMaskSize != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssMaskSize = 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 CssMaskSize &&
98+
value.equals(((CssMaskSize) 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).getMaskSize();
111+
} else {
112+
return ((SVGStyle) style).cssMaskSize;
113+
}
114+
}
115+
}
116+

org/w3c/css/properties/css3/CssBackgroundSize.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package org.w3c.css.properties.css3;
88

9+
import org.w3c.css.properties.css.CssProperty;
910
import org.w3c.css.util.ApplContext;
1011
import org.w3c.css.util.InvalidParamException;
1112
import org.w3c.css.values.CssCheckableValue;
@@ -68,13 +69,27 @@ public CssBackgroundSize() {
6869
*/
6970
public CssBackgroundSize(ApplContext ac, CssExpression expression,
7071
boolean check) throws InvalidParamException {
72+
73+
setByUser();
74+
75+
value = checkBackgroundSize(ac, expression, this);
76+
}
77+
78+
public static CssValue checkBackgroundSize(ApplContext ac, CssExpression ex,
79+
CssProperty caller)
80+
throws InvalidParamException {
81+
return checkBackgroundSize(ac, ex, caller.getPropertyName());
82+
83+
}
84+
85+
public static CssValue checkBackgroundSize(ApplContext ac, CssExpression expression,
86+
String caller) throws InvalidParamException {
7187
ArrayList<CssValue> values = new ArrayList<CssValue>();
7288
char op;
7389
CssValue val;
7490
CssValueList vl = null;
7591
boolean is_complete = true;
7692

77-
setByUser();
7893

7994
while (!expression.end()) {
8095
val = expression.getValue();
@@ -85,7 +100,7 @@ public CssBackgroundSize(ApplContext ac, CssExpression expression,
85100
case CssTypes.CSS_LENGTH:
86101
case CssTypes.CSS_PERCENTAGE:
87102
CssCheckableValue l = val.getCheckableValue();
88-
l.checkPositiveness(ac, this);
103+
l.checkPositiveness(ac, caller);
89104
if (is_complete) {
90105
vl = new CssValueList();
91106
vl.add(val);
@@ -101,7 +116,7 @@ public CssBackgroundSize(ApplContext ac, CssExpression expression,
101116
// if we got more than one value... fail
102117
if ((values.size() > 0) || (expression.getCount() > 1)) {
103118
throw new InvalidParamException("value", val,
104-
getPropertyName(), ac);
119+
caller, ac);
105120
}
106121
values.add(inherit);
107122
break;
@@ -126,7 +141,7 @@ public CssBackgroundSize(ApplContext ac, CssExpression expression,
126141
}
127142
default:
128143
throw new InvalidParamException("value", val,
129-
getPropertyName(), ac);
144+
caller, ac);
130145

131146
}
132147
expression.next();
@@ -149,13 +164,12 @@ public CssBackgroundSize(ApplContext ac, CssExpression expression,
149164
values.add(vl);
150165
}
151166
if (values.size() == 1) {
152-
value = values.get(0);
167+
return values.get(0);
153168
} else {
154-
value = new CssLayerList(values);
169+
return new CssLayerList(values);
155170
}
156171
}
157172

158-
159173
public CssBackgroundSize(ApplContext ac, CssExpression expression)
160174
throws InvalidParamException {
161175
this(ac, expression, false);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.properties.css3.CssBackgroundSize;
9+
import org.w3c.css.util.ApplContext;
10+
import org.w3c.css.util.InvalidParamException;
11+
import org.w3c.css.values.CssExpression;
12+
13+
/**
14+
* @spec https://www.w3.org/TR/2014/CR-css-masking-1-20140826/#the-mask-size
15+
*/
16+
public class CssMaskSize extends org.w3c.css.properties.css.CssMaskSize {
17+
18+
/**
19+
* Create a new CssMaskSize
20+
*/
21+
public CssMaskSize() {
22+
value = initial;
23+
}
24+
25+
/**
26+
* Creates a new CssMaskSize
27+
*
28+
* @param expression The expression for this property
29+
* @throws org.w3c.css.util.InvalidParamException
30+
* Expressions are incorrect
31+
*/
32+
public CssMaskSize(ApplContext ac, CssExpression expression, boolean check)
33+
throws InvalidParamException {
34+
35+
setByUser();
36+
37+
value = CssBackgroundSize.checkBackgroundSize(ac, expression, this);
38+
}
39+
40+
public CssMaskSize(ApplContext ac, CssExpression expression)
41+
throws InvalidParamException {
42+
this(ac, expression, false);
43+
}
44+
45+
}
46+

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.w3c.css.properties.css.CssMaskOrigin;
2020
import org.w3c.css.properties.css.CssMaskPosition;
2121
import org.w3c.css.properties.css.CssMaskRepeat;
22+
import org.w3c.css.properties.css.CssMaskSize;
2223
import org.w3c.css.properties.css.CssMaskType;
2324
import org.w3c.css.properties.css.colorprofile.CssName;
2425
import org.w3c.css.properties.css.colorprofile.CssRenderingIntent;
@@ -43,6 +44,7 @@ public class SVGStyle extends SVGBasicStyle {
4344
public CssMaskOrigin cssMaskOrigin;
4445
public CssMaskPosition cssMaskPosition;
4546
public CssMaskRepeat cssMaskRepeat;
47+
public CssMaskSize cssMaskSize;
4648
public CssMaskType cssMaskType;
4749

4850
public CssMaskType getMaskType() {
@@ -53,6 +55,14 @@ public CssMaskType getMaskType() {
5355
return cssMaskType;
5456
}
5557

58+
public CssMaskSize getMaskSize() {
59+
if (cssMaskSize == null) {
60+
cssMaskSize = (CssMaskSize) style.CascadingOrder(new CssMaskSize(),
61+
style, selector);
62+
}
63+
return cssMaskSize;
64+
}
65+
5666
public CssMaskPosition getMaskPosition() {
5767
if (cssMaskPosition == null) {
5868
cssMaskPosition = (CssMaskPosition) style.CascadingOrder(new CssMaskPosition(),

0 commit comments

Comments
 (0)