Skip to content

Commit 44bae5d

Browse files
committed
1 parent 58a2fa2 commit 44bae5d

File tree

4 files changed

+234
-0
lines changed

4 files changed

+234
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ backface-visibility: org.w3c.css.properties.css3.CssBackfaceV
196196
perspective: org.w3c.css.properties.css3.CssPerspective
197197
perspective-origin: org.w3c.css.properties.css3.CssPerspectiveOrigin
198198
transform-origin: org.w3c.css.properties.css3.CssTransformOrigin
199+
transform-box: org.w3c.css.properties.css3.CssTransformBox
199200
transform: org.w3c.css.properties.css3.CssTransform
200201

201202
# image
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// $Id$
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
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.css3.Css3Style;
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 CSS3
17+
*/
18+
public class CssTransformBox extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssTransformBox
24+
*/
25+
public CssTransformBox() {
26+
}
27+
28+
/**
29+
* Creates a new CssTransformBox
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssTransformBox(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 CssTransformBox(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 "transform-box";
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+
Css3Style s = (Css3Style) style;
84+
if (s.cssTransformBox != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssTransformBox = 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 CssTransformBox &&
98+
value.equals(((CssTransformBox) 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 ((Css3Style) style).getTransformBox();
111+
} else {
112+
return ((Css3Style) style).cssTransformBox;
113+
}
114+
}
115+
}
116+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
import org.w3c.css.properties.css.CssTextUnderlinePosition;
192192
import org.w3c.css.properties.css.CssTouchAction;
193193
import org.w3c.css.properties.css.CssTransform;
194+
import org.w3c.css.properties.css.CssTransformBox;
194195
import org.w3c.css.properties.css.CssTransformOrigin;
195196
import org.w3c.css.properties.css.CssTransformStyle;
196197
import org.w3c.css.properties.css.CssTransition;
@@ -438,6 +439,7 @@ public class Css3Style extends ATSCStyle {
438439
public CssPerspectiveOrigin cssPerspectiveOrigin;
439440
public CssTransformOrigin cssTransformOrigin;
440441
public CssTransform cssTransform;
442+
public CssTransformBox cssTransformBox;
441443

442444
public CssBoxSizing cssBoxSizing;
443445
public CssResize cssResize;
@@ -2293,6 +2295,15 @@ public CssTransform getTransform() {
22932295
return cssTransform;
22942296
}
22952297

2298+
public CssTransformBox getTransformBox() {
2299+
if (cssTransformBox == null) {
2300+
cssTransformBox =
2301+
(CssTransformBox) style.CascadingOrder(
2302+
new CssTransformBox(), style, selector);
2303+
}
2304+
return cssTransformBox;
2305+
}
2306+
22962307
public CssImeMode getImeMode() {
22972308
if (cssImeMode == null) {
22982309
cssImeMode =
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2019.
5+
// Please first read the full copyright statement in file COPYRIGHT.html
6+
package org.w3c.css.properties.css3;
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 https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#propdef-transform-box
17+
*/
18+
public class CssTransformBox extends org.w3c.css.properties.css.CssTransformBox {
19+
20+
21+
public static final CssIdent[] allowed_values;
22+
23+
static {
24+
String[] _allowed_values = {"content-box", "border-box", "fill-box",
25+
"stroke-box", "view-box"};
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 final CssIdent getAllowedValue(CssIdent ident) {
34+
if (none.equals(ident)) {
35+
return none;
36+
}
37+
for (CssIdent id : allowed_values) {
38+
if (id.equals(ident)) {
39+
return id;
40+
}
41+
}
42+
return null;
43+
}
44+
45+
public static CssIdent getMatchingIdent(CssIdent ident) {
46+
for (CssIdent id : allowed_values) {
47+
if (id.equals(ident)) {
48+
return id;
49+
}
50+
}
51+
return null;
52+
}
53+
54+
/**
55+
* Create a new CssTransformOrigin
56+
*/
57+
public CssTransformBox() {
58+
value = initial;
59+
}
60+
61+
/**
62+
* Creates a new CssTransformOrigin
63+
*
64+
* @param expression The expression for this property
65+
* @throws org.w3c.css.util.InvalidParamException
66+
* Values are incorrect
67+
*/
68+
public CssTransformBox(ApplContext ac, CssExpression expression,
69+
boolean check) throws InvalidParamException {
70+
71+
if (check && expression.getCount() > 1) {
72+
throw new InvalidParamException("unrecognize", ac);
73+
}
74+
setByUser();
75+
76+
CssValue val;
77+
char op;
78+
79+
val = expression.getValue();
80+
op = expression.getOperator();
81+
82+
if (val.getType() == CssTypes.CSS_IDENT) {
83+
CssIdent ident = (CssIdent) val;
84+
if (inherit.equals(ident)) {
85+
value = inherit;
86+
} else {
87+
value = getAllowedValue(ident);
88+
if (value == null) {
89+
throw new InvalidParamException("value",
90+
val.toString(),
91+
getPropertyName(), ac);
92+
}
93+
}
94+
} else {
95+
throw new InvalidParamException("value",
96+
val.toString(),
97+
getPropertyName(), ac);
98+
}
99+
expression.next();
100+
}
101+
102+
public CssTransformBox(ApplContext ac, CssExpression expression)
103+
throws InvalidParamException {
104+
this(ac, expression, false);
105+
}
106+
}

0 commit comments

Comments
 (0)