Skip to content

Commit cb6c2a8

Browse files
committed
1 parent f54ccbe commit cb6c2a8

File tree

5 files changed

+203
-39
lines changed

5 files changed

+203
-39
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -498,32 +498,20 @@ flood-color: org.w3c.css.properties.css3.CssFloodColo
498498
flood-opacity: org.w3c.css.properties.css3.CssFloodOpacity
499499
lighting-color: org.w3c.css.properties.css3.CssLightingColor
500500

501-
@font-face.unicode-range: org.w3c.css.properties.css2.font.UnicodeRange
502-
@font-face.units-per-em: org.w3c.css.properties.css2.font.UnitsPerEm
503-
@font-face.src: org.w3c.css.properties.css3.fontface.CssSrc
504-
@font-face.panose-1: org.w3c.css.properties.css2.font.Panose1
505-
@font-face.stemv: org.w3c.css.properties.css2.font.Stemv
506-
@font-face.stemh: org.w3c.css.properties.css2.font.Stemh
507-
@font-face.slope: org.w3c.css.properties.css2.font.Slope
508-
@font-face.cap-height: org.w3c.css.properties.css2.font.CapHeight
509-
@font-face.x-hegiht: org.w3c.css.properties.css2.font.XHeight
510-
@font-face.widths: org.w3c.css.properties.css2.font.Widths
511-
@font-face.ascent: org.w3c.css.properties.css2.font.Ascent
512-
@font-face.descent: org.w3c.css.properties.css2.font.Descent
513-
@font-face.bbox: org.w3c.css.properties.css2.font.Bbox
514-
@font-face.baseline: org.w3c.css.properties.css2.font.Baseline
515-
@font-face.centerline: org.w3c.css.properties.css2.font.Centerline
516-
@font-face.definition-src: org.w3c.css.properties.css2.font.DefinitionSrc
517-
@font-face.mathline: org.w3c.css.properties.css2.font.Mathline
518-
@font-face.topline: org.w3c.css.properties.css2.font.Topline
519-
@font-face.font-style: org.w3c.css.properties.css3.fontface.CssFontStyle
520-
@font-face.font-variant: org.w3c.css.properties.css2.font.FontVariant
521-
@font-face.font-weight: org.w3c.css.properties.css3.fontface.CssFontWeight
522-
@font-face.font-size: org.w3c.css.properties.css2.font.FontSize
523-
@font-face.font-family: org.w3c.css.properties.css2.font.FontFamily
501+
@font-face.ascent-override: org.w3c.css.properties.css3.fontface.CssAscentOverride
502+
@font-face.descent-override: org.w3c.css.properties.css3.fontface.CssDescentOverride
503+
@font-face.font-display: org.w3c.css.properties.css3.fontface.CssFontDisplay
504+
@font-face.font-family: org.w3c.css.properties.css3.fontface.CssFontFamily
505+
@font-face.font-feature-settings: org.w3c.css.properties.css3.fontface.CssFontFeatureSettings
506+
@font-face.font-language-override: org.w3c.css.properties.css3.fontface.CssFontLanguageOverride
524507
@font-face.font-named-instance org.w3c.css.properties.css3.fontface.CssFontNamedInstance
525508
@font-face.font-stretch: org.w3c.css.properties.css3.fontface.CssFontStretch
526-
@font-face.font-display: org.w3c.css.properties.css3.fontface.CssFontDisplay
509+
@font-face.font-style: org.w3c.css.properties.css3.fontface.CssFontStyle
510+
@font-face.font-variation-settings: org.w3c.css.properties.css3.fontface.CssFontVariationSettings
511+
@font-face.font-weight: org.w3c.css.properties.css3.fontface.CssFontWeight
512+
@font-face.line-gap-override: org.w3c.css.properties.css3.fontface.CssLineGapOverride
513+
@font-face.src: org.w3c.css.properties.css3.fontface.CssSrc
514+
@font-face.unicode-range: org.w3c.css.properties.css3.fontface.CssUnicodeRange
527515

