Skip to content

Commit 3e5bc2f

Browse files
committed
1 parent 080308f commit 3e5bc2f

File tree

4 files changed

+225
-0
lines changed

4 files changed

+225
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ dominant-baseline: org.w3c.css.properties.css3.CssDominantB
267267
alignment-baseline: org.w3c.css.properties.css3.CssAlignmentBaseline
268268
initial-letter: org.w3c.css.properties.css3.CssInitialLetter
269269
initial-letter-align: org.w3c.css.properties.css3.CssInitialLetterAlign
270+
initial-letter-wrap: org.w3c.css.properties.css3.CssInitialLetterWrap
270271

271272

272273
# CSS Multi-column Layout Module
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 CssInitialLetterWrap extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssInitialLetterWrap
24+
*/
25+
public CssInitialLetterWrap() {
26+
}
27+
28+
/**
29+
* Creates a new CssInitialLetterWrap
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssInitialLetterWrap(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 CssInitialLetterWrap(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 "initial-letter-wrap";
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.cssInitialLetterWrap != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssInitialLetterWrap = 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 CssInitialLetterWrap &&
98+
value.equals(((CssInitialLetterWrap) 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).getInitialLetterWrap();
111+
} else {
112+
return ((Css3Style) style).cssInitialLetterWrap;
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
@@ -75,6 +75,7 @@
7575
import org.w3c.css.properties.css.CssImeMode;
7676
import org.w3c.css.properties.css.CssInitialLetter;
7777
import org.w3c.css.properties.css.CssInitialLetterAlign;
78+
import org.w3c.css.properties.css.CssInitialLetterWrap;
7879
import org.w3c.css.properties.css.CssJustifyContent;
7980
import org.w3c.css.properties.css.CssLightingColor;
8081
import org.w3c.css.properties.css.CssLineBreak;
@@ -164,6 +165,7 @@ public class Css3Style extends ATSCStyle {
164165
CssFit cssFit;
165166
public CssInitialLetter cssInitialLetter;
166167
public CssInitialLetterAlign cssInitialLetterAlign;
168+
public CssInitialLetterWrap cssInitialLetterWrap;
167169

168170
public CssOpacity cssOpacity;
169171
public CssBackgroundClip cssBackgroundClip;
@@ -459,6 +461,15 @@ public CssInitialLetterAlign getInitialLetterAlign() {
459461
return cssInitialLetterAlign;
460462
}
461463

464+
public CssInitialLetterWrap getInitialLetterWrap() {
465+
if (cssInitialLetterWrap == null) {
466+
cssInitialLetterWrap =
467+
(CssInitialLetterWrap) style.CascadingOrder(
468+
new CssInitialLetterWrap(), style, selector);
469+
}
470+
return cssInitialLetterWrap;
471+
}
472+
462473
public CssLineBreak getLineBreak() {
463474
if (cssLineBreak == null) {
464475
cssLineBreak =
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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-inline-3-20150917/#propdef-initial-letter-wrap
17+
*/
18+
public class CssInitialLetterWrap extends org.w3c.css.properties.css.CssInitialLetterWrap {
19+
20+
public static final CssIdent[] allowed_values;
21+
22+
static {
23+
String[] _allowed_values = {"none", "first", "all", "grid"};
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 CssInitialLetterWrap
42+
*/
43+
public CssInitialLetterWrap() {
44+
value = initial;
45+
}
46+
47+
/**
48+
* Set the value of the property
49+
*
50+
* @param expression The expression for this property
51+
* @param check set it to true to check the number of values
52+
* @throws org.w3c.css.util.InvalidParamException
53+
* The expression is incorrect
54+
*/
55+
public CssInitialLetterWrap(ApplContext ac, CssExpression expression,
56+
boolean check) throws InvalidParamException {
57+
58+
if (check && expression.getCount() > 1) {
59+
throw new InvalidParamException("unrecognize", ac);
60+
}
61+
62+
setByUser();
63+
CssValue val = expression.getValue();
64+
65+
switch (val.getType()) {
66+
case CssTypes.CSS_NUMBER:
67+
// check that the number is a length (ie: 0)
68+
val.getLength();
69+
case CssTypes.CSS_LENGTH:
70+
case CssTypes.CSS_PERCENTAGE:
71+
value = val;
72+
break;
73+
case CssTypes.CSS_IDENT:
74+
CssIdent id = (CssIdent) val;
75+
if (inherit.equals(id)) {
76+
value = inherit;
77+
break;
78+
}
79+
value = getAllowedIdent(id);
80+
if (value != null) {
81+
break;
82+
}
83+
default:
84+
throw new InvalidParamException("value", val,
85+
getPropertyName(), ac);
86+
}
87+
expression.next();
88+
}
89+
90+
public CssInitialLetterWrap(ApplContext ac, CssExpression expression)
91+
throws InvalidParamException {
92+
this(ac, expression, false);
93+
}
94+
95+
96+
}
97+

0 commit comments

Comments
 (0)