Skip to content

Commit 52af757

Browse files
committed
1 parent 01d024c commit 52af757

File tree

6 files changed

+227
-29
lines changed

6 files changed

+227
-29
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ lighting-color: org.w3c.css.properties.css3.CssLightingC
484484
@font-face.font-size: org.w3c.css.properties.css2.font.FontSize
485485
@font-face.font-family: org.w3c.css.properties.css2.font.FontFamily
486486
@font-face.font-stretch: org.w3c.css.properties.css2.font.FontStretch
487+
@font-face.font-display: org.w3c.css.properties.css3.fontface.CssFontDisplay
487488

488489
mediafeature.width: org.w3c.css.atrules.css3.media.MediaWidth
489490
mediafeature.height: org.w3c.css.atrules.css3.media.MediaHeight

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ lighting-color: org.w3c.css.properties.css3.CssLightingC
541541
@font-face.font-size: org.w3c.css.properties.css2.font.FontSize
542542
@font-face.font-family: org.w3c.css.properties.css2.font.FontFamily
543543
@font-face.font-stretch: org.w3c.css.properties.css2.font.FontStretch
544+
@font-face.font-display: org.w3c.css.properties.css3.fontface.CssFontDisplay
544545

545546
mediafeature.width: org.w3c.css.atrules.css3.media.MediaWidth
546547
mediafeature.height: org.w3c.css.atrules.css3.media.MediaHeight
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
7+
package org.w3c.css.properties.css.fontface;
8+
9+
import org.w3c.css.parser.CssStyle;
10+
import org.w3c.css.properties.css.CssProperty;
11+
import org.w3c.css.properties.css3.Css3Style;
12+
import org.w3c.css.util.ApplContext;
13+
import org.w3c.css.util.InvalidParamException;
14+
import org.w3c.css.values.CssExpression;
15+
import org.w3c.css.values.CssValue;
16+
17+
/**
18+
* @since CSS3
19+
*/
20+
public class CssFontDisplay extends CssProperty {
21+
22+
public CssValue value;
23+
24+
/**
25+
* Create a new CssFontDisplay
26+
*/
27+
public CssFontDisplay() {
28+
}
29+
30+
/**
31+
* Creates a new CssFontDisplay
32+
*
33+
* @param expression The expression for this property
34+
* @throws org.w3c.css.util.InvalidParamException
35+
* Expressions are incorrect
36+
*/
37+
public CssFontDisplay(ApplContext ac, CssExpression expression, boolean check)
38+
throws InvalidParamException {
39+
throw new InvalidParamException("value",
40+
expression.getValue().toString(),
41+
getPropertyName(), ac);
42+
}
43+
44+
public CssFontDisplay(ApplContext ac, CssExpression expression)
45+
throws InvalidParamException {
46+
this(ac, expression, false);
47+
}
48+
49+
/**
50+
* Returns the value of this property
51+
*/
52+
public Object get() {
53+
return value;
54+
}
55+
56+
57+
/**
58+
* Returns the name of this property
59+
*/
60+
public final String getPropertyName() {
61+
return "font-display";
62+
}
63+
64+
/**
65+
* Returns true if this property is "softly" inherited
66+
* e.g. his value is equals to inherit
67+
*/
68+
public boolean isSoftlyInherited() {
69+
return value.equals(inherit);
70+
}
71+
72+
/**
73+
* Returns a string representation of the object.
74+
*/
75+
public String toString() {
76+
return value.toString();
77+
}
78+
79+
/**
80+
* Add this property to the CssStyle.
81+
*
82+
* @param style The CssStyle
83+
*/
84+
public void addToStyle(ApplContext ac, CssStyle style) {
85+
Css3Style s = (Css3Style) style;
86+
if (s.fontFaceCssFontDisplay != null) {
87+
style.addRedefinitionWarning(ac, this);
88+
}
89+
s.fontFaceCssFontDisplay = this;
90+
}
91+
92+
93+
/**
94+
* Compares two properties for equality.
95+
*
96+
* @param property The other property.
97+
*/
98+
public boolean equals(CssProperty property) {
99+
return (property instanceof CssFontDisplay &&
100+
value.equals(((CssFontDisplay) property).value));
101+
}
102+
103+
104+
/**
105+
* Get this property in the style.
106+
*
107+
* @param style The style where the property is
108+
* @param resolve if true, resolve the style to find this property
109+
*/
110+
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
111+
if (resolve) {
112+
return ((Css3Style) style).getFontFaceCssFontDisplay();
113+
} else {
114+
return ((Css3Style) style).fontFaceCssFontDisplay;
115+
}
116+
}
117+
}
118+

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
import org.w3c.css.properties.css.counterstyle.CssSuffix;
219219
import org.w3c.css.properties.css.counterstyle.CssSymbols;
220220
import org.w3c.css.properties.css.counterstyle.CssSystem;
221+
import org.w3c.css.properties.css.fontface.CssFontDisplay;
221222
import org.w3c.css.properties.css.viewport.CssMaxZoom;
222223
import org.w3c.css.properties.css.viewport.CssMinZoom;
223224
import org.w3c.css.properties.css.viewport.CssOrientation;
@@ -479,6 +480,17 @@ public class Css3Style extends ATSCStyle {
479480
public CssJustifyItems cssJustifyItems;
480481
public CssPlaceItems cssPlaceItems;
481482

483+
public CssFontDisplay fontFaceCssFontDisplay;
484+
485+
486+
public CssFontDisplay getFontFaceCssFontDisplay() {
487+
if (fontFaceCssFontDisplay == null) {
488+
fontFaceCssFontDisplay =
489+
(CssFontDisplay) style.CascadingOrder(new CssFontDisplay(),
490+
style, selector);
491+
}
492+
return fontFaceCssFontDisplay;
493+
}
482494

483495
public CssPlaceItems getPlaceItems() {
484496
if (cssPlaceItems == null) {
@@ -488,7 +500,7 @@ public CssPlaceItems getPlaceItems() {
488500
}
489501
return cssPlaceItems;
490502
}
491-
503+
492504
public CssJustifyItems getJustifyItems() {
493505
if (cssJustifyItems == null) {
494506
cssJustifyItems =
@@ -497,7 +509,7 @@ public CssJustifyItems getJustifyItems() {
497509
}
498510
return cssJustifyItems;
499511
}
500-
512+
501513
public CssPlaceContent getPlaceContent() {
502514
if (cssPlaceContent == null) {
503515
cssPlaceContent =
@@ -506,7 +518,7 @@ public CssPlaceContent getPlaceContent() {
506518
}
507519
return cssPlaceContent;
508520
}
509-
521+
510522
public CssPlaceSelf getPlaceSelf() {
511523
if (cssPlaceSelf == null) {
512524
cssPlaceSelf =
@@ -515,7 +527,7 @@ public CssPlaceSelf getPlaceSelf() {
515527
}
516528
return cssPlaceSelf;
517529
}
518-
530+
519531
public CssJustifySelf getJustifySelf() {
520532
if (cssJustifySelf == null) {
521533
cssJustifySelf =
@@ -524,7 +536,7 @@ public CssJustifySelf getJustifySelf() {
524536
}
525537
return cssJustifySelf;
526538
}
527-
539+
528540
public CssGap getGap() {
529541
if (cssGap == null) {
530542
cssGap =
@@ -533,7 +545,7 @@ public CssGap getGap() {
533545
}
534546
return cssGap;
535547
}
536-
548+
537549
public CssRowGap getRowGap() {
538550
if (cssRowGap == null) {
539551
cssRowGap =
@@ -542,7 +554,7 @@ public CssRowGap getRowGap() {
542554
}
543555
return cssRowGap;
544556
}
545-
557+
546558
public CssTextCombineUpright getTextCombineUpright() {
547559
if (cssTextCombineUpright == null) {
548560
cssTextCombineUpright =
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.fontface;
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 https://www.w3.org/TR/2018/WD-css-fonts-4-20180410/#font-display-desc
17+
*/
18+
public class CssFontDisplay extends org.w3c.css.properties.css.fontface.CssFontDisplay {
19+
20+
public static final CssIdent[] allowed_values;
21+
22+
static {
23+
String[] _allowed_values = {"auto", "block", "swap", "fallback", "optional"};
24+
allowed_values = new CssIdent[_allowed_values.length];
25+
int i = 0;
26+
for (String s : _allowed_values) {
27+
allowed_values[i++] = CssIdent.getIdent(s);
28+
}
29+
}
30+
31+
public static 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 CssFontDisplay
42+
*/
43+
public CssFontDisplay() {
44+
value = initial;
45+
}
46+
47+
/**
48+
* Creates a new CssFontDisplay
49+
*
50+
* @param expression The expression for this property
51+
* @throws org.w3c.css.util.InvalidParamException
52+
* Expressions are incorrect
53+
*/
54+
public CssFontDisplay(ApplContext ac, CssExpression expression, boolean check)
55+
throws InvalidParamException {
56+
if (check && expression.getCount() > 1) {
57+
throw new InvalidParamException("unrecognize", ac);
58+
}
59+
60+
setByUser();
61+
62+
char op;
63+
CssValue val;
64+
65+
val = expression.getValue();
66+
op = expression.getOperator();
67+
68+
switch (val.getType()) {
69+
case CssTypes.CSS_IDENT:
70+
value = getAllowedIdent((CssIdent) val);
71+
if (value != null) {
72+
break;
73+
}
74+
default:
75+
throw new InvalidParamException("value",
76+
val.toString(),
77+
getPropertyName(), ac);
78+
}
79+
expression.next();
80+
}
81+
82+
public CssFontDisplay(ApplContext ac, CssExpression expression)
83+
throws InvalidParamException {
84+
this(ac, expression, false);
85+
}
86+
87+
}
88+

org/w3c/css/properties/css3/fontface/CssSrc.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.w3c.css.util.InvalidParamException;
1010
import org.w3c.css.values.CssExpression;
1111
import org.w3c.css.values.CssFunction;
12-
import org.w3c.css.values.CssIdent;
1312
import org.w3c.css.values.CssLayerList;
1413
import org.w3c.css.values.CssTypes;
1514
import org.w3c.css.values.CssValue;
@@ -25,27 +24,6 @@
2524
*/
2625
public class CssSrc extends org.w3c.css.properties.css.fontface.CssSrc {
2726

28-
public static final CssIdent[] allowed_values;
29-
30-
static {
31-
String[] _allowed_values = {"flex-start", "flex-end", "center", "space-between",
32-
"space-around", "stretch"};
33-
allowed_values = new CssIdent[_allowed_values.length];
34-
int i = 0;
35-
for (String s : _allowed_values) {
36-
allowed_values[i++] = CssIdent.getIdent(s);
37-
}
38-
}
39-
40-
public static CssIdent getAllowedIdent(CssIdent ident) {
41-
for (CssIdent id : allowed_values) {
42-
if (id.equals(ident)) {
43-
return id;
44-
}
45-
}
46-
return null;
47-
}
48-
4927
/**
5028
* Create a new CssSrc
5129
*/

0 commit comments

Comments
 (0)