Skip to content

Commit 4813cb6

Browse files
committed
1 parent 3975ea8 commit 4813cb6

File tree

5 files changed

+228
-0
lines changed

5 files changed

+228
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ gap: org.w3c.css.properties.css3.CssGap
111111
justify-items: org.w3c.css.properties.css3.CssJustifyItems
112112
justify-self: org.w3c.css.properties.css3.CssJustifySelf
113113
place-content: org.w3c.css.properties.css3.CssPlaceContent
114+
place-items: org.w3c.css.properties.css3.CssPlaceItems
114115
place-self: org.w3c.css.properties.css3.CssPlaceSelf
115116

116117
# text properties

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ gap: org.w3c.css.properties.css3.CssGap
168168
justify-items: org.w3c.css.properties.css3.CssJustifyItems
169169
justify-self: org.w3c.css.properties.css3.CssJustifySelf
170170
place-content: org.w3c.css.properties.css3.CssPlaceContent
171+
place-items: org.w3c.css.properties.css3.CssPlaceItems
171172
place-self: org.w3c.css.properties.css3.CssPlaceSelf
172173

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
import org.w3c.css.properties.css.CssPerspective;
136136
import org.w3c.css.properties.css.CssPerspectiveOrigin;
137137
import org.w3c.css.properties.css.CssPlaceContent;
138+
import org.w3c.css.properties.css.CssPlaceItems;
138139
import org.w3c.css.properties.css.CssPlaceSelf;
139140
import org.w3c.css.properties.css.CssResize;
140141
import org.w3c.css.properties.css.CssRest;
@@ -476,7 +477,18 @@ public class Css3Style extends ATSCStyle {
476477
public CssPlaceSelf cssPlaceSelf;
477478
public CssPlaceContent cssPlaceContent;
478479
public CssJustifyItems cssJustifyItems;
480+
public CssPlaceItems cssPlaceItems;
479481

482+
483+
public CssPlaceItems getPlaceItems() {
484+
if (cssPlaceItems == null) {
485+
cssPlaceItems =
486+
(CssPlaceItems) style.CascadingOrder(new CssPlaceItems(),
487+
style, selector);
488+
}
489+
return cssPlaceItems;
490+
}
491+
480492
public CssJustifyItems getJustifyItems() {
481493
if (cssJustifyItems == null) {
482494
cssJustifyItems =
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018.
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.parser.CssStyle;
9+
import org.w3c.css.util.ApplContext;
10+
import org.w3c.css.util.InvalidParamException;
11+
import org.w3c.css.values.CssExpression;
12+
import org.w3c.css.values.CssValue;
13+
import org.w3c.css.values.CssValueList;
14+
15+
import java.util.ArrayList;
16+
17+
import static org.w3c.css.values.CssOperator.SPACE;
18+
19+
/**
20+
* @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#place-items-property
21+
*/
22+
public class CssPlaceItems extends org.w3c.css.properties.css.CssPlaceItems {
23+
24+
private CssAlignItems alignItems;
25+
private CssJustifyItems justifyItems;
26+
27+
/**
28+
* Create a new CssAlignItems
29+
*/
30+
public CssPlaceItems() {
31+
value = initial;
32+
alignItems = new CssAlignItems();
33+
justifyItems = new CssJustifyItems();
34+
}
35+
36+
/**
37+
* Creates a new CssAlignItems
38+
*
39+
* @param expression The expression for this property
40+
* @throws org.w3c.css.util.InvalidParamException
41+
* Expressions are incorrect
42+
*/
43+
public CssPlaceItems(ApplContext ac, CssExpression expression, boolean check)
44+
throws InvalidParamException {
45+
if (check && expression.getCount() > 4) {
46+
throw new InvalidParamException("unrecognize", ac);
47+
}
48+
setByUser();
49+
50+
alignItems = new CssAlignItems();
51+
justifyItems = new CssJustifyItems();
52+
53+
ArrayList<CssValue> values = new ArrayList<>();
54+
CssValue val;
55+
56+
val = CssAlignItems.parseAlignItems(ac, expression, this);
57+
if (expression.end()) {
58+
value = val;
59+
alignItems.value = val;
60+
justifyItems.value = val;
61+
} else {
62+
char op = expression.getOperator();
63+
if (op != SPACE) {
64+
throw new InvalidParamException("operator",
65+
((new Character(op)).toString()), ac);
66+
}
67+
values.add(val);
68+
alignItems.value = val;
69+
70+
val = CssJustifyItems.parseJustifyItems(ac, expression, this);
71+
if (!expression.end()) {
72+
throw new InvalidParamException("value", expression.getValue().toString(),
73+
getPropertyName(), ac);
74+
}
75+
values.add(val);
76+
justifyItems.value = val;
77+
value = new CssValueList(values);
78+
}
79+
}
80+
81+
public CssPlaceItems(ApplContext ac, CssExpression expression)
82+
throws InvalidParamException {
83+
this(ac, expression, false);
84+
}
85+
86+
87+
/**
88+
* Add this property to the CssStyle.
89+
*
90+
* @param style The CssStyle
91+
*/
92+
public void addToStyle(ApplContext ac, CssStyle style) {
93+
super.addToStyle(ac, style);
94+
alignItems.addToStyle(ac, style);
95+
justifyItems.addToStyle(ac, style);
96+
}
97+
}
98+

0 commit comments

Comments
 (0)