Skip to content

Commit 7bedb25

Browse files
Make deprecated media types an error (not warning)
When the CSS3 profile is selected, this change makes the CSS checker report an error if any deprecated media types are used — per the normative requirements in the current Media Queries spec: https://www.w3.org/TR/2017/CR-mediaqueries-4-20170905/#media-types > ...the following deprecated media types are defined. Authors must not use these media types: tty, tv, projection, handheld, braille, embossed, aural Otherwise, without this change, only a warning (rather than an error) is reported.
1 parent c44e222 commit 7bedb25

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

org/w3c/css/atrules/css3/AtRuleMedia.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@
88
import org.w3c.css.atrules.css.media.Media;
99
import org.w3c.css.atrules.css.media.MediaFeature;
1010
import org.w3c.css.parser.AtRule;
11+
import org.w3c.css.parser.CssError;
12+
import org.w3c.css.parser.analyzer.ParseException;
1113
import org.w3c.css.util.ApplContext;
1214
import org.w3c.css.util.InvalidParamException;
1315

1416
import java.util.ArrayList;
1517

1618
/**
17-
* @spec http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/
19+
* @spec https://www.w3.org/TR/2017/CR-mediaqueries-4-20170905/
1820
*/
1921

2022
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"
2425
};
2526

2627
static final String[] deprecatedMedia = {
27-
"aural"
28+
"aural", "braille", "embossed", "handheld", "projection",
29+
"tty", "tv"
2830
};
2931

3032
/**
@@ -50,7 +52,7 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me
5052
return this;
5153
}
5254
medium = medium.toLowerCase();
53-
for (String s : mediaCSS21) {
55+
for (String s : mediaType) {
5456
if (medium.equals(s)) {
5557
media.setMedia(s);
5658
allMedia.add(media);
@@ -59,8 +61,13 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me
5961
}
6062
for (String s : deprecatedMedia) {
6163
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))));
6471
allMedia.add(new Media(s));
6572
return this;
6673
}

0 commit comments

Comments
 (0)