8247955: doclint: don't complain about summary/caption when role=presentation
Reviewed-by: prappo
This commit is contained in:
parent
1e1985da9b
commit
e66a2a3384
@ -36,6 +36,7 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -114,6 +115,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
|
|
||||||
public enum Flag {
|
public enum Flag {
|
||||||
TABLE_HAS_CAPTION,
|
TABLE_HAS_CAPTION,
|
||||||
|
TABLE_IS_PRESENTATION,
|
||||||
HAS_ELEMENT,
|
HAS_ELEMENT,
|
||||||
HAS_HEADING,
|
HAS_HEADING,
|
||||||
HAS_INLINE_TAG,
|
HAS_INLINE_TAG,
|
||||||
@ -530,7 +532,8 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
if (t == top.tag) {
|
if (t == top.tag) {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case TABLE:
|
case TABLE:
|
||||||
if (!top.attrs.contains(HtmlTag.Attr.SUMMARY)
|
if (!top.flags.contains(Flag.TABLE_IS_PRESENTATION)
|
||||||
|
&& !top.attrs.contains(HtmlTag.Attr.SUMMARY)
|
||||||
&& !top.flags.contains(Flag.TABLE_HAS_CAPTION)) {
|
&& !top.flags.contains(Flag.TABLE_HAS_CAPTION)) {
|
||||||
env.messages.error(ACCESSIBILITY, tree,
|
env.messages.error(ACCESSIBILITY, tree,
|
||||||
"dc.no.summary.or.caption.for.table");
|
"dc.no.summary.or.caption.for.table");
|
||||||
@ -687,6 +690,15 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ROLE:
|
||||||
|
if (currTag == HtmlTag.TABLE) {
|
||||||
|
String v = getAttrValue(tree);
|
||||||
|
if (Objects.equals(v, "presentation")) {
|
||||||
|
tagStack.peek().flags.add(Flag.TABLE_IS_PRESENTATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
test/langtools/tools/doclint/AccessibilityTest5.java
Normal file
30
test/langtools/tools/doclint/AccessibilityTest5.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8247955
|
||||||
|
* @summary Add new doclint package
|
||||||
|
* @modules jdk.compiler/com.sun.tools.doclint
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -XhtmlVersion:html5 -Xmsgs:-accessibility AccessibilityTest5.java
|
||||||
|
* @run main DocLintTester -XhtmlVersion:html5 -ref AccessibilityTest5.out AccessibilityTest5.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This test should be merged into AccessibilityTest.java when we drop support for html4.
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class AccessibilityTest5 {
|
||||||
|
/**
|
||||||
|
* <table><caption>ok</caption><tr><th>head<tr><td>data</table>
|
||||||
|
*/
|
||||||
|
public void table_with_caption() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <table><tr><th>head<tr><td>data</table>
|
||||||
|
*/
|
||||||
|
public void table_without_caption() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <table role="presentation"><tr><th>head<tr><td>data</table>
|
||||||
|
*/
|
||||||
|
public void table_presentation() { }
|
||||||
|
}
|
||||||
|
|
4
test/langtools/tools/doclint/AccessibilityTest5.out
Normal file
4
test/langtools/tools/doclint/AccessibilityTest5.out
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
AccessibilityTest5.java:21: error: no summary or caption for table
|
||||||
|
* <table><tr><th>head<tr><td>data</table>
|
||||||
|
^
|
||||||
|
1 error
|
Loading…
x
Reference in New Issue
Block a user