Skip to content

Commit e37f0bb

Browse files
committed
1 parent 0bb1ec3 commit e37f0bb

File tree

7 files changed

+205
-160
lines changed

7 files changed

+205
-160
lines changed

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ marker-mid: org.w3c.css.properties.svg.CssMarkerMid
2020
marker-start: org.w3c.css.properties.svg.CssMarkerStart
2121
kerning: org.w3c.css.properties.svg.CssKerning
2222
writing-mode: org.w3c.css.properties.svg.CssWritingMode
23+
clip-path: org.w3c.css.properties.svg.CssClipPath
2324

2425
# CSS3 Properties
2526
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
@@ -1,7 +1,7 @@
11
alignment-baseline: org.w3c.css.properties.svg.CssAlignmentBaseline
22
baseline-shift: org.w3c.css.properties.svg.CssBaselineShift
33
clip: org.w3c.css.properties.css21.CssClip
4-
clip-path: org.w3c.css.properties.svg.ClipPath
4+
clip-path: org.w3c.css.properties.svg.CssClipPath
55
clip-rule: org.w3c.css.properties.svg.ClipRule
66
color: org.w3c.css.properties.css3.CssColor
77
color-interpolation: org.w3c.css.properties.svg.CssColorInterpolation

org/w3c/css/properties/SVGProperties.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
alignment-baseline: org.w3c.css.properties.svg.CssAlignmentBaseline
22
baseline-shift: org.w3c.css.properties.svg.CssBaselineShift
33
clip: org.w3c.css.properties.css21.CssClip
4-
clip-path: org.w3c.css.properties.svg.ClipPath
4+
clip-path: org.w3c.css.properties.svg.CssClipPath
55
clip-rule: org.w3c.css.properties.svg.ClipRule
66
color: org.w3c.css.properties.css3.CssColor
77
color-interpolation: org.w3c.css.properties.svg.CssColorInterpolation
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 CssClipPath extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssClipPath
24+
*/
25+
public CssClipPath() {
26+
}
27+
28+
/**
29+
* Creates a new CssClipPath
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssClipPath(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 CssClipPath(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 "clip-path";
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.cssClipPath != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssClipPath = 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 CssClipPath &&
98+
value.equals(((CssClipPath) 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).getClipPath();
111+
} else {
112+
return ((SVGBasicStyle) style).cssClipPath;
113+
}
114+
}
115+
}
116+

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

Lines changed: 0 additions & 149 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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.CssIdent;
12+
import org.w3c.css.values.CssTypes;
13+
import org.w3c.css.values.CssValue;
14+
15+
/**
16+
* @spec http://www.w3.org/TR/2011/REC-SVG11-20110816/text.html#KerningProperty
17+
*/
18+
public class CssClipPath extends org.w3c.css.properties.css.CssKerning {
19+
20+
CssIdent auto = CssIdent.getIdent("auto");
21+
/**
22+
* Create a new CssKerning
23+
*/
24+
public CssClipPath() {
25+
value = initial;
26+
}
27+
28+
/**
29+
* Creates a new CssKerning
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssClipPath(ApplContext ac, CssExpression expression, boolean check)
36+
throws InvalidParamException {
37+
if (check && expression.getCount() > 1) {
38+
throw new InvalidParamException("unrecognize", ac);
39+
}
40+
setByUser();
41+
42+
CssValue val;
43+
char op;
44+
45+
val = expression.getValue();
46+
op = expression.getOperator();
47+
48+
switch (val.getType()) {
49+
case CssTypes.CSS_URL:
50+
value = val;
51+
break;
52+
case CssTypes.CSS_IDENT:
53+
if (inherit.equals(val)) {
54+
value = inherit;
55+
break;
56+
}
57+
if (none.equals(val)) {
58+
value = none;
59+
break;
60+
}
61+
default:
62+
throw new InvalidParamException("value",
63+
val.toString(),
64+
getPropertyName(), ac);
65+
}
66+
expression.next();
67+
}
68+
69+
public CssClipPath(ApplContext ac, CssExpression expression)
70+
throws InvalidParamException {
71+
this(ac, expression, false);
72+
}
73+
74+
}
75+

0 commit comments

Comments
 (0)