528516
// mediafeatures
529517
mf.any-hover: org.w3c.css.atrules.css3.media.MediaAnyHover
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, 2021.
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 CssFontVariationSettings extends CssProperty {
21+
22+
public CssValue value;
23+
24+
/**
25+
* Create a new CssFontVariationSettings
26+
*/
27+
public CssFontVariationSettings() {
28+
}
29+
30+
/**
31+
* Creates a new CssFontVariationSettings
32+
*
33+
* @param expression The expression for this property
34+
* @throws InvalidParamException
35+
* Expressions are incorrect
36+
*/
37+
public CssFontVariationSettings(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 CssFontVariationSettings(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-variation-settings";
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.fontFaceCssFontVariationSettings != null) {
87+
style.addRedefinitionWarning(ac, this);
88+
}
89+
s.fontFaceCssFontVariationSettings = 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 CssFontVariationSettings &&
100+
value.equals(((CssFontVariationSettings) 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).getFontFaceCssFontVariationSettings();
113+
} else {
114+
return ((Css3Style) style).fontFaceCssFontVariationSettings;
115+
}
116+
}
117+
}
118+

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ public class Css3Style extends ATSCStyle {
597597
public CssUnicodeRange fontFaceCssUnicodeRange;
598598
public org.w3c.css.properties.css.fontface.CssFontFamily fontFaceCssFontFamily;
599599
public org.w3c.css.properties.css.fontface.CssFontFeatureSettings fontFaceCssFontFeatureSettings;
600-
600+
public org.w3c.css.properties.css.fontface.CssFontVariationSettings fontFaceCssFontVariationSettings;
601+
601602
public CssColorAdjust cssColorAdjust;
602603
public CssForcedColorAdjust cssForcedColorAdjust;
603604
public CssColorScheme cssColorScheme;
@@ -1316,6 +1317,15 @@ public org.w3c.css.properties.css.fontface.CssFontFeatureSettings getFontFaceCss
13161317
}
13171318
return fontFaceCssFontFeatureSettings;
13181319
}
1320+
1321+
public org.w3c.css.properties.css.fontface.CssFontVariationSettings getFontFaceCssFontVariationSettings() {
1322+
if (fontFaceCssFontVariationSettings == null) {
1323+
fontFaceCssFontVariationSettings =
1324+
(org.w3c.css.properties.css.fontface.CssFontVariationSettings) style.CascadingOrder(new org.w3c.css.properties.css.fontface.CssFontVariationSettings(),
1325+
style, selector);
1326+
}
1327+
return fontFaceCssFontVariationSettings;
1328+
}
13191329

13201330
public CssUnicodeRange getFontFaceCssUnicodeRange() {
13211331
if (fontFaceCssUnicodeRange == null) {

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolea
4545

4646
setByUser();
4747

48+
value = parseFontVariationSettings(ac, expression, getPropertyName());
49+
}
50+
51+
public static final CssValue parseFontVariationSettings(ApplContext ac,
52+
CssExpression expression,
53+
String caller)
54+
throws InvalidParamException {
55+
4856
CssValue val;
4957
char op;
5058

@@ -63,20 +71,16 @@ public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolea
6371
if (CssIdent.isCssWide(id) || normal.equals(id)) {
6472
if (expression.getCount() != 1) {
6573
throw new InvalidParamException("value",
66-
val.toString(),
67-
getPropertyName(), ac);
74+
val.toString(), caller, ac);
6875
}
69-
value = val;
70-
break;
76+
return val;
7177
}
7278
throw new InvalidParamException("value",
73-
val.toString(),
74-
getPropertyName(), ac);
79+
val.toString(), caller, ac);
7580
case CssTypes.CSS_NUMBER:
7681
if (layervalues.size() != 1) {
7782
throw new InvalidParamException("value",
78-
val.toString(),
79-
getPropertyName(), ac);
83+
val.toString(), caller, ac);
8084
}
8185
layervalues.add(val);
8286
break;
@@ -87,15 +91,14 @@ public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolea
8791
if (s.toString().length() != 6) {
8892
throw new InvalidParamException("value",
8993
expression.getValue().toString(),
90-
getPropertyName(), ac);
94+
caller, ac);
9195
}
9296
// FIXME TODO check
9397
layervalues.add(val);
9498
break;
9599
default:
96100
throw new InvalidParamException("value",
97-
val.toString(),
98-
getPropertyName(), ac);
101+
val.toString(), caller, ac);
99102
}
100103
expression.next();
101104
if (!layervalues.isEmpty()) {
@@ -120,12 +123,12 @@ public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolea
120123
if (layervalues.size() == 1) {
121124
throw new InvalidParamException("value",
122125
layervalues.get(0).toString(),
123-
getPropertyName(), ac);
126+
caller, ac);
124127
}
125128
if (!values.isEmpty()) {
126-
value = (values.size() == 1) ? values.get(0) : new CssLayerList(values);
129+
return (values.size() == 1) ? values.get(0) : new CssLayerList(values);
127130
}
128-
131+
return null;
129132
}
130133

131134
public CssFontVariationSettings(ApplContext ac, CssExpression expression)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
12+
import static org.w3c.css.properties.css3.CssFontVariationSettings.parseFontVariationSettings;
13+
14+
/**
15+
* @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#descdef-font-face-font-variation-settings
16+
* @see org.w3c.css.properties.css3.CssFontVariationSettings
17+
*/
18+
public class CssFontVariationSettings extends org.w3c.css.properties.css.fontface.CssFontVariationSettings {
19+
20+
/**
21+
* Create a new CssFontVariationSettings
22+
*/
23+
public CssFontVariationSettings() {
24+
value = initial;
25+
}
26+
27+
/**
28+
* Creates a new CssFontVariationSettings
29+
*
30+
* @param expression The expression for this property
31+
* @throws InvalidParamException Expressions are incorrect
32+
*/
33+
public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolean check)
34+
throws InvalidParamException {
35+
setByUser();
36+
value = parseFontVariationSettings(ac, expression, getPropertyName());
37+
}
38+
39+
public CssFontVariationSettings(ApplContext ac, CssExpression expression)
40+
throws InvalidParamException {
41+
this(ac, expression, false);
42+
}
43+
44+
}
45+

0 commit comments

Comments
 (0)