Skip to content

Commit 0410d35

Browse files
committed
1 parent 3e4c305 commit 0410d35

File tree

4 files changed

+229
-0
lines changed

4 files changed

+229
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ padding-right: org.w3c.css.properties.css3.CssPaddingRi
180180
padding: org.w3c.css.properties.css3.CssPadding
181181

182182
float: org.w3c.css.properties.css3.CssFloat
183+
float-defer: org.w3c.css.properties.css3.CssFloatDefer
183184
float-reference: org.w3c.css.properties.css3.CssFloatReference
184185

185186
width: org.w3c.css.properties.css3.CssWidth
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, 2015.
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 CssFloatDefer extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssFloatDefer
24+
*/
25+
public CssFloatDefer() {
26+
}
27+
28+
/**
29+
* Creates a new CssFloatDefer
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssFloatDefer(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 CssFloatDefer(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 "float-defer";
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.cssFloatDefer != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssFloatDefer = 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 CssFloatDefer &&
98+
value.equals(((CssFloatDefer) 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).getFloatDefer();
111+
} else {
112+
return ((Css3Style) style).cssFloatDefer;
113+
}
114+
}
115+
}
116+

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.w3c.css.properties.css.CssFlexGrow;
5656
import org.w3c.css.properties.css.CssFlexShrink;
5757
import org.w3c.css.properties.css.CssFlexWrap;
58+
import org.w3c.css.properties.css.CssFloatDefer;
5859
import org.w3c.css.properties.css.CssFloatReference;
5960
import org.w3c.css.properties.css.CssFloodColor;
6061
import org.w3c.css.properties.css.CssFloodOpacity;
@@ -302,6 +303,7 @@ public class Css3Style extends ATSCStyle {
302303
public CssLightingColor cssLightingColor;
303304

304305
public CssFloatReference cssFloatReference;
306+
public CssFloatDefer cssFloatDefer;
305307

306308
public org.w3c.css.properties.css.CssBorderImageSource getBorderImageSource() {
307309
if (cssBorder.borderImage.source == null) {
@@ -1662,6 +1664,13 @@ public final CssFloatReference getFloatReference() {
16621664
}
16631665
return cssFloatReference;
16641666
}
1667+
1668+
public final CssFloatDefer getFloatDefer() {
1669+
if (cssFloatDefer == null) {
1670+
cssFloatDefer = (CssFloatDefer) style.CascadingOrder(new CssFloatDefer(), style, selector);
1671+
}
1672+
return cssFloatDefer;
1673+
}
16651674
///
16661675

16671676
/**
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2015.
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 http://www.w3.org/TR/2015/WD-css-page-floats-3-20150915/#propdef-float-defer
17+
*/
18+
public class CssFloatDefer extends org.w3c.css.properties.css.CssFloatDefer {
19+
20+
public static final CssIdent[] allowed_values;
21+
22+
static {
23+
String[] _allowed_values = {"last", "none"};
24+
int i = 0;
25+
allowed_values = new CssIdent[_allowed_values.length];
26+
for (String s : _allowed_values) {
27+
allowed_values[i++] = CssIdent.getIdent(s);
28+
}
29+
}
30+
31+
public static final CssIdent getAllowedIdent(CssIdent ident) {
32+
for (CssIdent id : allowed_values) {
33+
if (id.equals(ident)) {
34+
return id;
35+
}
36+
}
37+
return null;
38+
}
39+
40+
/**
41+
* Create a new CssFloatDefer
42+
*/
43+
public CssFloatDefer() {
44+
value = initial;
45+
}
46+
47+
48+
/**
49+
* Set the value of the property<br/>
50+
* Does not check the number of values
51+
*
52+
* @param expression The expression for this property
53+
* @throws org.w3c.css.util.InvalidParamException
54+
* The expression is incorrect
55+
*/
56+
public CssFloatDefer(ApplContext ac, CssExpression expression)
57+
throws InvalidParamException {
58+
this(ac, expression, false);
59+
}
60+
61+
/**
62+
* Set the value of the property
63+
*
64+
* @param expression The expression for this property
65+
* @param check set it to true to check the number of values
66+
* @throws org.w3c.css.util.InvalidParamException
67+
* The expression is incorrect
68+
*/
69+
public CssFloatDefer(ApplContext ac, CssExpression expression,
70+
boolean check) throws InvalidParamException {
71+
if (check && expression.getCount() > 1) {
72+
throw new InvalidParamException("unrecognize", ac);
73+
}
74+
setByUser();
75+
76+
CssValue val;
77+
78+
val = expression.getValue();
79+
80+
switch (val.getType()) {
81+
case CssTypes.CSS_NUMBER:
82+
val.getNumber().checkInteger(ac, this);
83+
value = val;
84+
break;
85+
case CssTypes.CSS_IDENT:
86+
CssIdent id = (CssIdent) val;
87+
if (inherit.equals(id)) {
88+
value = inherit;
89+
break;
90+
} else {
91+
value = getAllowedIdent(id);
92+
if (value != null) {
93+
break;
94+
}
95+
}
96+
default:
97+
throw new InvalidParamException("value",
98+
val.toString(),
99+
getPropertyName(), ac);
100+
}
101+
expression.next();
102+
}
103+
}

0 commit comments

Comments
 (0)