1- // $Id$
1+ //
22// Author: Yves Lafon <ylafon@w3.org>
33//
4- // (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
4+ // (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang , 2012.
55// Please first read the full copyright statement in file COPYRIGHT.html
66package org .w3c .css .properties .css3 ;
77
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 java .util .ArrayList ;
17+
18+ import static org .w3c .css .values .CssOperator .SPACE ;
1419
1520/**
16- * @spec https://www.w3.org/TR/2017 /WD-css-text-3-20170822 /#text-transform-property
21+ * @spec https://www.w3.org/TR/2018 /WD-css-text-3-20181212 /#text-transform-property
1722 */
1823public class CssTextTransform extends org .w3c .css .properties .css .CssTextTransform {
1924
20- private static CssIdent [] allowed_values ;
25+ private static CssIdent [] allowed_action_values ;
26+ private static CssIdent none , fullWidth , fullSizeKana ;
27+
2128
2229 static {
23- String id_values [] = {"none" , "capitalize" , "uppercase" ,
24- "lowercase" , "full-width" };
25- allowed_values = new CssIdent [id_values .length ];
30+ none = CssIdent .getIdent ("none" );
31+ fullWidth = CssIdent .getIdent ("full-width" );
32+ fullSizeKana = CssIdent .getIdent ("full-size-kana" );
33+
34+ String id_values [] = {"capitalize" , "uppercase" , "lowercase" };
35+ allowed_action_values = new CssIdent [id_values .length ];
2636 int i = 0 ;
2737 for (String s : id_values ) {
28- allowed_values [i ++] = CssIdent .getIdent (s );
38+ allowed_action_values [i ++] = CssIdent .getIdent (s );
2939 }
3040 }
3141
32- public static CssIdent getMatchingIdent (CssIdent ident ) {
33- for (CssIdent id : allowed_values ) {
42+ public static CssIdent getMatchingActionIdent (CssIdent ident ) {
43+ for (CssIdent id : allowed_action_values ) {
3444 if (id .equals (ident )) {
3545 return id ;
3646 }
@@ -56,29 +66,68 @@ public CssTextTransform(ApplContext ac, CssExpression expression, boolean check)
5666 throws InvalidParamException {
5767 setByUser ();
5868 CssValue val = expression .getValue ();
69+ char op ;
70+ ArrayList <CssValue > values = new ArrayList <>();
71+ boolean got_action = false ;
72+ boolean got_full_width = false ;
73+ boolean got_full_size_kana = false ;
5974
60- if (check && expression .getCount () > 1 ) {
75+ if (check && expression .getCount () > 3 ) {
6176 throw new InvalidParamException ("unrecognize" , ac );
6277 }
6378
64- if (val .getType () != CssTypes .CSS_IDENT ) {
65- throw new InvalidParamException ("value" ,
66- expression .getValue (),
67- getPropertyName (), ac );
68- }
69- // ident, so inherit, or allowed value
70- if (inherit .equals (val )) {
71- value = inherit ;
72- } else {
73- val = getMatchingIdent ((CssIdent ) val );
74- if (val == null ) {
79+ while (!expression .end ()) {
80+ val = expression .getValue ();
81+ op = expression .getOperator ();
82+
83+ if (val .getType () != CssTypes .CSS_IDENT ) {
7584 throw new InvalidParamException ("value" ,
7685 expression .getValue (),
7786 getPropertyName (), ac );
7887 }
79- value = val ;
88+ // ident, so inherit, or allowed value
89+ if (inherit .equals (val )) {
90+ if (expression .getCount () > 1 ) {
91+ throw new InvalidParamException ("value" ,
92+ expression .getValue (),
93+ getPropertyName (), ac );
94+ }
95+ values .add (inherit );
96+ } else if (none .equals (val )) {
97+ if (expression .getCount () > 1 ) {
98+ throw new InvalidParamException ("value" ,
99+ expression .getValue (),
100+ getPropertyName (), ac );
101+ }
102+ values .add (none );
103+ } else if (fullWidth .equals (val ) && !got_full_width ) {
104+ got_full_width = true ;
105+ values .add (fullWidth );
106+ } else if (fullSizeKana .equals (val ) && !got_full_size_kana ) {
107+ got_full_size_kana = true ;
108+ values .add (fullSizeKana );
109+ } else if (!got_action ) {
110+ got_action = true ;
111+ val = getMatchingActionIdent ((CssIdent ) val );
112+ if (val == null ) {
113+ throw new InvalidParamException ("value" ,
114+ expression .getValue (),
115+ getPropertyName (), ac );
116+ }
117+ got_action = true ;
118+ values .add (val );
119+ } else {
120+ throw new InvalidParamException ("value" ,
121+ expression .getValue (),
122+ getPropertyName (), ac );
123+ }
124+ if (op != SPACE ) {
125+ throw new InvalidParamException ("operator" , op ,
126+ getPropertyName (), ac );
127+ }
128+ expression .next ();
80129 }
81- expression . next ( );
130+ value = ( values . size () == 1 ) ? values . get ( 0 ) : new CssValueList ( values );
82131 }
83132
84133 public CssTextTransform (ApplContext ac , CssExpression expression )
0 commit comments