Skip to content

Commit 2b0dc49

Browse files
committed
1 parent 098451e commit 2b0dc49

File tree

4 files changed

+233
-1
lines changed

4 files changed

+233
-1
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ lighting-color: org.w3c.css.properties.css3.CssLightingC
546546
@font-face.subscript-position-override org.w3c.css.properties.css3.fontface.CssSubscriptPositionOverride
547547
@font-face.subscript-size-override org.w3c.css.properties.css3.fontface.CssSubscriptSizeOverride
548548
@font-face.superscript-position-override org.w3c.css.properties.css3.fontface.CssSuperscriptPositionOverride
549+
@font-face.superscript-size-override org.w3c.css.properties.css3.fontface.CssSuperscriptSizeOverride
549550
@font-face.unicode-range: org.w3c.css.properties.css3.fontface.CssUnicodeRange
550551

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

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
import org.w3c.css.properties.css.fontface.CssSubscriptPositionOverride;
342342
import org.w3c.css.properties.css.fontface.CssSubscriptSizeOverride;
343343
import org.w3c.css.properties.css.fontface.CssSuperscriptPositionOverride;
344+
import org.w3c.css.properties.css.fontface.CssSuperscriptSizeOverride;
344345
import org.w3c.css.properties.css.fontface.CssUnicodeRange;
345346
import org.w3c.css.properties.css.viewport.CssMaxZoom;
346347
import org.w3c.css.properties.css.viewport.CssMinZoom;
@@ -636,7 +637,8 @@ public class Css3Style extends ATSCStyle {
636637
public CssSizeAdjust fontFaceCssSizeAdjust;
637638
public CssSuperscriptPositionOverride fontFaceCssSuperscriptPositionOverride;
638639
public CssSubscriptPositionOverride fontFaceCssSubscriptPositionOverride;
639-
public CssSubscriptSizeOverride fontFaceCssSubscriptSizeOverride;
640+
public CssSubscriptSizeOverride fontFaceCssSubscriptSizeOverride;
641+
public CssSuperscriptSizeOverride fontFaceCssSuperscriptSizeOverride;
640642

641643
public CssColorAdjust cssColorAdjust;
642644
public CssForcedColorAdjust cssForcedColorAdjust;
@@ -1737,6 +1739,15 @@ public CssSubscriptSizeOverride getFontFaceCssSubscriptSizeOverride() {
17371739
return fontFaceCssSubscriptSizeOverride;
17381740
}
17391741

1742+
public CssSuperscriptSizeOverride getFontFaceCssSuperscriptSizeOverride() {
1743+
if (fontFaceCssSuperscriptSizeOverride == null) {
1744+
fontFaceCssSuperscriptSizeOverride =
1745+
(CssSuperscriptSizeOverride) style.CascadingOrder(new CssSuperscriptSizeOverride(),
1746+
style, selector);
1747+
}
1748+
return fontFaceCssSuperscriptSizeOverride;
1749+
}
1750+
17401751
public CssFontDisplay getFontFaceCssFontDisplay() {
17411752
if (fontFaceCssFontDisplay == null) {
17421753
fontFaceCssFontDisplay =
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT W3C, 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+
import org.w3c.css.values.CssValueList;
15+
16+
import java.util.ArrayList;
17+
18+
import static org.w3c.css.values.CssOperator.SPACE;
19+
20+
/**
21+
* @spec https://www.w3.org/TR/2026/WD-css-fonts-5-20260303/#descdef-font-face-superscript-Size-override
22+
*/
23+
public class CssSuperscriptSizeOverride extends org.w3c.css.properties.css.fontface.CssSuperscriptSizeOverride {
24+
25+
public static final CssIdent[] allowed_values;
26+
27+
static {
28+
String[] _allowed_values = {"normal", "from-font"};
29+
allowed_values = new CssIdent[_allowed_values.length];
30+
int i = 0;
31+
for (String s : _allowed_values) {
32+
allowed_values[i++] = CssIdent.getIdent(s);
33+
}
34+
}
35+
36+
public static CssIdent getAllowedIdent(CssIdent ident) {
37+
for (CssIdent id : allowed_values) {
38+
if (id.equals(ident)) {
39+
return id;
40+
}
41+
}
42+
return null;
43+
}
44+
45+
/**
46+
* Create a new CssSuperscriptSizeOverride
47+
*/
48+
public CssSuperscriptSizeOverride() {
49+
value = initial;
50+
}
51+
52+
/**
53+
* Creates a new CssSuperscriptSizeOverride
54+
*
55+
* @param expression The expression for this property
56+
* @throws InvalidParamException Expressions are incorrect
57+
*/
58+
public CssSuperscriptSizeOverride(ApplContext ac, CssExpression expression, boolean check)
59+
throws InvalidParamException {
60+
if (check && expression.getCount() > 2) {
61+
throw new InvalidParamException("unrecognize", ac);
62+
}
63+
64+
setByUser();
65+
66+
char op;
67+
CssValue val;
68+
69+
ArrayList<CssValue> values = new ArrayList<>();
70+
71+
while (!expression.end()) {
72+
val = expression.getValue();
73+
op = expression.getOperator();
74+
switch (val.getType()) {
75+
case CssTypes.CSS_PERCENTAGE:
76+
val.getCheckableValue().checkPositiveness(ac, this);
77+
values.add(val);
78+
break;
79+
case CssTypes.CSS_IDENT:
80+
if (getAllowedIdent(val.getIdent()) != null) {
81+
values.add(val);
82+
break;
83+
}
84+
default:
85+
throw new InvalidParamException("value",
86+
val.toString(),
87+
getPropertyName(), ac);
88+
}
89+
expression.next();
90+
if (!expression.end() && op != SPACE) {
91+
throw new InvalidParamException("operator", op, ac);
92+
}
93+
}
94+
value = (values.size() == 1) ? values.get(0) : new CssValueList(values);
95+
}
96+
97+
public CssSuperscriptSizeOverride(ApplContext ac, CssExpression expression)
98+
throws InvalidParamException {
99+
this(ac, expression, false);
100+
}
101+
102+
}
103+

0 commit comments

Comments
 (0)