Skip to content

Commit 8576214

Browse files
committed
1 parent c29bbab commit 8576214

File tree

5 files changed

+227
-0
lines changed

5 files changed

+227
-0
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ grid-template-rows: org.w3c.css.properties.css3.CssGridTempl
109109
row-gap: org.w3c.css.properties.css3.CssRowGap
110110
gap: org.w3c.css.properties.css3.CssGap
111111
justify-self: org.w3c.css.properties.css3.CssJustifySelf
112+
place-content: org.w3c.css.properties.css3.CssPlaceContent
112113
place-self: org.w3c.css.properties.css3.CssPlaceSelf
113114

114115
# text properties

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ grid-template-rows: org.w3c.css.properties.css3.CssGridTempl
166166
row-gap: org.w3c.css.properties.css3.CssRowGap
167167
gap: org.w3c.css.properties.css3.CssGap
168168
justify-self: org.w3c.css.properties.css3.CssJustifySelf
169+
place-content: org.w3c.css.properties.css3.CssPlaceContent
169170
place-self: org.w3c.css.properties.css3.CssPlaceSelf
170171

171172
# 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 CssPlaceContent extends CssProperty {
19+
20+
public CssValue value;
21+
22+
/**
23+
* Create a new CssPlaceContent
24+
*/
25+
public CssPlaceContent() {
26+
}
27+
28+
/**
29+
* Creates a new CssPlaceContent
30+
*
31+
* @param expression The expression for this property
32+
* @throws org.w3c.css.util.InvalidParamException
33+
* Expressions are incorrect
34+
*/
35+
public CssPlaceContent(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 CssPlaceContent(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-content";
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.cssPlaceContent != null) {
85+
style.addRedefinitionWarning(ac, this);
86+
}
87+
s.cssPlaceContent = 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 CssPlaceContent &&
98+
value.equals(((CssPlaceContent) 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).getPlaceContent();
111+
} else {
112+
return ((Css3Style) style).cssPlaceContent;
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
@@ -133,6 +133,7 @@
133133
import org.w3c.css.properties.css.CssOverflowY;
134134
import org.w3c.css.properties.css.CssPerspective;
135135
import org.w3c.css.properties.css.CssPerspectiveOrigin;
136+
import org.w3c.css.properties.css.CssPlaceContent;
136137
import org.w3c.css.properties.css.CssPlaceSelf;
137138
import org.w3c.css.properties.css.CssResize;
138139
import org.w3c.css.properties.css.CssRest;
@@ -472,8 +473,18 @@ public class Css3Style extends ATSCStyle {
472473
public CssGap cssGap;
473474
public CssJustifySelf cssJustifySelf;
474475
public CssPlaceSelf cssPlaceSelf;
476+
public CssPlaceContent cssPlaceContent;
475477

476478

479+
public CssPlaceContent getPlaceContent() {
480+
if (cssPlaceContent == null) {
481+
cssPlaceContent =
482+
(CssPlaceContent) style.CascadingOrder(new CssPlaceContent(),
483+
style, selector);
484+
}
485+
return cssPlaceContent;
486+
}
487+
477488
public CssPlaceSelf getPlaceSelf() {
478489
if (cssPlaceSelf == null) {
479490
cssPlaceSelf =
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-content-property
21+
*/
22+
public class CssPlaceContent extends org.w3c.css.properties.css.CssPlaceContent {
23+
24+
private CssAlignContent alignContent;
25+
private CssJustifyContent justifyContent;
26+
27+
/**
28+
* Create a new CssAlignContent
29+
*/
30+
public CssPlaceContent() {
31+
value = initial;
32+
alignContent = new CssAlignContent();
33+
justifyContent = new CssJustifyContent();
34+
}
35+
36+
/**
37+
* Creates a new CssAlignContent
38+
*
39+
* @param expression The expression for this property
40+
* @throws org.w3c.css.util.InvalidParamException
41+
* Expressions are incorrect
42+
*/
43+
public CssPlaceContent(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+
alignContent = new CssAlignContent();
51+
justifyContent = new CssJustifyContent();
52+
53+
ArrayList<CssValue> values = new ArrayList<>();
54+
CssValue val;
55+
56+
val = CssAlignContent.parseAlignContent(ac, expression, this);
57+
if (expression.end()) {
58+
value = val;
59+
alignContent.value = val;
60+
justifyContent.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+
alignContent.value = val;
69+
70+
val = CssJustifyContent.parseJustifyContent(ac, expression, this);
71+
if (!expression.end()) {
72+
throw new InvalidParamException("value", expression.getValue().toString(),
73+
getPropertyName(), ac);
74+
}
75+
values.add(val);
76+
justifyContent.value = val;
77+
value = new CssValueList(values);
78+
}
79+
}
80+
81+
public CssPlaceContent(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+
alignContent.addToStyle(ac, style);
95+
justifyContent.addToStyle(ac, style);
96+
}
97+
}
98+

0 commit comments

Comments
 (0)