1
- // $Id$
1
+ //
2
2
// Author: Yves Lafon <ylafon@w3.org>
3
3
//
4
- // (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
4
+ // (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012-2019
5
5
// Please first read the full copyright statement in file COPYRIGHT.html
6
6
package org .w3c .css .properties .css3 ;
7
7
8
8
import org .w3c .css .util .ApplContext ;
9
9
import org .w3c .css .util .InvalidParamException ;
10
+ import org .w3c .css .values .CssAngle ;
10
11
import org .w3c .css .values .CssExpression ;
12
+ import org .w3c .css .values .CssIdent ;
13
+ import org .w3c .css .values .CssOperator ;
11
14
import org .w3c .css .values .CssTypes ;
12
15
import org .w3c .css .values .CssValue ;
16
+ import org .w3c .css .values .CssValueList ;
17
+
18
+ import java .util .ArrayList ;
13
19
14
20
/**
15
- * @spec http://www.w3.org/TR/2012/CR-css3-images-20120417/#image-orientation
21
+ * @spec https://www.w3.org/TR/2019/CR-css-images-3-20191010/#propdef-image-orientation
22
+ * @deprecated
16
23
*/
17
24
public class CssImageOrientation extends org .w3c .css .properties .css .CssImageOrientation {
18
25
26
+ public static final CssIdent [] allowed_values ;
27
+ public static final CssIdent flip ;
28
+
29
+ static {
30
+ String [] _allowed_values = {"from-image" , "none" , "flip" };
31
+ allowed_values = new CssIdent [_allowed_values .length ];
32
+ int i = 0 ;
33
+ for (String s : _allowed_values ) {
34
+ allowed_values [i ++] = CssIdent .getIdent (s );
35
+ }
36
+ flip = CssIdent .getIdent ("flip" );
37
+ }
38
+
39
+ public static CssIdent getAllowedIdent (CssIdent ident ) {
40
+ for (CssIdent id : allowed_values ) {
41
+ if (id .equals (ident )) {
42
+ return id ;
43
+ }
44
+ }
45
+ return null ;
46
+ }
47
+
19
48
/**
20
49
* Create a new CssImageOrientation
21
50
*/
@@ -32,7 +61,7 @@ public CssImageOrientation() {
32
61
*/
33
62
public CssImageOrientation (ApplContext ac , CssExpression expression , boolean check )
34
63
throws InvalidParamException {
35
- if (check && expression .getCount () > 1 ) {
64
+ if (check && expression .getCount () > 2 ) {
36
65
throw new InvalidParamException ("unrecognize" , ac );
37
66
}
38
67
setByUser ();
@@ -43,17 +72,54 @@ public CssImageOrientation(ApplContext ac, CssExpression expression, boolean che
43
72
val = expression .getValue ();
44
73
op = expression .getOperator ();
45
74
75
+ ac .getFrame ().addWarning ("deprecatedproperty" , getPropertyName ());
76
+
46
77
switch (val .getType ()) {
47
78
case CssTypes .CSS_NUMBER :
48
79
val .getCheckableValue ().checkEqualsZero (ac , this );
49
80
case CssTypes .CSS_ANGLE :
50
81
value = val ;
82
+ // check for optional 'flip'
83
+ if (op == CssOperator .SPACE && expression .getRemainingCount () > 1 ) {
84
+ expression .next ();
85
+ val = expression .getValue ();
86
+ op = expression .getOperator ();
87
+ if (val .getType () != CssTypes .CSS_IDENT ) {
88
+ throw new InvalidParamException ("value" ,
89
+ val .toString (),
90
+ getPropertyName (), ac );
91
+ }
92
+ if (!flip .equals ((CssIdent ) val )) {
93
+ throw new InvalidParamException ("value" ,
94
+ val .toString (),
95
+ getPropertyName (), ac );
96
+ }
97
+ ArrayList <CssValue > v = new ArrayList <>(2 );
98
+ v .add (value );
99
+ v .add (flip );
100
+ value = new CssValueList (v );
101
+ }
51
102
break ;
52
103
case CssTypes .CSS_IDENT :
104
+ if (check && expression .getCount () > 1 ) {
105
+ throw new InvalidParamException ("unrecognize" , ac );
106
+ }
53
107
if (inherit .equals (val )) {
54
108
value = inherit ;
55
109
break ;
56
110
}
111
+ value = getAllowedIdent ((CssIdent ) val );
112
+ if (value != null ) {
113
+ // single 'flip' will be pretty-printed as 0deg flip
114
+ if (flip == value ) {
115
+ ArrayList <CssValue > v = new ArrayList <>(2 );
116
+ v .add (new CssAngle ());
117
+ v .add (flip );
118
+ value = new CssValueList (v );
119
+ }
120
+ break ;
121
+ }
122
+ // null value, bail out
57
123
default :
58
124
throw new InvalidParamException ("value" ,
59
125
val .toString (),
0 commit comments