Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8247955: doclint: don't complain about summary/caption when role=pres…
…entation

Reviewed-by: prappo
  • Loading branch information
jonathan-gibbons committed Jun 23, 2020
1 parent 1e1985d commit e66a2a3384281c81bcc466eba1563d94cf47945f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
@@ -36,6 +36,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -114,6 +115,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {

public enum Flag {
TABLE_HAS_CAPTION,
TABLE_IS_PRESENTATION,
HAS_ELEMENT,
HAS_HEADING,
HAS_INLINE_TAG,
@@ -530,7 +532,8 @@ public Void visitEndElement(EndElementTree tree, Void ignore) {
if (t == top.tag) {
switch (t) {
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)) {
env.messages.error(ACCESSIBILITY, tree,
"dc.no.summary.or.caption.for.table");
@@ -687,6 +690,15 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
}
}
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;
}
}
}
@@ -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() { }
}

@@ -0,0 +1,4 @@
AccessibilityTest5.java:21: error: no summary or caption for table
* <table><tr><th>head<tr><td>data</table>
^
1 error

0 comments on commit e66a2a3

Please sign in to comment.