Skip to content

Commit c0c43cc

Browse files
committed
1 parent 0410d35 commit c0c43cc

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

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

182182
float: org.w3c.css.properties.css3.CssFloat
183183
float-defer: org.w3c.css.properties.css3.CssFloatDefer
184+
float-offset: org.w3c.css.properties.css3.CssFloatOffset
184185
float-reference: org.w3c.css.properties.css3.CssFloatReference
185186

186187
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 CssFloatOffset extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssFloatOffset
24+
*/
25+
public CssFloatOffset() {
26+
}
27+
28+
/**
29+
* Creates a new CssFloatOffset
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssFloatOffset(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 CssFloatOffset(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-offset";
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.cssFloatOffset != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssFloatOffset = 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 CssFloatOffset &&
98+
value.equals(((CssFloatOffset) 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).getFloatOffset();
111+
} else {
112+
return ((Css3Style) style).cssFloatOffset;
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
@@ -56,6 +56,7 @@
5656
import org.w3c.css.properties.css.CssFlexShrink;
5757
import org.w3c.css.properties.css.CssFlexWrap;
5858
import org.w3c.css.properties.css.CssFloatDefer;
59+
import org.w3c.css.properties.css.CssFloatOffset;
5960
import org.w3c.css.properties.css.CssFloatReference;
6061
import org.w3c.css.properties.css.CssFloodColor;
6162
import org.w3c.css.properties.css.CssFloodOpacity;
@@ -303,6 +304,7 @@ public class Css3Style extends ATSCStyle {
303304
public CssLightingColor cssLightingColor;
304305

305306
public CssFloatReference cssFloatReference;
307+
public CssFloatOffset cssFloatOffset;
306308
public CssFloatDefer cssFloatDefer;
307309

308310
public org.w3c.css.properties.css.CssBorderImageSource getBorderImageSource() {
@@ -1671,6 +1673,13 @@ public final CssFloatDefer getFloatDefer() {
16711673
}
16721674
return cssFloatDefer;
16731675
}
1676+
1677+
public final CssFloatOffset getFloatOffset() {
1678+
if (cssFloatOffset == null) {
1679+
cssFloatOffset = (CssFloatOffset) style.CascadingOrder(new CssFloatOffset(), style, selector);
1680+
}
1681+
return cssFloatOffset;
1682+
}
16741683
///
16751684

16761685
/**
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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-offset
17+
*/
18+
public class CssFloatOffset extends org.w3c.css.properties.css.CssFloatOffset {
19+
20+
/**
21+
* Create a new CssFloatOffset
22+
*/
23+
public CssFloatOffset() {
24+
value = initial;
25+
}
26+
27+
28+
/**
29+
* Set the value of the property<br/>
30+
* Does not check the number of values
31+
*
32+
* @param expression The expression for this property
33+
* @throws org.w3c.css.util.InvalidParamException
34+
* The expression is incorrect
35+
*/
36+
public CssFloatOffset(ApplContext ac, CssExpression expression)
37+
throws InvalidParamException {
38+
this(ac, expression, false);
39+
}
40+
41+
/**
42+
* Set the value of the property
43+
*
44+
* @param expression The expression for this property
45+
* @param check set it to true to check the number of values
46+
* @throws org.w3c.css.util.InvalidParamException
47+
* The expression is incorrect
48+
*/
49+
public CssFloatOffset(ApplContext ac, CssExpression expression,
50+
boolean check) throws InvalidParamException {
51+
if (check && expression.getCount() > 1) {
52+
throw new InvalidParamException("unrecognize", ac);
53+
}
54+
setByUser();
55+
56+
CssValue val;
57+
58+
val = expression.getValue();
59+
60+
switch (val.getType()) {
61+
case CssTypes.CSS_NUMBER:
62+
// only 0 can be a length
63+
val.getLength();
64+
case CssTypes.CSS_LENGTH:
65+
case CssTypes.CSS_PERCENTAGE:
66+
value = val;
67+
break;
68+
case CssTypes.CSS_IDENT:
69+
CssIdent id = (CssIdent) val;
70+
if (inherit.equals(id)) {
71+
value = inherit;
72+
break;
73+
}
74+
default:
75+
throw new InvalidParamException("value",
76+
val.toString(),
77+
getPropertyName(), ac);
78+
}
79+
expression.next();
80+
}
81+
}

0 commit comments

Comments
 (0)