1111import org .w3c .css .values .CssIdent ;
1212import org .w3c .css .values .CssTypes ;
1313import org .w3c .css .values .CssValue ;
14+ import org .w3c .css .values .CssValueList ;
15+
16+ import static org .w3c .css .values .CssOperator .SPACE ;
1417
1518/**
16- * @spec https://www.w3.org/TR/2021 /WD-css-fonts-4-20210729 /#propdef-font-size-adjust
19+ * @spec https://www.w3.org/TR/2024 /WD-css-fonts-5-20240206 /#propdef-font-size-adjust
1720 */
1821public class CssFontSizeAdjust extends org .w3c .css .properties .css .CssFontSizeAdjust {
1922
23+ public static final CssIdent [] optionalIdentValues ;
24+ public static final CssIdent from_font ;
25+
26+ static {
27+ String [] _optionalIdentValues = {"ex-height" , "cap-height" , "ch-width" ,
28+ "ic-width" , "ic-height" };
29+ optionalIdentValues = new CssIdent [_optionalIdentValues .length ];
30+ for (int i = 0 ; i < optionalIdentValues .length ; i ++) {
31+ optionalIdentValues [i ] = CssIdent .getIdent (_optionalIdentValues [i ]);
32+ }
33+ from_font = CssIdent .getIdent ("from-font" );
34+ }
35+
36+ public static final CssIdent getOptionalIdent (CssIdent ident ) {
37+ for (CssIdent id : optionalIdentValues ) {
38+ if (id .equals (ident )) {
39+ return id ;
40+ }
41+ }
42+ return null ;
43+ }
44+
2045 public static final CssIdent getAllowedIdent (CssIdent ident ) {
21- if (none .equals (ident )) {
22- return none ;
46+ if (from_font .equals (ident )) {
47+ return from_font ;
2348 }
2449 return null ;
2550 }
@@ -39,37 +64,74 @@ public CssFontSizeAdjust() {
3964 */
4065 public CssFontSizeAdjust (ApplContext ac , CssExpression expression , boolean check )
4166 throws InvalidParamException {
42- if (check && expression .getCount () > 1 ) {
67+ if (check && expression .getCount () > 2 ) {
4368 throw new InvalidParamException ("unrecognize" , ac );
4469 }
4570
4671 setByUser ();
4772
4873 CssValue val ;
74+ CssValueList vl = null ;
4975 char op ;
76+ boolean got_option = false ;
77+
78+ while (!expression .end ()) {
79+ val = expression .getValue ();
80+ op = expression .getOperator ();
5081
51- val = expression .getValue ();
52- op = expression .getOperator ();
53-
54- switch (val .getType ()) {
55- case CssTypes .CSS_IDENT :
56- CssIdent id = val .getIdent ();
57- if (CssIdent .isCssWide (id ) || (getAllowedIdent (id ) != null )) {
58- value = val ;
82+ switch (val .getType ()) {
83+ case CssTypes .CSS_IDENT :
84+ CssIdent id = val .getIdent ();
85+ if (expression .getCount () == 1 ) {
86+ if (CssIdent .isCssWide (id ) || (getAllowedIdent (id ) != null ) || none .equals (id )) {
87+ value = val ;
88+ break ;
89+ }
90+ throw new InvalidParamException ("value" ,
91+ val , getPropertyName (), ac );
92+ } else {
93+ if (!got_option ) {
94+ got_option = (getOptionalIdent (id ) != null );
95+ if (got_option ) {
96+ vl = new CssValueList ();
97+ vl .add (val );
98+ } else {
99+ throw new InvalidParamException ("value" ,
100+ val , getPropertyName (), ac );
101+ }
102+ } else {
103+ // got_option is true, so vl was created
104+ if (getAllowedIdent (id ) != null ) {
105+ vl .add (val );
106+ } else {
107+ throw new InvalidParamException ("value" ,
108+ val , getPropertyName (), ac );
109+ }
110+ }
111+ }
59112 break ;
60- }
61- throw new InvalidParamException ("value" ,
62- val , getPropertyName (), ac );
63- case CssTypes .CSS_NUMBER :
64- val .getCheckableValue ().checkPositiveness (ac , getPropertyName ());
65- value = val ;
66- break ;
67- default :
68- throw new InvalidParamException ("value" ,
69- val , getPropertyName (), ac );
113+ case CssTypes .CSS_NUMBER :
114+ val .getCheckableValue ().checkPositiveness (ac , getPropertyName ());
115+ if (got_option ) {
116+ vl .add (val );
117+ } else {
118+ value = val ;
119+ }
120+ break ;
121+ default :
122+ throw new InvalidParamException ("value" ,
123+ val , getPropertyName (), ac );
124+ }
125+ if (op != SPACE ) {
126+ throw new InvalidParamException ("operator" , op ,
127+ getPropertyName (), ac );
128+ }
129+ expression .next ();
130+ }
131+ // reassign if we got multiple values
132+ if (got_option ) {
133+ value = vl ;
70134 }
71- expression .next ();
72-
73135 }
74136
75137 public CssFontSizeAdjust (ApplContext ac , CssExpression expression )
0 commit comments