8
8
import org .w3c .css .atrules .css .media .Media ;
9
9
import org .w3c .css .atrules .css .media .MediaFeature ;
10
10
import org .w3c .css .parser .AtRule ;
11
+ import org .w3c .css .parser .CssError ;
12
+ import org .w3c .css .parser .analyzer .ParseException ;
11
13
import org .w3c .css .util .ApplContext ;
12
14
import org .w3c .css .util .InvalidParamException ;
13
15
14
16
import java .util .ArrayList ;
15
17
16
18
/**
17
- * @spec http ://www.w3.org/TR/2012/REC-css3- mediaqueries-20120619 /
19
+ * @spec https ://www.w3.org/TR/2017/CR- mediaqueries-4-20170905 /
18
20
*/
19
21
20
22
public class AtRuleMedia extends org .w3c .css .atrules .css .AtRuleMedia {
21
- static final String [] mediaCSS21 = {
22
- "all" , "braille" , "embossed" , "handheld" , "print" , "projection" ,
23
- "screen" , "speech" , "tty" , "tv"
23
+ static final String [] mediaType = {
24
+ "all" , "print" , "screen" , "speech"
24
25
};
25
26
26
27
static final String [] deprecatedMedia = {
27
- "aural"
28
+ "aural" , "braille" , "embossed" , "handheld" , "projection" ,
29
+ "tty" , "tv"
28
30
};
29
31
30
32
/**
@@ -50,7 +52,7 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me
50
52
return this ;
51
53
}
52
54
medium = medium .toLowerCase ();
53
- for (String s : mediaCSS21 ) {
55
+ for (String s : mediaType ) {
54
56
if (medium .equals (s )) {
55
57
media .setMedia (s );
56
58
allMedia .add (media );
@@ -59,8 +61,13 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me
59
61
}
60
62
for (String s : deprecatedMedia ) {
61
63
if (medium .equals (s )) {
62
- // we add a warning as it has been deprecated
63
- ac .getFrame ().addWarning ("deprecatedmedia" , medium );
64
+ // error because the current Media Queries spec states that
65
+ // "Authors *must not* use these media types"
66
+ ac .getFrame ().addError (
67
+ new CssError (new ParseException (String .format (
68
+ ac .getMsg ()
69
+ .getString ("warning.deprecatedmedia" ),
70
+ medium ))));
64
71
allMedia .add (new Media (s ));
65
72
return this ;
66
73
}
0 commit comments