8335122: Reorganize internal low-level support for HTML in jdk.javadoc

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons 2024-08-02 17:53:23 +00:00
parent f2e1205abf
commit 7deee74525
107 changed files with 1377 additions and 1395 deletions

View File

@ -38,13 +38,14 @@ import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleTypeVisitor14; import javax.lang.model.util.SimpleTypeVisitor14;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo.Kind.LINK_TYPE_PARAMS; import static jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo.Kind.LINK_TYPE_PARAMS;
import static jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS; import static jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS;
@ -108,7 +109,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
} }
String signature = utils.flatSignature((ExecutableElement) member, typeElement); String signature = utils.flatSignature((ExecutableElement) member, typeElement);
if (signature.length() > 2) { if (signature.length() > 2) {
content.add(new HtmlTree(TagName.WBR)); content.add(new HtmlTree(HtmlTag.WBR));
} }
content.add(signature); content.add(signature);
@ -120,7 +121,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement te, Element member, protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement te, Element member,
Content target) { Content target) {
ExecutableElement ee = (ExecutableElement)member; ExecutableElement ee = (ExecutableElement)member;
Content memberLink = writer.getDocLink(context, te, ee, name(ee), HtmlStyle.memberNameLink); Content memberLink = writer.getDocLink(context, te, ee, name(ee), HtmlStyles.memberNameLink);
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);
addParameters(ee, code); addParameters(ee, code);
target.add(code); target.add(code);
@ -143,7 +144,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
// Add explicit line break between method type parameters and // Add explicit line break between method type parameters and
// return type in member summary table to avoid random wrapping. // return type in member summary table to avoid random wrapping.
if (typeParameters.charCount() > 10) { if (typeParameters.charCount() > 10) {
target.add(new HtmlTree(TagName.BR)); target.add(new HtmlTree(HtmlTag.BR));
} else { } else {
target.add(Entity.NO_BREAK_SPACE); target.add(Entity.NO_BREAK_SPACE);
} }
@ -232,7 +233,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
Content params = getParameters(member, false); Content params = getParameters(member, false);
if (params.charCount() > 2) { if (params.charCount() > 2) {
// only add <wbr> for non-empty parameters // only add <wbr> for non-empty parameters
target.add(new HtmlTree(TagName.WBR)); target.add(new HtmlTree(HtmlTag.WBR));
} }
target.add(params); target.add(params);
} }

View File

@ -44,15 +44,16 @@ import javax.lang.model.type.TypeMirror;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.ANNOTATION_TYPE_MEMBER; import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.ANNOTATION_TYPE_MEMBER;
import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL; import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL;
@ -450,7 +451,7 @@ public abstract class AbstractMemberWriter {
*/ */
protected void addModifiersAndType(Element member, TypeMirror type, protected void addModifiersAndType(Element member, TypeMirror type,
Content target) { Content target) {
var code = new HtmlTree(TagName.CODE); var code = new HtmlTree(HtmlTag.CODE);
addModifiers(member, code); addModifiers(member, code);
if (type == null) { if (type == null) {
code.add(switch (member.getKind()) { code.add(switch (member.getKind()) {
@ -518,7 +519,7 @@ public abstract class AbstractMemberWriter {
var t = configuration.tagletManager.getTaglet(DocTree.Kind.DEPRECATED); var t = configuration.tagletManager.getTaglet(DocTree.Kind.DEPRECATED);
Content output = t.getAllBlockTagOutput(member, writer.getTagletWriterInstance(false)); Content output = t.getAllBlockTagOutput(member, writer.getTagletWriterInstance(false));
if (!output.isEmpty()) { if (!output.isEmpty()) {
target.add(HtmlTree.DIV(HtmlStyle.deprecationBlock, output)); target.add(HtmlTree.DIV(HtmlStyles.deprecationBlock, output));
} }
} }
@ -570,9 +571,9 @@ public abstract class AbstractMemberWriter {
return; return;
} }
boolean printedUseTableHeader = false; boolean printedUseTableHeader = false;
var useTable = new Table<Void>(HtmlStyle.summaryTable) var useTable = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(heading) .setCaption(heading)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast);
for (Element element : members) { for (Element element : members) {
TypeElement te = (typeElement == null) TypeElement te = (typeElement == null)
? utils.getEnclosingTypeElement(element) ? utils.getEnclosingTypeElement(element)
@ -588,7 +589,7 @@ public abstract class AbstractMemberWriter {
&& !utils.isConstructor(element) && !utils.isConstructor(element)
&& !utils.isTypeElement(element)) { && !utils.isTypeElement(element)) {
var name = HtmlTree.SPAN(HtmlStyle.typeNameLabel); var name = HtmlTree.SPAN(HtmlStyles.typeNameLabel);
name.add(name(te) + "."); name.add(name(te) + ".");
typeContent.add(name); typeContent.add(name);
} }
@ -669,7 +670,7 @@ public abstract class AbstractMemberWriter {
* @return the inherited summary links * @return the inherited summary links
*/ */
public Content getInheritedSummaryLinks() { public Content getInheritedSummaryLinks() {
return new HtmlTree(TagName.CODE); return new HtmlTree(HtmlTag.CODE);
} }
/** /**

View File

@ -25,14 +25,15 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.RawHtml;
/** /**
* Abstract class to generate the top-level "overview" files. * Abstract class to generate the top-level "overview" files.
@ -135,8 +136,8 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
if (!doctitle.isEmpty()) { if (!doctitle.isEmpty()) {
var title = RawHtml.of(doctitle); var title = RawHtml.of(doctitle);
var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, title); HtmlStyles.title, title);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
target.add(div); target.add(div);
} }
} }

View File

@ -25,18 +25,20 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree.Hierarchy;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import javax.lang.model.element.TypeElement;
import java.util.Collection; import java.util.Collection;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree.Hierarchy;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* Abstract class to print the class hierarchy page for all the Classes. This * Abstract class to print the class hierarchy page for all the Classes. This
@ -77,10 +79,10 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
protected void addLevelInfo(TypeElement parent, Collection<TypeElement> collection, protected void addLevelInfo(TypeElement parent, Collection<TypeElement> collection,
Hierarchy hierarchy, Content content) { Hierarchy hierarchy, Content content) {
if (!collection.isEmpty()) { if (!collection.isEmpty()) {
var ul = new HtmlTree(TagName.UL); var ul = new HtmlTree(HtmlTag.UL);
for (TypeElement local : collection) { for (TypeElement local : collection) {
var li = new HtmlTree(TagName.LI); var li = new HtmlTree(HtmlTag.LI);
li.setStyle(HtmlStyle.circle); li.setStyle(HtmlStyles.circle);
addPartialInfo(local, li); addPartialInfo(local, li);
addExtendsImplements(parent, local, li); addExtendsImplements(parent, local, li);
addLevelInfo(local, hierarchy.subtypes(local), hierarchy, li); // Recurse addLevelInfo(local, hierarchy.subtypes(local), hierarchy, li); // Recurse
@ -104,7 +106,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
Content headingContent = contents.getContent(heading); Content headingContent = contents.getContent(heading);
var sectionHeading = HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING, var sectionHeading = HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING,
headingContent); headingContent);
var section = HtmlTree.SECTION(HtmlStyle.hierarchy, sectionHeading); var section = HtmlTree.SECTION(HtmlStyles.hierarchy, sectionHeading);
addLevelInfo(!utils.isPlainInterface(firstTypeElement) ? firstTypeElement : null, addLevelInfo(!utils.isPlainInterface(firstTypeElement) ? firstTypeElement : null,
roots, hierarchy, section); roots, hierarchy, section);
content.add(section); content.add(section);

View File

@ -33,14 +33,16 @@ import java.util.TreeSet;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DeprecatedTree; import com.sun.source.doctree.DeprecatedTree;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag; import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* Generate the file with list of all the classes in this run. * Generate the file with list of all the classes in this run.
@ -79,9 +81,9 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
* @param target the content to which the links will be added * @param target the content to which the links will be added
*/ */
protected void addContents(Content target) { protected void addContents(Content target) {
var table = new Table<TypeElement>(HtmlStyle.summaryTable) var table = new Table<TypeElement>(HtmlStyles.summaryTable)
.setHeader(new TableHeader(contents.classLabel, contents.descriptionLabel)) .setHeader(new TableHeader(contents.classLabel, contents.descriptionLabel))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast)
.setId(HtmlIds.ALL_CLASSES_TABLE) .setId(HtmlIds.ALL_CLASSES_TABLE)
.setDefaultTab(contents.allClassesAndInterfacesLabel) .setDefaultTab(contents.allClassesAndInterfacesLabel)
.addTab(contents.interfaces, utils::isPlainInterface) .addTab(contents.interfaces, utils::isPlainInterface)
@ -96,8 +98,8 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
} }
Content titleContent = contents.allClassesAndInterfacesLabel; Content titleContent = contents.allClassesAndInterfacesLabel;
var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent); HtmlStyles.title, titleContent);
var headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); var headerDiv = HtmlTree.DIV(HtmlStyles.header, pHeading);
target.add(headerDiv); target.add(headerDiv);
if (!table.isEmpty()) { if (!table.isEmpty()) {
target.add(table); target.add(table);

View File

@ -29,12 +29,13 @@ import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate the file with list of all the packages in this run. * Generate the file with list of all the packages in this run.
@ -60,8 +61,8 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter {
addPackages(mainContent); addPackages(mainContent);
Content titleContent = contents.allPackagesLabel; Content titleContent = contents.allPackagesLabel;
var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent); HtmlStyles.title, titleContent);
var headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); var headerDiv = HtmlTree.DIV(HtmlStyles.header, pHeading);
HtmlTree body = getBody(getWindowTitle(label)); HtmlTree body = getBody(getWindowTitle(label));
body.add(new BodyContents() body.add(new BodyContents()
.setHeader(getHeader(PageMode.ALL_PACKAGES)) .setHeader(getHeader(PageMode.ALL_PACKAGES))
@ -77,10 +78,10 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter {
* @param target the content to which the links will be added * @param target the content to which the links will be added
*/ */
protected void addPackages(Content target) { protected void addPackages(Content target) {
var table = new Table<PackageElement>(HtmlStyle.summaryTable) var table = new Table<PackageElement>(HtmlStyles.summaryTable)
.setCaption(Text.of(contents.packageSummaryLabel.toString())) .setCaption(Text.of(contents.packageSummaryLabel.toString()))
.setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel)) .setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (PackageElement pkg : configuration.packages) { for (PackageElement pkg : configuration.packages) {
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) { if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg)); Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));

View File

@ -32,13 +32,14 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.Comment; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Comment;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
@ -96,7 +97,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
for (Element member : members) { for (Element member : members) {
currentMember = member; currentMember = member;
Content annotationContent = getAnnotationHeaderContent(currentMember); Content annotationContent = getAnnotationHeaderContent(currentMember);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildAnnotationTypeMemberChildren(div); buildAnnotationTypeMemberChildren(div);
annotationContent.add(div); annotationContent.add(div);
memberList.add(writer.getMemberListItem(annotationContent)); memberList.add(writer.getMemberListItem(annotationContent));
@ -181,7 +182,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.memberSummary, writer.addSummary(HtmlStyles.memberSummary,
switch (kind) { switch (kind) {
case ANNOTATION_TYPE_MEMBER_REQUIRED -> HtmlIds.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY; case ANNOTATION_TYPE_MEMBER_REQUIRED -> HtmlIds.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY;
case ANNOTATION_TYPE_MEMBER_OPTIONAL -> HtmlIds.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY; case ANNOTATION_TYPE_MEMBER_OPTIONAL -> HtmlIds.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY;
@ -209,7 +210,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING, var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
Text.of(name(member))); Text.of(name(member)));
content.add(heading); content.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, content) return HtmlTree.SECTION(HtmlStyles.detail, content)
.setId(htmlIds.forMember((ExecutableElement) member).getFirst()); .setId(htmlIds.forMember((ExecutableElement) member).getFirst());
} }
@ -238,7 +239,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
protected Content getAnnotationDetails(Content annotationDetailsHeader, Content annotationDetails) { protected Content getAnnotationDetails(Content annotationDetailsHeader, Content annotationDetails) {
Content c = new ContentBuilder(annotationDetailsHeader, annotationDetails); Content c = new ContentBuilder(annotationDetailsHeader, annotationDetails);
return getMember(HtmlTree.SECTION(HtmlStyle.memberDetails, c)); return getMember(HtmlTree.SECTION(HtmlStyles.memberDetails, c));
} }
@Override @Override
@ -278,10 +279,10 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setCaption(getCaption()) .setCaption(getCaption())
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast);
} }
@Override @Override
@ -292,7 +293,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member, protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member,
Content content) { Content content) {
Content memberLink = writer.getDocLink(context, utils.getEnclosingTypeElement(member), member, Content memberLink = writer.getDocLink(context, utils.getEnclosingTypeElement(member), member,
name(member), HtmlStyle.memberNameLink); name(member), HtmlStyles.memberNameLink);
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);
content.add(code); content.add(code);
} }
@ -331,7 +332,7 @@ public class AnnotationTypeMemberWriter extends AbstractMemberWriter {
ExecutableElement ee = (ExecutableElement) member; ExecutableElement ee = (ExecutableElement) member;
AnnotationValue value = ee.getDefaultValue(); AnnotationValue value = ee.getDefaultValue();
if (value != null) { if (value != null) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.default_)); dl.add(HtmlTree.DT(contents.default_));
dl.add(HtmlTree.DD(HtmlTree.CODE(Text.of(value.toString())))); dl.add(HtmlTree.DD(HtmlTree.CODE(Text.of(value.toString()))));
annotationContent.add(dl); annotationContent.add(dl);

View File

@ -38,11 +38,8 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic; import javax.tools.Diagnostic;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
@ -50,6 +47,10 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
@ -244,10 +245,10 @@ public class ClassUseWriter extends SubWriterHolderWriter {
"doclet.ClassUse_Packages.that.use.0", "doclet.ClassUse_Packages.that.use.0",
getLink(new HtmlLinkInfo(configuration, getLink(new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.PLAIN, typeElement))); HtmlLinkInfo.Kind.PLAIN, typeElement)));
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(caption) .setCaption(caption)
.setHeader(getPackageTableHeader()) .setHeader(getPackageTableHeader())
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (PackageElement pkg : pkgSet) { for (PackageElement pkg : pkgSet) {
addPackageUse(pkg, table); addPackageUse(pkg, table);
} }
@ -270,10 +271,10 @@ public class ClassUseWriter extends SubWriterHolderWriter {
getLink(new HtmlLinkInfo(configuration, getLink(new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.PLAIN, typeElement))); HtmlLinkInfo.Kind.PLAIN, typeElement)));
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(caption) .setCaption(caption)
.setHeader(getPackageTableHeader()) .setHeader(getPackageTableHeader())
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (PackageElement pkg : pkgToPackageAnnotations) { for (PackageElement pkg : pkgToPackageAnnotations) {
Content summary = new ContentBuilder(); Content summary = new ContentBuilder();
addSummaryComment(pkg, summary); addSummaryComment(pkg, summary);
@ -288,9 +289,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
* @param content the content to which the class elements will be added * @param content the content to which the class elements will be added
*/ */
protected void addClassList(Content content) { protected void addClassList(Content content) {
var ul = HtmlTree.UL(HtmlStyle.blockList); var ul = HtmlTree.UL(HtmlStyles.blockList);
for (PackageElement pkg : pkgSet) { for (PackageElement pkg : pkgSet) {
var section = HtmlTree.SECTION(HtmlStyle.detail) var section = HtmlTree.SECTION(HtmlStyles.detail)
.setId(htmlIds.forPackage(pkg)); .setId(htmlIds.forPackage(pkg));
Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1", Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1",
getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.PLAIN, getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.PLAIN,
@ -301,7 +302,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
addClassUse(pkg, section); addClassUse(pkg, section);
ul.add(HtmlTree.LI(section)); ul.add(HtmlTree.LI(section));
} }
var li = HtmlTree.SECTION(HtmlStyle.classUses, ul); var li = HtmlTree.SECTION(HtmlStyles.classUses, ul);
content.add(li); content.add(li);
} }
@ -422,11 +423,11 @@ public class ClassUseWriter extends SubWriterHolderWriter {
HtmlTree body = getBody(getWindowTitle(title)); HtmlTree body = getBody(getWindowTitle(title));
ContentBuilder headingContent = new ContentBuilder(); ContentBuilder headingContent = new ContentBuilder();
headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype)); headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
headingContent.add(new HtmlTree(TagName.BR)); headingContent.add(new HtmlTree(HtmlTag.BR));
headingContent.add(clname); headingContent.add(clname);
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent); HtmlStyles.title, headingContent);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
bodyContents.setHeader(getHeader(PageMode.USE, typeElement)).addMainContent(div); bodyContents.setHeader(getHeader(PageMode.USE, typeElement)).addMainContent(div);
return body; return body;
} }

View File

@ -45,12 +45,7 @@ import com.sun.source.doctree.DeprecatedTree;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils; import jdk.javadoc.internal.doclets.toolkit.CommentUtils;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.PropertyUtils; import jdk.javadoc.internal.doclets.toolkit.PropertyUtils;
@ -58,6 +53,12 @@ import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate the Class Information Page. * Generate the Class Information Page.
@ -154,7 +155,7 @@ public class ClassWriter extends SubWriterHolderWriter {
* @param target the content to which the documentation will be added * @param target the content to which the documentation will be added
*/ */
protected void buildClassInfo(Content target) { protected void buildClassInfo(Content target) {
Content c = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content c = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildParamInfo(c); buildParamInfo(c);
buildSuperInterfacesInfo(c); buildSuperInterfacesInfo(c);
buildImplementedInterfacesInfo(c); buildImplementedInterfacesInfo(c);
@ -430,12 +431,12 @@ public class ClassWriter extends SubWriterHolderWriter {
protected Content getHeader(String header) { protected Content getHeader(String header) {
HtmlTree body = getBody(getWindowTitle(utils.getSimpleName(typeElement))); HtmlTree body = getBody(getWindowTitle(utils.getSimpleName(typeElement)));
var div = HtmlTree.DIV(HtmlStyle.header); var div = HtmlTree.DIV(HtmlStyles.header);
HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration, HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement) HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement)
.linkToSelf(false); // Let's not link to ourselves in the header .linkToSelf(false); // Let's not link to ourselves in the header
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, Text.of(header)); HtmlStyles.title, Text.of(header));
heading.add(getTypeParameterLinks(linkInfo)); heading.add(getTypeParameterLinks(linkInfo));
div.add(heading); div.add(heading);
bodyContents.setHeader(getHeader(PageMode.CLASS, typeElement)) bodyContents.setHeader(getHeader(PageMode.CLASS, typeElement))
@ -463,7 +464,7 @@ public class ClassWriter extends SubWriterHolderWriter {
} }
protected Content getClassInfo(Content classInfo) { protected Content getClassInfo(Content classInfo) {
return getMember(HtmlIds.CLASS_DESCRIPTION, HtmlStyle.classDescription, classInfo); return getMember(HtmlIds.CLASS_DESCRIPTION, HtmlStyles.classDescription, classInfo);
} }
@Override @Override
@ -472,7 +473,7 @@ public class ClassWriter extends SubWriterHolderWriter {
} }
protected void addClassSignature(Content classInfo) { protected void addClassSignature(Content classInfo) {
classInfo.add(new HtmlTree(TagName.HR)); classInfo.add(new HtmlTree(HtmlTag.HR));
classInfo.add(new Signatures.TypeSignature(typeElement, this) classInfo.add(new Signatures.TypeSignature(typeElement, this)
.toContent()); .toContent());
} }
@ -514,7 +515,7 @@ public class ClassWriter extends SubWriterHolderWriter {
HtmlTree classTree = null; HtmlTree classTree = null;
do { do {
sup = utils.getFirstVisibleSuperClass(type); sup = utils.getFirstVisibleSuperClass(type);
var entry = HtmlTree.DIV(HtmlStyle.inheritance, getClassHelperContent(type)); var entry = HtmlTree.DIV(HtmlStyles.inheritance, getClassHelperContent(type));
if (classTree != null) if (classTree != null)
entry.add(classTree); entry.add(classTree);
classTree = entry; classTree = entry;
@ -564,7 +565,7 @@ public class ClassWriter extends SubWriterHolderWriter {
var t = configuration.tagletManager.getTaglet(DocTree.Kind.PARAM); var t = configuration.tagletManager.getTaglet(DocTree.Kind.PARAM);
Content paramInfo = t.getAllBlockTagOutput(typeElement, getTagletWriterInstance(false)); Content paramInfo = t.getAllBlockTagOutput(typeElement, getTagletWriterInstance(false));
if (!paramInfo.isEmpty()) { if (!paramInfo.isEmpty()) {
target.add(HtmlTree.DL(HtmlStyle.notes, paramInfo)); target.add(HtmlTree.DL(HtmlStyles.notes, paramInfo));
} }
} }
} }
@ -578,7 +579,7 @@ public class ClassWriter extends SubWriterHolderWriter {
} }
Set<TypeElement> subclasses = classTree.hierarchy(typeElement).subtypes(typeElement); Set<TypeElement> subclasses = classTree.hierarchy(typeElement).subtypes(typeElement);
if (!subclasses.isEmpty()) { if (!subclasses.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.subclassesLabel)); dl.add(HtmlTree.DT(contents.subclassesLabel));
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.PLAIN, subclasses))); dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.PLAIN, subclasses)));
target.add(dl); target.add(dl);
@ -590,7 +591,7 @@ public class ClassWriter extends SubWriterHolderWriter {
if (utils.isPlainInterface(typeElement)) { if (utils.isPlainInterface(typeElement)) {
Set<TypeElement> subInterfaces = classTree.hierarchy(typeElement).allSubtypes(typeElement); Set<TypeElement> subInterfaces = classTree.hierarchy(typeElement).allSubtypes(typeElement);
if (!subInterfaces.isEmpty()) { if (!subInterfaces.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.subinterfacesLabel)); dl.add(HtmlTree.DT(contents.subinterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, subInterfaces))); dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, subInterfaces)));
target.add(dl); target.add(dl);
@ -609,7 +610,7 @@ public class ClassWriter extends SubWriterHolderWriter {
} }
Set<TypeElement> implcl = classTree.implementingClasses(typeElement); Set<TypeElement> implcl = classTree.implementingClasses(typeElement);
if (!implcl.isEmpty()) { if (!implcl.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.implementingClassesLabel)); dl.add(HtmlTree.DT(contents.implementingClassesLabel));
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.PLAIN, implcl))); dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.PLAIN, implcl)));
target.add(dl); target.add(dl);
@ -620,7 +621,7 @@ public class ClassWriter extends SubWriterHolderWriter {
SortedSet<TypeMirror> interfaces = new TreeSet<>(comparators.typeMirrorClassUseComparator()); SortedSet<TypeMirror> interfaces = new TreeSet<>(comparators.typeMirrorClassUseComparator());
interfaces.addAll(utils.getAllInterfaces(typeElement)); interfaces.addAll(utils.getAllInterfaces(typeElement));
if (utils.isClass(typeElement) && !interfaces.isEmpty()) { if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.allImplementedInterfacesLabel)); dl.add(HtmlTree.DT(contents.allImplementedInterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, interfaces))); dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, interfaces)));
target.add(dl); target.add(dl);
@ -633,7 +634,7 @@ public class ClassWriter extends SubWriterHolderWriter {
interfaces.addAll(utils.getAllInterfaces(typeElement)); interfaces.addAll(utils.getAllInterfaces(typeElement));
if (utils.isPlainInterface(typeElement) && !interfaces.isEmpty()) { if (utils.isPlainInterface(typeElement) && !interfaces.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.allSuperinterfacesLabel)); dl.add(HtmlTree.DT(contents.allSuperinterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, interfaces))); dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS, interfaces)));
target.add(dl); target.add(dl);
@ -647,7 +648,7 @@ public class ClassWriter extends SubWriterHolderWriter {
new SimpleElementVisitor8<Void, Void>() { new SimpleElementVisitor8<Void, Void>() {
@Override @Override
public Void visitType(TypeElement e, Void p) { public Void visitType(TypeElement e, Void p) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(utils.isPlainInterface(e) dl.add(HtmlTree.DT(utils.isPlainInterface(e)
? contents.enclosingInterfaceLabel ? contents.enclosingInterfaceLabel
: contents.enclosingClassLabel)); : contents.enclosingClassLabel));
@ -660,9 +661,9 @@ public class ClassWriter extends SubWriterHolderWriter {
protected void addFunctionalInterfaceInfo (Content target) { protected void addFunctionalInterfaceInfo (Content target) {
if (utils.isFunctionalInterface(typeElement)) { if (utils.isFunctionalInterface(typeElement)) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(HtmlTree.DT(contents.functionalInterface)); dl.add(HtmlTree.DT(contents.functionalInterface));
var dd = new HtmlTree(TagName.DD); var dd = new HtmlTree(HtmlTag.DD);
dd.add(contents.functionalInterfaceMessage); dd.add(contents.functionalInterfaceMessage);
dl.add(dd); dl.add(dd);
target.add(dl); target.add(dl);
@ -672,8 +673,8 @@ public class ClassWriter extends SubWriterHolderWriter {
protected void addClassDeprecationInfo(Content classInfo) { protected void addClassDeprecationInfo(Content classInfo) {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(typeElement); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(typeElement);
if (utils.isDeprecated(typeElement)) { if (utils.isDeprecated(typeElement)) {
var deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(typeElement)); var deprLabel = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(typeElement));
var div = HtmlTree.DIV(HtmlStyle.deprecationBlock, deprLabel); var div = HtmlTree.DIV(HtmlStyles.deprecationBlock, deprLabel);
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
CommentHelper ch = utils.getCommentHelper(typeElement); CommentHelper ch = utils.getCommentHelper(typeElement);
DocTree dt = deprs.get(0); DocTree dt = deprs.get(0);
@ -726,7 +727,7 @@ public class ClassWriter extends SubWriterHolderWriter {
} }
protected Content getMemberDetails(Content content) { protected Content getMemberDetails(Content content) {
var section = HtmlTree.SECTION(HtmlStyle.details, content); var section = HtmlTree.SECTION(HtmlStyles.details, content);
// The following id is required by the Navigation bar // The following id is required by the Navigation bar
if (utils.isAnnotationInterface(typeElement)) { if (utils.isAnnotationInterface(typeElement)) {
section.setId(HtmlIds.ANNOTATION_TYPE_ELEMENT_DETAIL); section.setId(HtmlIds.ANNOTATION_TYPE_ELEMENT_DETAIL);

View File

@ -39,20 +39,21 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
@ -328,14 +329,14 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter {
bodyContents.setHeader(getHeader(PageMode.CONSTANT_VALUES)); bodyContents.setHeader(getHeader(PageMode.CONSTANT_VALUES));
Content titleContent = contents.constantsSummaryTitle; Content titleContent = contents.constantsSummaryTitle;
var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent); HtmlStyles.title, titleContent);
var div = HtmlTree.DIV(HtmlStyle.header, pHeading); var div = HtmlTree.DIV(HtmlStyles.header, pHeading);
bodyContents.addMainContent(div); bodyContents.addMainContent(div);
return body; return body;
} }
Content getContentsHeader() { Content getContentsHeader() {
return HtmlTree.UL(HtmlStyle.contentsList); return HtmlTree.UL(HtmlStyles.contentsList);
} }
void addLinkToTableOfContents(String abbrevPackageName) { void addLinkToTableOfContents(String abbrevPackageName) {
@ -361,14 +362,14 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter {
var heading = HtmlTree.HEADING_TITLE( var heading = HtmlTree.HEADING_TITLE(
Headings.ConstantsSummary.PACKAGE_HEADING, Headings.ConstantsSummary.PACKAGE_HEADING,
headingContent); headingContent);
summarySection = HtmlTree.SECTION(HtmlStyle.constantsSummary, heading) summarySection = HtmlTree.SECTION(HtmlStyles.constantsSummary, heading)
.setId(anchorName); .setId(anchorName);
toContent.add(summarySection); toContent.add(summarySection);
} }
Content getClassConstantHeader() { Content getClassConstantHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
void addClassConstant(Content fromClassConstant) { void addClassConstant(Content fromClassConstant) {
@ -394,10 +395,10 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter {
} }
caption.add(classLink); caption.add(classLink);
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(caption) .setCaption(caption)
.setHeader(constantsTableHeader) .setHeader(constantsTableHeader)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast);
for (VariableElement field : fields) { for (VariableElement field : fields) {
table.addRow(getTypeColumn(field), getNameColumn(field), getValue(field)); table.addRow(getTypeColumn(field), getNameColumn(field), getValue(field));
@ -413,7 +414,7 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter {
*/ */
private Content getTypeColumn(VariableElement member) { private Content getTypeColumn(VariableElement member) {
Content typeContent = new ContentBuilder(); Content typeContent = new ContentBuilder();
var code = new HtmlTree(TagName.CODE) var code = new HtmlTree(HtmlTag.CODE)
.setId(htmlIds.forMember(currentTypeElement, member)); .setId(htmlIds.forMember(currentTypeElement, member));
for (Modifier mod : member.getModifiers()) { for (Modifier mod : member.getModifiers()) {
code.add(Text.of(mod.toString())) code.add(Text.of(mod.toString()))

View File

@ -33,15 +33,16 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement; import javax.lang.model.element.TypeParameterElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
@ -111,7 +112,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
for (Element constructor : constructors) { for (Element constructor : constructors) {
currentConstructor = (ExecutableElement)constructor; currentConstructor = (ExecutableElement)constructor;
Content constructorContent = getConstructorHeaderContent(currentConstructor); Content constructorContent = getConstructorHeaderContent(currentConstructor);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildSignature(div); buildSignature(div);
buildDeprecationInfo(div); buildDeprecationInfo(div);
buildPreviewInfo(div); buildPreviewInfo(div);
@ -193,7 +194,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.constructorSummary, writer.addSummary(HtmlStyles.constructorSummary,
HtmlIds.CONSTRUCTOR_SUMMARY, summariesList, content); HtmlIds.CONSTRUCTOR_SUMMARY, summariesList, content);
} }
@ -216,7 +217,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
heading.setId(anchors.getLast()); heading.setId(anchors.getLast());
} }
content.add(heading); content.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, content) return HtmlTree.SECTION(HtmlStyles.detail, content)
.setId(anchors.getFirst()); .setId(anchors.getFirst());
} }
@ -247,7 +248,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
protected Content getConstructorDetails(Content memberDetailsHeader, Content memberDetails) { protected Content getConstructorDetails(Content memberDetailsHeader, Content memberDetails) {
return writer.getDetailsListItem( return writer.getDetailsListItem(
HtmlTree.SECTION(HtmlStyle.constructorDetails) HtmlTree.SECTION(HtmlStyles.constructorDetails)
.setId(HtmlIds.CONSTRUCTOR_DETAIL) .setId(HtmlIds.CONSTRUCTOR_DETAIL)
.add(memberDetailsHeader) .add(memberDetailsHeader)
.add(memberDetails)); .add(memberDetails));
@ -279,14 +280,14 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
List<HtmlStyle> bodyRowStyles; List<HtmlStyle> bodyRowStyles;
if (threeColumnSummary()) { if (threeColumnSummary()) {
bodyRowStyles = Arrays.asList(HtmlStyle.colFirst, HtmlStyle.colConstructorName, bodyRowStyles = Arrays.asList(HtmlStyles.colFirst, HtmlStyles.colConstructorName,
HtmlStyle.colLast); HtmlStyles.colLast);
} else { } else {
bodyRowStyles = Arrays.asList(HtmlStyle.colConstructorName, HtmlStyle.colLast); bodyRowStyles = Arrays.asList(HtmlStyles.colConstructorName, HtmlStyles.colLast);
} }
return new Table<Element>( return new Table<Element>(
HtmlStyle.summaryTable) HtmlStyles.summaryTable)
.setCaption(contents.constructors) .setCaption(contents.constructors)
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(bodyRowStyles); .setColumnStyles(bodyRowStyles);
@ -299,7 +300,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
@Override @Override
protected void addSummaryType(Element member, Content content) { protected void addSummaryType(Element member, Content content) {
if (threeColumnSummary()) { if (threeColumnSummary()) {
var code = new HtmlTree(TagName.CODE); var code = new HtmlTree(HtmlTag.CODE);
if (utils.isProtected(member)) { if (utils.isProtected(member)) {
code.add("protected "); code.add("protected ");
} else if (utils.isPrivate(member)) { } else if (utils.isPrivate(member)) {

View File

@ -31,11 +31,12 @@ import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.Text;
/** /**

View File

@ -32,11 +32,13 @@ import javax.lang.model.element.Element;
import com.sun.source.doctree.DeprecatedTree; import com.sun.source.doctree.DeprecatedTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate File to list all the deprecated classes and class members with the * Generate File to list all the deprecated classes and class members with the
@ -79,7 +81,7 @@ public class DeprecatedListWriter extends SummaryListWriter<DeprecatedAPIListBui
protected void addContentSelectors(Content target) { protected void addContentSelectors(Content target) {
List<String> releases = builder.releases; List<String> releases = builder.releases;
if (releases.size() > 1) { if (releases.size() > 1) {
Content tabs = HtmlTree.DIV(HtmlStyle.checkboxes, contents.getContent( Content tabs = HtmlTree.DIV(HtmlStyles.checkboxes, contents.getContent(
"doclet.Deprecated_API_Checkbox_Label")); "doclet.Deprecated_API_Checkbox_Label"));
// Table column ids are 1-based // Table column ids are 1-based
int index = 1; int index = 1;
@ -125,7 +127,7 @@ public class DeprecatedListWriter extends SummaryListWriter<DeprecatedAPIListBui
protected void addTableTabs(Table<Element> table, String headingKey) { protected void addTableTabs(Table<Element> table, String headingKey) {
List<String> releases = builder.releases; List<String> releases = builder.releases;
if (!releases.isEmpty()) { if (!releases.isEmpty()) {
table.setGridStyle(HtmlStyle.threeColumnReleaseSummary); table.setGridStyle(HtmlStyles.threeColumnReleaseSummary);
} }
if (releases.size() > 1) { if (releases.size() > 1) {
table.setDefaultTab(getTableCaption(headingKey)) table.setDefaultTab(getTableCaption(headingKey))
@ -170,7 +172,7 @@ public class DeprecatedListWriter extends SummaryListWriter<DeprecatedAPIListBui
if (releases.isEmpty()) { if (releases.isEmpty()) {
return super.getColumnStyles(); return super.getColumnStyles();
} }
return new HtmlStyle[]{ HtmlStyle.colSummaryItemName, HtmlStyle.colSecond, HtmlStyle.colLast }; return new HtmlStyle[]{ HtmlStyles.colSummaryItemName, HtmlStyles.colSecond, HtmlStyles.colLast };
} }
@Override @Override

View File

@ -25,12 +25,23 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import javax.lang.model.element.Element;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.tools.JavaFileManager.Location;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.EndElementTree; import com.sun.source.doctree.EndElementTree;
import com.sun.source.doctree.StartElementTree; import com.sun.source.doctree.StartElementTree;
import com.sun.source.util.DocTreeFactory; import com.sun.source.util.DocTreeFactory;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.toolkit.DocFileElement; import jdk.javadoc.internal.doclets.toolkit.DocFileElement;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@ -38,19 +49,9 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclint.HtmlTag; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlTag;
import javax.lang.model.element.Element; import jdk.javadoc.internal.html.HtmlTree;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.tools.JavaFileManager.Location;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
/** /**
* A class to handle any files, including HTML files, found in the {@code doc-files} * A class to handle any files, including HTML files, found in the {@code doc-files}
@ -249,7 +250,7 @@ public class DocFilesHandler {
switch (dt.getKind()) { switch (dt.getKind()) {
case START_ELEMENT: case START_ELEMENT:
StartElementTree startElem = (StartElementTree)dt; StartElementTree startElem = (StartElementTree)dt;
switch (HtmlTag.get(startElem.getName())) { switch (HtmlTag.of(startElem.getName())) {
case HEAD: case HEAD:
inHead = true; inHead = true;
break; break;
@ -267,7 +268,7 @@ public class DocFilesHandler {
break; break;
case END_ELEMENT: case END_ELEMENT:
EndElementTree endElem = (EndElementTree)dt; EndElementTree endElem = (EndElementTree)dt;
switch (HtmlTag.get(endElem.getName())) { switch (HtmlTag.of(endElem.getName())) {
case HEAD: case HEAD:
inHead = false; inHead = false;
break loop; break loop;

View File

@ -29,12 +29,13 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes enum constant documentation in HTML format. * Writes enum constant documentation in HTML format.
@ -75,7 +76,7 @@ public class EnumConstantWriter extends AbstractMemberWriter {
for (Element enumConstant : enumConstants) { for (Element enumConstant : enumConstants) {
currentElement = (VariableElement)enumConstant; currentElement = (VariableElement)enumConstant;
Content enumConstantContent = getEnumConstantsHeader(currentElement); Content enumConstantContent = getEnumConstantsHeader(currentElement);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildSignature(div); buildSignature(div);
buildDeprecationInfo(div); buildDeprecationInfo(div);
buildPreviewInfo(div); buildPreviewInfo(div);
@ -138,7 +139,7 @@ public class EnumConstantWriter extends AbstractMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.constantsSummary, writer.addSummary(HtmlStyles.constantsSummary,
HtmlIds.ENUM_CONSTANT_SUMMARY, summariesList, content); HtmlIds.ENUM_CONSTANT_SUMMARY, summariesList, content);
} }
@ -156,7 +157,7 @@ public class EnumConstantWriter extends AbstractMemberWriter {
var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING, var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
Text.of(name(enumConstant))); Text.of(name(enumConstant)));
enumConstantsContent.add(heading); enumConstantsContent.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, enumConstantsContent) return HtmlTree.SECTION(HtmlStyles.detail, enumConstantsContent)
.setId(htmlIds.forMember(enumConstant)); .setId(htmlIds.forMember(enumConstant));
} }
@ -186,7 +187,7 @@ public class EnumConstantWriter extends AbstractMemberWriter {
protected Content getEnumConstantsDetails(Content memberDetailsHeader, protected Content getEnumConstantsDetails(Content memberDetailsHeader,
Content content) { Content content) {
return writer.getDetailsListItem( return writer.getDetailsListItem(
HtmlTree.SECTION(HtmlStyle.constantDetails) HtmlTree.SECTION(HtmlStyles.constantDetails)
.setId(HtmlIds.ENUM_CONSTANT_DETAIL) .setId(HtmlIds.ENUM_CONSTANT_DETAIL)
.add(memberDetailsHeader) .add(memberDetailsHeader)
.add(content)); .add(content));
@ -206,10 +207,10 @@ public class EnumConstantWriter extends AbstractMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setCaption(contents.getContent("doclet.Enum_Constants")) .setCaption(contents.getContent("doclet.Enum_Constants"))
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
} }
@Override @Override
@ -220,7 +221,7 @@ public class EnumConstantWriter extends AbstractMemberWriter {
protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member, protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member,
Content content) { Content content) {
Content memberLink = writer.getDocLink(context, utils.getEnclosingTypeElement(member), member, Content memberLink = writer.getDocLink(context, utils.getEnclosingTypeElement(member), member,
name(member), HtmlStyle.memberNameLink); name(member), HtmlStyles.memberNameLink);
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);
content.add(code); content.add(code);
} }

View File

@ -49,15 +49,16 @@ import com.sun.source.util.TreePath;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.DocFileElement; import jdk.javadoc.internal.doclets.toolkit.DocFileElement;
import jdk.javadoc.internal.doclets.toolkit.OverviewElement; import jdk.javadoc.internal.doclets.toolkit.OverviewElement;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
@ -103,7 +104,7 @@ public class ExternalSpecsWriter extends HtmlDocletWriter {
addExternalSpecs(mainContent); addExternalSpecs(mainContent);
body.add(new BodyContents() body.add(new BodyContents()
.setHeader(getHeader(PageMode.EXTERNAL_SPECS)) .setHeader(getHeader(PageMode.EXTERNAL_SPECS))
.addMainContent(HtmlTree.DIV(HtmlStyle.header, .addMainContent(HtmlTree.DIV(HtmlStyles.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.External_Specifications")))) contents.getContent("doclet.External_Specifications"))))
.addMainContent(mainContent) .addMainContent(mainContent)
@ -192,10 +193,10 @@ public class ExternalSpecsWriter extends HtmlDocletWriter {
} }
var hostNamesList = new ArrayList<>(hostNamesSet); var hostNamesList = new ArrayList<>(hostNamesSet);
var table = new Table<URI>(HtmlStyle.summaryTable) var table = new Table<URI>(HtmlStyles.summaryTable)
.setCaption(contents.externalSpecifications) .setCaption(contents.externalSpecifications)
.setHeader(new TableHeader(contents.specificationLabel, contents.referencedIn)) .setHeader(new TableHeader(contents.specificationLabel, contents.referencedIn))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast)
.setId(HtmlIds.EXTERNAL_SPECS); .setId(HtmlIds.EXTERNAL_SPECS);
if ((hostNamesList.size() + (noHost ? 1 : 0)) > 1) { if ((hostNamesList.size() + (noHost ? 1 : 0)) > 1) {
for (var host : hostNamesList) { for (var host : hostNamesList) {
@ -211,7 +212,7 @@ public class ExternalSpecsWriter extends HtmlDocletWriter {
for (List<IndexItem> searchIndexItems : searchIndexMap.values()) { for (List<IndexItem> searchIndexItems : searchIndexMap.values()) {
IndexItem ii = searchIndexItems.get(0); IndexItem ii = searchIndexItems.get(0);
Content specName = createSpecLink(ii); Content specName = createSpecLink(ii);
Content referencesList = HtmlTree.UL(HtmlStyle.refList, searchIndexItems, Content referencesList = HtmlTree.UL(HtmlStyles.refList, searchIndexItems,
item -> HtmlTree.LI(createLink(item))); item -> HtmlTree.LI(createLink(item)));
Content references = searchIndexItems.size() < USE_DETAILS_THRESHHOLD Content references = searchIndexItems.size() < USE_DETAILS_THRESHHOLD
? referencesList ? referencesList

View File

@ -32,13 +32,15 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes field documentation in HTML format. * Writes field documentation in HTML format.
@ -85,7 +87,7 @@ public class FieldWriter extends AbstractMemberWriter {
for (Element element : fields) { for (Element element : fields) {
currentElement = (VariableElement)element; currentElement = (VariableElement)element;
Content fieldContent = getFieldHeaderContent(currentElement); Content fieldContent = getFieldHeaderContent(currentElement);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildSignature(div); buildSignature(div);
buildDeprecationInfo(div); buildDeprecationInfo(div);
buildPreviewInfo(div); buildPreviewInfo(div);
@ -147,7 +149,7 @@ public class FieldWriter extends AbstractMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.fieldSummary, writer.addSummary(HtmlStyles.fieldSummary,
HtmlIds.FIELD_SUMMARY, summariesList, content); HtmlIds.FIELD_SUMMARY, summariesList, content);
} }
@ -165,7 +167,7 @@ public class FieldWriter extends AbstractMemberWriter {
var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING, var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
Text.of(name(field))); Text.of(name(field)));
content.add(heading); content.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, content) return HtmlTree.SECTION(HtmlStyles.detail, content)
.setId(htmlIds.forMember(field)); .setId(htmlIds.forMember(field));
} }
@ -196,7 +198,7 @@ public class FieldWriter extends AbstractMemberWriter {
protected Content getFieldDetails(Content memberDetailsHeaderContent, Content memberContent) { protected Content getFieldDetails(Content memberDetailsHeaderContent, Content memberContent) {
return writer.getDetailsListItem( return writer.getDetailsListItem(
HtmlTree.SECTION(HtmlStyle.fieldDetails) HtmlTree.SECTION(HtmlStyles.fieldDetails)
.setId(HtmlIds.FIELD_DETAIL) .setId(HtmlIds.FIELD_DETAIL)
.add(memberDetailsHeaderContent) .add(memberDetailsHeaderContent)
.add(memberContent)); .add(memberContent));
@ -217,10 +219,10 @@ public class FieldWriter extends AbstractMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyle.colFirst, HtmlStyle.colSecond, List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyles.colFirst, HtmlStyles.colSecond,
HtmlStyle.colLast); HtmlStyles.colLast);
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setCaption(contents.fields) .setCaption(contents.fields)
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(bodyRowStyles); .setColumnStyles(bodyRowStyles);
@ -252,7 +254,7 @@ public class FieldWriter extends AbstractMemberWriter {
protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member, protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member,
Content content) { Content content) {
Content memberLink = writer.getDocLink(context, typeElement , member, name(member), Content memberLink = writer.getDocLink(context, typeElement , member, name(member),
HtmlStyle.memberNameLink); HtmlStyles.memberNameLink);
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);
content.add(code); content.add(code);
} }

View File

@ -25,7 +25,7 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName; import jdk.javadoc.internal.html.HtmlTag;
/** /**
* Aliases for HTML heading tags (H1..H6) for different kinds of pages. * Aliases for HTML heading tags (H1..H6) for different kinds of pages.
@ -34,25 +34,25 @@ class Headings {
/** /**
* Standard top-level heading for the page title for all pages. * Standard top-level heading for the page title for all pages.
*/ */
static final TagName PAGE_TITLE_HEADING = TagName.H1; static final HtmlTag PAGE_TITLE_HEADING = HtmlTag.H1;
/** /**
* Standard second-level heading for sundry pages that do * Standard second-level heading for sundry pages that do
* not have their own page group. * not have their own page group.
*/ */
static final TagName CONTENT_HEADING = TagName.H2; static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
/** /**
* Standard third-level heading for sundry pages that do * Standard third-level heading for sundry pages that do
* not have their own page group. * not have their own page group.
*/ */
static final TagName SUB_HEADING = TagName.H3; static final HtmlTag SUB_HEADING = HtmlTag.H3;
/** /**
* Headings for the page for a module declaration. * Headings for the page for a module declaration.
*/ */
static class ModuleDeclaration { static class ModuleDeclaration {
static final TagName SUMMARY_HEADING = TagName.H2; static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
} }
/** /**
@ -64,31 +64,31 @@ class Headings {
* Heading for the different summary lists: * Heading for the different summary lists:
* Field Summary, Constructor Summary, Method Summary, etc. * Field Summary, Constructor Summary, Method Summary, etc.
*/ */
static final TagName SUMMARY_HEADING = TagName.H2; static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
/** /**
* Subheading within a summary for the inherited elements: * Subheading within a summary for the inherited elements:
* inherited methods, etc * inherited methods, etc
*/ */
static final TagName INHERITED_SUMMARY_HEADING = TagName.H3; static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
/** /**
* Heading for the different detail lists: * Heading for the different detail lists:
* Field Details, Constructor Details, Method Details, etc. * Field Details, Constructor Details, Method Details, etc.
*/ */
static final TagName DETAILS_HEADING = TagName.H2; static final HtmlTag DETAILS_HEADING = HtmlTag.H2;
/** /**
* Subheading with a Details list for an individual element. * Subheading with a Details list for an individual element.
*/ */
static final TagName MEMBER_HEADING = TagName.H3; static final HtmlTag MEMBER_HEADING = HtmlTag.H3;
} }
/** /**
* Headings for the Constants Summary page. * Headings for the Constants Summary page.
*/ */
static class ConstantsSummary { static class ConstantsSummary {
static final TagName PACKAGE_HEADING = TagName.H2; static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
} }
/** /**
@ -98,28 +98,28 @@ class Headings {
/** /**
* Heading for the package name, preceding a list of types. * Heading for the package name, preceding a list of types.
*/ */
static final TagName PACKAGE_HEADING = TagName.H2; static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
/** /**
* Heading for a type name within a package. * Heading for a type name within a package.
*/ */
static final TagName CLASS_HEADING = TagName.H3; static final HtmlTag CLASS_HEADING = HtmlTag.H3;
/** /**
* Subheading for info within a type. * Subheading for info within a type.
*/ */
static final TagName CLASS_SUBHEADING = TagName.H4; static final HtmlTag CLASS_SUBHEADING = HtmlTag.H4;
/** /**
* Heading for an individual member element within a type. * Heading for an individual member element within a type.
*/ */
static final TagName MEMBER_HEADING = TagName.H5; static final HtmlTag MEMBER_HEADING = HtmlTag.H5;
} }
/** /**
* Headings for a type Use page. * Headings for a type Use page.
*/ */
static class TypeUse { static class TypeUse {
static final TagName SUMMARY_HEADING = TagName.H2; static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
} }
} }

View File

@ -27,17 +27,18 @@ package jdk.javadoc.internal.doclets.formats.html;
import java.util.List; import java.util.List;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
@ -103,13 +104,13 @@ public class HelpWriter extends HtmlDocletWriter {
var mainHeading = getContent("doclet.help.main_heading"); var mainHeading = getContent("doclet.help.main_heading");
tableOfContents.addLink(HtmlIds.TOP_OF_PAGE, mainHeading); tableOfContents.addLink(HtmlIds.TOP_OF_PAGE, mainHeading);
tableOfContents.pushNestedList(); tableOfContents.pushNestedList();
content.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, mainHeading)) content.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyles.title, mainHeading))
.add(new HtmlTree(TagName.HR)) .add(new HtmlTree(HtmlTag.HR))
.add(getNavigationSection()) .add(getNavigationSection())
.add(new HtmlTree(TagName.HR)) .add(new HtmlTree(HtmlTag.HR))
.add(getPageKindSection()) .add(getPageKindSection())
.add(new HtmlTree(TagName.HR)) .add(new HtmlTree(HtmlTag.HR))
.add(HtmlTree.SPAN(HtmlStyle.helpFootnote, .add(HtmlTree.SPAN(HtmlStyles.helpFootnote,
getContent("doclet.help.footnote"))); getContent("doclet.help.footnote")));
tableOfContents.popNestedList(); tableOfContents.popNestedList();
} }
@ -129,7 +130,7 @@ public class HelpWriter extends HtmlDocletWriter {
Content content = new ContentBuilder(); Content content = new ContentBuilder();
Content navHeading = contents.getContent("doclet.help.navigation.head"); Content navHeading = contents.getContent("doclet.help.navigation.head");
var navSection = HtmlTree.DIV(HtmlStyle.subTitle) var navSection = HtmlTree.DIV(HtmlStyles.subTitle)
.add(HtmlTree.HEADING(Headings.CONTENT_HEADING, navHeading).setId(HtmlIds.HELP_NAVIGATION)) .add(HtmlTree.HEADING(Headings.CONTENT_HEADING, navHeading).setId(HtmlIds.HELP_NAVIGATION))
.add(contents.getContent("doclet.help.navigation.intro", overviewLink)); .add(contents.getContent("doclet.help.navigation.intro", overviewLink));
if (options.createIndex()) { if (options.createIndex()) {
@ -153,7 +154,7 @@ public class HelpWriter extends HtmlDocletWriter {
if (options.createIndex()) { if (options.createIndex()) {
section = newHelpSection(getContent("doclet.help.search.head"), PageMode.SEARCH); section = newHelpSection(getContent("doclet.help.search.head"), PageMode.SEARCH);
var searchIntro = HtmlTree.P(getContent("doclet.help.search.intro")); var searchIntro = HtmlTree.P(getContent("doclet.help.search.intro"));
var searchExamples = HtmlTree.OL(HtmlStyle.tocList); var searchExamples = HtmlTree.OL(HtmlStyles.tocList);
for (String[] example : SEARCH_EXAMPLES) { for (String[] example : SEARCH_EXAMPLES) {
searchExamples.add(HtmlTree.LI( searchExamples.add(HtmlTree.LI(
getContent("doclet.help.search.example", getContent("doclet.help.search.example",
@ -190,7 +191,7 @@ public class HelpWriter extends HtmlDocletWriter {
*/ */
private Content getPageKindSection() { private Content getPageKindSection() {
Content pageKindsHeading = contents.getContent("doclet.help.page_kinds.head"); Content pageKindsHeading = contents.getContent("doclet.help.page_kinds.head");
var pageKindsSection = HtmlTree.DIV(HtmlStyle.subTitle) var pageKindsSection = HtmlTree.DIV(HtmlStyles.subTitle)
.add(HtmlTree.HEADING(Headings.CONTENT_HEADING, pageKindsHeading).setId(HtmlIds.HELP_PAGES)) .add(HtmlTree.HEADING(Headings.CONTENT_HEADING, pageKindsHeading).setId(HtmlIds.HELP_PAGES))
.add(contents.getContent("doclet.help.page_kinds.intro")); .add(contents.getContent("doclet.help.page_kinds.intro"));
@ -235,7 +236,7 @@ public class HelpWriter extends HtmlDocletWriter {
// Class/interface // Class/interface
Content notes = new ContentBuilder( Content notes = new ContentBuilder(
HtmlTree.SPAN(HtmlStyle.helpNote, getContent("doclet.help.class_interface.note")), HtmlTree.SPAN(HtmlStyles.helpNote, getContent("doclet.help.class_interface.note")),
Text.of(" "), Text.of(" "),
getContent("doclet.help.class_interface.anno"), getContent("doclet.help.class_interface.anno"),
Text.of(" "), Text.of(" "),
@ -254,7 +255,7 @@ public class HelpWriter extends HtmlDocletWriter {
getContent("doclet.help.class_interface.implementations"), getContent("doclet.help.class_interface.implementations"),
getContent("doclet.help.class_interface.declaration"), getContent("doclet.help.class_interface.declaration"),
getContent("doclet.help.class_interface.description"))) getContent("doclet.help.class_interface.description")))
.add(new HtmlTree(TagName.BR)) .add(new HtmlTree(HtmlTag.BR))
.add(newHelpSectionList( .add(newHelpSectionList(
contents.nestedClassSummary, contents.nestedClassSummary,
contents.enumConstantSummary, contents.enumConstantSummary,
@ -264,7 +265,7 @@ public class HelpWriter extends HtmlDocletWriter {
contents.methodSummary, contents.methodSummary,
contents.annotateTypeRequiredMemberSummaryLabel, contents.annotateTypeRequiredMemberSummaryLabel,
contents.annotateTypeOptionalMemberSummaryLabel)) contents.annotateTypeOptionalMemberSummaryLabel))
.add(new HtmlTree(TagName.BR)) .add(new HtmlTree(HtmlTag.BR))
.add(newHelpSectionList( .add(newHelpSectionList(
contents.enumConstantDetailLabel, contents.enumConstantDetailLabel,
contents.fieldDetailsLabel, contents.fieldDetailsLabel,
@ -412,7 +413,7 @@ public class HelpWriter extends HtmlDocletWriter {
private HtmlTree newHelpSection(Content headingContent, HtmlId id) { private HtmlTree newHelpSection(Content headingContent, HtmlId id) {
tableOfContents.addLink(id, headingContent); tableOfContents.addLink(id, headingContent);
return HtmlTree.SECTION(HtmlStyle.helpSection, return HtmlTree.SECTION(HtmlStyles.helpSection,
HtmlTree.HEADING(Headings.SUB_HEADING, headingContent)) HtmlTree.HEADING(Headings.SUB_HEADING, headingContent))
.setId(id); .setId(id);
} }
@ -422,7 +423,7 @@ public class HelpWriter extends HtmlDocletWriter {
} }
private HtmlTree newHelpSectionList(Content first, Content... rest) { private HtmlTree newHelpSectionList(Content first, Content... rest) {
var list = HtmlTree.UL(HtmlStyle.helpSectionList, HtmlTree.LI(first)); var list = HtmlTree.UL(HtmlStyles.helpSectionList, HtmlTree.LI(first));
List.of(rest).forEach(i -> list.add(HtmlTree.LI(i))); List.of(rest).forEach(i -> list.add(HtmlTree.LI(i)));
return list; return list;
} }

View File

@ -94,20 +94,10 @@ import jdk.internal.org.commonmark.renderer.html.HtmlNodeRendererContext;
import jdk.internal.org.commonmark.renderer.html.HtmlNodeRendererFactory; import jdk.internal.org.commonmark.renderer.html.HtmlNodeRendererFactory;
import jdk.internal.org.commonmark.renderer.html.HtmlRenderer; import jdk.internal.org.commonmark.renderer.html.HtmlRenderer;
import jdk.internal.org.commonmark.renderer.html.HtmlWriter; import jdk.internal.org.commonmark.renderer.html.HtmlWriter;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.Head; import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Links; import jdk.javadoc.internal.doclets.formats.html.markup.Links;
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.markup.TextBuilder;
import jdk.javadoc.internal.doclets.formats.html.taglets.Taglet; import jdk.javadoc.internal.doclets.formats.html.taglets.Taglet;
import jdk.javadoc.internal.doclets.formats.html.taglets.TagletWriter; import jdk.javadoc.internal.doclets.formats.html.taglets.TagletWriter;
import jdk.javadoc.internal.doclets.toolkit.DocFileElement; import jdk.javadoc.internal.doclets.toolkit.DocFileElement;
@ -126,7 +116,17 @@ import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.Utils.DeclarationPreviewLanguageFeatures; import jdk.javadoc.internal.doclets.toolkit.util.Utils.DeclarationPreviewLanguageFeatures;
import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag; import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag;
import jdk.javadoc.internal.doclets.toolkit.util.Utils.PreviewSummary; import jdk.javadoc.internal.doclets.toolkit.util.Utils.PreviewSummary;
import jdk.javadoc.internal.doclint.HtmlTag; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.RawHtml;
import jdk.javadoc.internal.html.Script;
import jdk.javadoc.internal.html.Text;
import jdk.javadoc.internal.html.TextBuilder;
import static com.sun.source.doctree.DocTree.Kind.COMMENT; import static com.sun.source.doctree.DocTree.Kind.COMMENT;
import static com.sun.source.doctree.DocTree.Kind.START_ELEMENT; import static com.sun.source.doctree.DocTree.Kind.START_ELEMENT;
@ -361,7 +361,7 @@ public abstract class HtmlDocletWriter {
if (options.noComment()) { if (options.noComment()) {
return; return;
} }
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
if (utils.isMethod(e)) { if (utils.isMethod(e)) {
addMethodInfo((ExecutableElement)e, dl); addMethodInfo((ExecutableElement)e, dl);
} }
@ -610,7 +610,7 @@ public abstract class HtmlDocletWriter {
var contents = cb.getContents(); var contents = cb.getContents();
if (!contents.isEmpty()) { if (!contents.isEmpty()) {
var first = contents.get(0); var first = contents.get(0);
if (first instanceof HtmlTree htmlTree && htmlTree.tagName.equals(TagName.H1)) { if (first instanceof HtmlTree htmlTree && htmlTree.tag.equals(HtmlTag.H1)) {
for (var c2 : htmlTree.getContents()) { for (var c2 : htmlTree.getContents()) {
if (c2 instanceof Text t) { if (c2 instanceof Text t) {
sb.append(t.toString()); sb.append(t.toString());
@ -685,8 +685,8 @@ public abstract class HtmlDocletWriter {
return (bottom == null || bottom.isEmpty()) return (bottom == null || bottom.isEmpty())
? null ? null
: HtmlTree.FOOTER() : HtmlTree.FOOTER()
.add(new HtmlTree(TagName.HR)) .add(new HtmlTree(HtmlTag.HR))
.add(HtmlTree.P(HtmlStyle.legalCopy, .add(HtmlTree.P(HtmlStyles.legalCopy,
HtmlTree.SMALL( HtmlTree.SMALL(
RawHtml.of(replaceDocRootDir(bottom))))); RawHtml.of(replaceDocRootDir(bottom)))));
} }
@ -1047,7 +1047,7 @@ public abstract class HtmlDocletWriter {
* @param content the content to which the link with be added * @param content the content to which the link with be added
*/ */
public void addPreQualifiedStrongClassLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Content content) { public void addPreQualifiedStrongClassLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Content content) {
addPreQualifiedClassLink(context, typeElement, HtmlStyle.typeNameLink, content); addPreQualifiedClassLink(context, typeElement, HtmlStyles.typeNameLink, content);
} }
/** /**
@ -1255,10 +1255,10 @@ public abstract class HtmlDocletWriter {
Content result = commentTagsToContent(element, tags, first, inSummary); Content result = commentTagsToContent(element, tags, first, inSummary);
if (!result.isEmpty()) { if (!result.isEmpty()) {
if (depr) { if (depr) {
div = HtmlTree.DIV(HtmlStyle.deprecationComment, result); div = HtmlTree.DIV(HtmlStyles.deprecationComment, result);
target.add(div); target.add(div);
} else { } else {
div = HtmlTree.DIV(HtmlStyle.block, result); div = HtmlTree.DIV(HtmlStyles.block, result);
target.add(div); target.add(div);
} }
} }
@ -1277,7 +1277,7 @@ public abstract class HtmlDocletWriter {
} }
if (name != null) { if (name != null) {
HtmlTag htmlTag = HtmlTag.get(name); HtmlTag htmlTag = HtmlTag.of(name);
if (htmlTag != null) { if (htmlTag != null) {
if (htmlTag.blockType != HtmlTag.BlockType.INLINE) { if (htmlTag.blockType != HtmlTag.BlockType.INLINE) {
return true; return true;
@ -1944,9 +1944,9 @@ public abstract class HtmlDocletWriter {
public Content invalidTagOutput(String summary, Optional<Content> detail) { public Content invalidTagOutput(String summary, Optional<Content> detail) {
messages.setContainsDiagnosticMarkers(); messages.setContainsDiagnosticMarkers();
if (detail.isEmpty() || detail.get().isEmpty()) { if (detail.isEmpty() || detail.get().isEmpty()) {
return HtmlTree.SPAN(HtmlStyle.invalidTag, Text.of(summary)); return HtmlTree.SPAN(HtmlStyles.invalidTag, Text.of(summary));
} }
return HtmlTree.DETAILS(HtmlStyle.invalidTag) return HtmlTree.DETAILS(HtmlStyles.invalidTag)
.add(HtmlTree.SUMMARY(Text.of(summary))) .add(HtmlTree.SUMMARY(Text.of(summary)))
.add(HtmlTree.PRE(detail.get())); .add(HtmlTree.PRE(detail.get()));
} }
@ -2405,7 +2405,7 @@ public abstract class HtmlDocletWriter {
* @return an HtmlTree for the BODY tag * @return an HtmlTree for the BODY tag
*/ */
public HtmlTree getBody(String title) { public HtmlTree getBody(String title) {
var body = new HtmlTree(TagName.BODY).setStyle(getBodyStyle()); var body = new HtmlTree(HtmlTag.BODY).setStyle(getBodyStyle());
this.winTitle = title; this.winTitle = title;
// Don't print windowtitle script for overview-frame, allclasses-frame // Don't print windowtitle script for overview-frame, allclasses-frame
@ -2423,7 +2423,7 @@ public abstract class HtmlDocletWriter {
.replaceAll("^(Module|Package|Class)$", "$1Declaration") .replaceAll("^(Module|Package|Class)$", "$1Declaration")
.replace("API", "Api"); .replace("API", "Api");
String page = kind.substring(0, 1).toLowerCase(Locale.US) + kind.substring(1) + "Page"; String page = kind.substring(0, 1).toLowerCase(Locale.US) + kind.substring(1) + "Page";
return HtmlStyle.valueOf(page); return HtmlStyles.valueOf(page);
} }
/** /**
@ -2473,16 +2473,16 @@ public abstract class HtmlDocletWriter {
public void addPreviewSummary(Element forWhat, Content target) { public void addPreviewSummary(Element forWhat, Content target) {
if (utils.isPreviewAPI(forWhat)) { if (utils.isPreviewAPI(forWhat)) {
var div = HtmlTree.DIV(HtmlStyle.block); var div = HtmlTree.DIV(HtmlStyles.block);
div.add(HtmlTree.SPAN(HtmlStyle.previewLabel, contents.previewPhrase)); div.add(HtmlTree.SPAN(HtmlStyles.previewLabel, contents.previewPhrase));
target.add(div); target.add(div);
} }
} }
public void addRestrictedSummary(Element forWhat, Content target) { public void addRestrictedSummary(Element forWhat, Content target) {
if (utils.isRestrictedAPI(forWhat)) { if (utils.isRestrictedAPI(forWhat)) {
var div = HtmlTree.DIV(HtmlStyle.block); var div = HtmlTree.DIV(HtmlStyles.block);
div.add(HtmlTree.SPAN(HtmlStyle.restrictedLabel, contents.restrictedPhrase)); div.add(HtmlTree.SPAN(HtmlStyles.restrictedLabel, contents.restrictedPhrase));
target.add(div); target.add(div);
} }
} }
@ -2490,7 +2490,7 @@ public abstract class HtmlDocletWriter {
public void addPreviewInfo(Element forWhat, Content target) { public void addPreviewInfo(Element forWhat, Content target) {
if (utils.isPreviewAPI(forWhat)) { if (utils.isPreviewAPI(forWhat)) {
//in Java platform: //in Java platform:
var previewDiv = HtmlTree.DIV(HtmlStyle.previewBlock); var previewDiv = HtmlTree.DIV(HtmlStyles.previewBlock);
previewDiv.setId(htmlIds.forPreviewSection(forWhat)); previewDiv.setId(htmlIds.forPreviewSection(forWhat));
String name = (switch (forWhat.getKind()) { String name = (switch (forWhat.getKind()) {
case PACKAGE, MODULE -> case PACKAGE, MODULE ->
@ -2506,14 +2506,14 @@ public abstract class HtmlDocletWriter {
: "doclet.ReflectivePreviewPlatformLeadingNote"; : "doclet.ReflectivePreviewPlatformLeadingNote";
Content leadingNote = Content leadingNote =
contents.getContent(leadingNoteKey, nameCode); contents.getContent(leadingNoteKey, nameCode);
previewDiv.add(HtmlTree.SPAN(HtmlStyle.previewLabel, previewDiv.add(HtmlTree.SPAN(HtmlStyles.previewLabel,
leadingNote)); leadingNote));
if (!isReflectivePreview) { if (!isReflectivePreview) {
Content note1 = contents.getContent("doclet.PreviewTrailingNote1", nameCode); Content note1 = contents.getContent("doclet.PreviewTrailingNote1", nameCode);
previewDiv.add(HtmlTree.DIV(HtmlStyle.previewComment, note1)); previewDiv.add(HtmlTree.DIV(HtmlStyles.previewComment, note1));
} }
Content note2 = contents.getContent("doclet.PreviewTrailingNote2", nameCode); Content note2 = contents.getContent("doclet.PreviewTrailingNote2", nameCode);
previewDiv.add(HtmlTree.DIV(HtmlStyle.previewComment, note2)); previewDiv.add(HtmlTree.DIV(HtmlStyles.previewComment, note2));
target.add(previewDiv); target.add(previewDiv);
} else if (forWhat.getKind().isClass() || forWhat.getKind().isInterface()) { } else if (forWhat.getKind().isClass() || forWhat.getKind().isInterface()) {
//in custom code: //in custom code:
@ -2521,12 +2521,12 @@ public abstract class HtmlDocletWriter {
if (!previewNotes.isEmpty()) { if (!previewNotes.isEmpty()) {
Name name = forWhat.getSimpleName(); Name name = forWhat.getSimpleName();
var nameCode = HtmlTree.CODE(Text.of(name)); var nameCode = HtmlTree.CODE(Text.of(name));
var previewDiv = HtmlTree.DIV(HtmlStyle.previewBlock); var previewDiv = HtmlTree.DIV(HtmlStyles.previewBlock);
previewDiv.setId(htmlIds.forPreviewSection(forWhat)); previewDiv.setId(htmlIds.forPreviewSection(forWhat));
Content leadingNote = contents.getContent("doclet.PreviewLeadingNote", nameCode); Content leadingNote = contents.getContent("doclet.PreviewLeadingNote", nameCode);
previewDiv.add(HtmlTree.SPAN(HtmlStyle.previewLabel, previewDiv.add(HtmlTree.SPAN(HtmlStyles.previewLabel,
leadingNote)); leadingNote));
var ul = HtmlTree.UL(HtmlStyle.previewComment); var ul = HtmlTree.UL(HtmlStyles.previewComment);
for (Content note : previewNotes) { for (Content note : previewNotes) {
ul.add(HtmlTree.LI(note)); ul.add(HtmlTree.LI(note));
} }
@ -2534,11 +2534,11 @@ public abstract class HtmlDocletWriter {
Content note1 = Content note1 =
contents.getContent("doclet.PreviewTrailingNote1", contents.getContent("doclet.PreviewTrailingNote1",
nameCode); nameCode);
previewDiv.add(HtmlTree.DIV(HtmlStyle.previewComment, note1)); previewDiv.add(HtmlTree.DIV(HtmlStyles.previewComment, note1));
Content note2 = Content note2 =
contents.getContent("doclet.PreviewTrailingNote2", contents.getContent("doclet.PreviewTrailingNote2",
name); name);
previewDiv.add(HtmlTree.DIV(HtmlStyle.previewComment, note2)); previewDiv.add(HtmlTree.DIV(HtmlStyles.previewComment, note2));
target.add(previewDiv); target.add(previewDiv);
} }
} }
@ -2601,7 +2601,7 @@ public abstract class HtmlDocletWriter {
}); });
return contents.getContent(key, return contents.getContent(key,
HtmlTree.CODE(Text.of(className)), HtmlTree.CODE(Text.of(className)),
new HtmlTree(TagName.EM).add(featureName), new HtmlTree(HtmlTag.EM).add(featureName),
featureCodes); featureCodes);
} }
@ -2640,19 +2640,19 @@ public abstract class HtmlDocletWriter {
public void addRestrictedInfo(ExecutableElement forWhat, Content target) { public void addRestrictedInfo(ExecutableElement forWhat, Content target) {
if (utils.isRestrictedAPI(forWhat)) { if (utils.isRestrictedAPI(forWhat)) {
//in Java platform: //in Java platform:
var restrictedDiv = HtmlTree.DIV(HtmlStyle.restrictedBlock); var restrictedDiv = HtmlTree.DIV(HtmlStyles.restrictedBlock);
restrictedDiv.setId(htmlIds.forRestrictedSection(forWhat)); restrictedDiv.setId(htmlIds.forRestrictedSection(forWhat));
String name = forWhat.getSimpleName().toString(); String name = forWhat.getSimpleName().toString();
var nameCode = HtmlTree.CODE(Text.of(name)); var nameCode = HtmlTree.CODE(Text.of(name));
String leadingNoteKey = "doclet.RestrictedLeadingNote"; String leadingNoteKey = "doclet.RestrictedLeadingNote";
Content leadingNote = Content leadingNote =
contents.getContent(leadingNoteKey, nameCode); contents.getContent(leadingNoteKey, nameCode);
restrictedDiv.add(HtmlTree.SPAN(HtmlStyle.restrictedLabel, restrictedDiv.add(HtmlTree.SPAN(HtmlStyles.restrictedLabel,
leadingNote)); leadingNote));
Content note1 = contents.getContent("doclet.RestrictedTrailingNote1", nameCode); Content note1 = contents.getContent("doclet.RestrictedTrailingNote1", nameCode);
restrictedDiv.add(HtmlTree.DIV(HtmlStyle.restrictedComment, note1)); restrictedDiv.add(HtmlTree.DIV(HtmlStyles.restrictedComment, note1));
Content note2 = contents.getContent("doclet.RestrictedTrailingNote2", nameCode); Content note2 = contents.getContent("doclet.RestrictedTrailingNote2", nameCode);
restrictedDiv.add(HtmlTree.DIV(HtmlStyle.restrictedComment, note2)); restrictedDiv.add(HtmlTree.DIV(HtmlStyles.restrictedComment, note2));
target.add(restrictedDiv); target.add(restrictedDiv);
} }
} }

View File

@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind; import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
@ -46,10 +47,10 @@ import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable; import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.SimpleTypeVisitor9; import javax.lang.model.util.SimpleTypeVisitor9;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.HtmlId;
/** /**
* Centralized constants and factory methods for HTML ids. * Centralized constants and factory methods for HTML ids.

View File

@ -30,11 +30,11 @@ import java.io.Writer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@ -42,6 +42,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* Extensions to {@code IndexBuilder} to fill in remaining fields * Extensions to {@code IndexBuilder} to fill in remaining fields

View File

@ -43,17 +43,18 @@ import javax.lang.model.type.TypeVariable;
import javax.lang.model.type.WildcardType; import javax.lang.model.type.WildcardType;
import javax.lang.model.util.SimpleTypeVisitor14; import javax.lang.model.util.SimpleTypeVisitor14;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag; import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* A factory that returns a link given the information about it. * A factory that returns a link given the information about it.
@ -377,14 +378,14 @@ public class HtmlLinkFactory {
} }
if (!vars.isEmpty()) { if (!vars.isEmpty()) {
if (linkInfo.addLineBreakOpportunitiesInTypeParameters()) { if (linkInfo.addLineBreakOpportunitiesInTypeParameters()) {
links.add(new HtmlTree(TagName.WBR)); links.add(new HtmlTree(HtmlTag.WBR));
} }
links.add("<"); links.add("<");
boolean many = false; boolean many = false;
for (TypeMirror t : vars) { for (TypeMirror t : vars) {
if (many) { if (many) {
links.add(","); links.add(",");
links.add(new HtmlTree(TagName.WBR)); links.add(new HtmlTree(HtmlTag.WBR));
if (linkInfo.addLineBreaksInTypeParameters()) { if (linkInfo.addLineBreaksInTypeParameters()) {
links.add(Text.NL); links.add(Text.NL);
} }

View File

@ -31,11 +31,13 @@ import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType; import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.Text;
/** /**

View File

@ -29,18 +29,18 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import jdk.javadoc.internal.doclets.formats.html.markup.Head; import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Script;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes a file that tries to redirect to an alternate page. * Writes a file that tries to redirect to an alternate page.
@ -92,7 +92,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
Script script = new Script("window.location.replace(") Script script = new Script("window.location.replace(")
.appendStringLiteral(targetPath, '\'') .appendStringLiteral(targetPath, '\'')
.append(")"); .append(")");
var metaRefresh = new HtmlTree(TagName.META) var metaRefresh = new HtmlTree(HtmlTag.META)
.put(HtmlAttr.HTTP_EQUIV, "Refresh") .put(HtmlAttr.HTTP_EQUIV, "Refresh")
.put(HtmlAttr.CONTENT, "0;" + targetPath); .put(HtmlAttr.CONTENT, "0;" + targetPath);
head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh)); head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh));
@ -103,7 +103,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, Text.of(targetPath)))); bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, Text.of(targetPath))));
var body = new HtmlTree(TagName.BODY).setStyle(HtmlStyle.indexRedirectPage); var body = new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.indexRedirectPage);
var main = HtmlTree.MAIN(bodyContent); var main = HtmlTree.MAIN(bodyContent);
body.add(main); body.add(main);

View File

@ -36,22 +36,21 @@ import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DeprecatedTree;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generator for either a single index or split index for all * Generator for either a single index or split index for all
@ -129,7 +128,7 @@ public class IndexWriter extends HtmlDocletWriter {
addLinksForIndexes(allFirstCharacters, mainContent); addLinksForIndexes(allFirstCharacters, mainContent);
body.add(new BodyContents() body.add(new BodyContents()
.setHeader(getHeader(PageMode.INDEX)) .setHeader(getHeader(PageMode.INDEX))
.addMainContent(HtmlTree.DIV(HtmlStyle.header, .addMainContent(HtmlTree.DIV(HtmlStyles.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.Index")))) contents.getContent("doclet.Index"))))
.addMainContent(mainContent) .addMainContent(mainContent)
@ -149,7 +148,7 @@ public class IndexWriter extends HtmlDocletWriter {
protected void addContents(char ch, SortedSet<IndexItem> items, Content content) { protected void addContents(char ch, SortedSet<IndexItem> items, Content content) {
addHeading(ch, content); addHeading(ch, content);
var dl = HtmlTree.DL(HtmlStyle.index); var dl = HtmlTree.DL(HtmlStyles.index);
for (IndexItem item : items) { for (IndexItem item : items) {
addDescription(item, dl); addDescription(item, dl);
} }
@ -164,7 +163,7 @@ public class IndexWriter extends HtmlDocletWriter {
*/ */
protected void addHeading(char ch, Content content) { protected void addHeading(char ch, Content content) {
Content headContent = Text.of(String.valueOf(ch)); Content headContent = Text.of(String.valueOf(ch));
var heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, HtmlStyle.title, headContent) var heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, HtmlStyles.title, headContent)
.setId(HtmlIds.forIndexChar(ch)); .setId(HtmlIds.forIndexChar(ch));
content.add(heading); content.add(heading);
} }
@ -209,7 +208,7 @@ public class IndexWriter extends HtmlDocletWriter {
case CLASS, ENUM, RECORD, ANNOTATION_TYPE, INTERFACE -> { case CLASS, ENUM, RECORD, ANNOTATION_TYPE, INTERFACE -> {
dt = HtmlTree.DT(getLink(new HtmlLinkInfo(configuration, dt = HtmlTree.DT(getLink(new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL, (TypeElement) element).style(HtmlStyle.typeNameLink))); HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL, (TypeElement) element).style(HtmlStyles.typeNameLink)));
dt.add(" - "); dt.add(" - ");
addClassInfo((TypeElement) element, dt); addClassInfo((TypeElement) element, dt);
} }
@ -217,7 +216,7 @@ public class IndexWriter extends HtmlDocletWriter {
case CONSTRUCTOR, METHOD, FIELD, ENUM_CONSTANT -> { case CONSTRUCTOR, METHOD, FIELD, ENUM_CONSTANT -> {
TypeElement containingType = item.getContainingTypeElement(); TypeElement containingType = item.getContainingTypeElement();
dt = HtmlTree.DT(getDocLink(HtmlLinkInfo.Kind.PLAIN, containingType, element, dt = HtmlTree.DT(getDocLink(HtmlLinkInfo.Kind.PLAIN, containingType, element,
label, HtmlStyle.memberNameLink)); label, HtmlStyles.memberNameLink));
dt.add(" - "); dt.add(" - ");
addMemberDesc(element, containingType, dt); addMemberDesc(element, containingType, dt);
} }
@ -225,7 +224,7 @@ public class IndexWriter extends HtmlDocletWriter {
default -> throw new Error(); default -> throw new Error();
} }
target.add(dt); target.add(dt);
var dd = new HtmlTree(TagName.DD); var dd = new HtmlTree(HtmlTag.DD);
if (element.getKind() == ElementKind.MODULE || element.getKind() == ElementKind.PACKAGE) { if (element.getKind() == ElementKind.MODULE || element.getKind() == ElementKind.PACKAGE) {
addSummaryComment(element, dd); addSummaryComment(element, dd);
} else { } else {
@ -258,11 +257,11 @@ public class IndexWriter extends HtmlDocletWriter {
String itemPath = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/"; String itemPath = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/";
itemPath += item.getUrl(); itemPath += item.getUrl();
var labelLink = HtmlTree.A(itemPath, Text.of(item.getLabel())); var labelLink = HtmlTree.A(itemPath, Text.of(item.getLabel()));
var dt = HtmlTree.DT(labelLink.setStyle(HtmlStyle.searchTagLink)); var dt = HtmlTree.DT(labelLink.setStyle(HtmlStyles.searchTagLink));
dt.add(" - "); dt.add(" - ");
dt.add(contents.getContent("doclet.Search_tag_in", item.getHolder())); dt.add(contents.getContent("doclet.Search_tag_in", item.getHolder()));
target.add(dt); target.add(dt);
var dd = new HtmlTree(TagName.DD); var dd = new HtmlTree(HtmlTag.DD);
if (item.getDescription().isEmpty()) { if (item.getDescription().isEmpty()) {
dd.add(Entity.NO_BREAK_SPACE); dd.add(Entity.NO_BREAK_SPACE);
} else { } else {
@ -281,8 +280,8 @@ public class IndexWriter extends HtmlDocletWriter {
* @param content the content to which the comment will be added * @param content the content to which the comment will be added
*/ */
protected void addComment(Element element, Content content) { protected void addComment(Element element, Content content) {
var span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(element)); var span = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(element));
var div = HtmlTree.DIV(HtmlStyle.deprecationBlock); var div = HtmlTree.DIV(HtmlStyles.deprecationBlock);
if (utils.isDeprecated(element)) { if (utils.isDeprecated(element)) {
div.add(span); div.add(span);
var tags = utils.getDeprecatedTrees(element); var tags = utils.getDeprecatedTrees(element);
@ -349,7 +348,7 @@ public class IndexWriter extends HtmlDocletWriter {
content.add(Entity.NO_BREAK_SPACE); content.add(Entity.NO_BREAK_SPACE);
} }
content.add(new HtmlTree(TagName.BR)); content.add(new HtmlTree(HtmlTag.BR));
var pageLinks = Stream.of(IndexItem.Category.values()) var pageLinks = Stream.of(IndexItem.Category.values())
.flatMap(c -> mainIndex.getItems(c).stream()) .flatMap(c -> mainIndex.getItems(c).stream())
.filter(i -> !(i.isElementItem() || i.isTagItem())) .filter(i -> !(i.isElementItem() || i.isTagItem()))
@ -361,6 +360,6 @@ public class IndexWriter extends HtmlDocletWriter {
} }
private Content getVerticalSeparator() { private Content getVerticalSeparator() {
return HtmlTree.SPAN(HtmlStyle.verticalSeparator, Text.of("|")); return HtmlTree.SPAN(HtmlStyles.verticalSeparator, Text.of("|"));
} }
} }

View File

@ -25,7 +25,7 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.Comment; import jdk.javadoc.internal.html.Comment;
/** /**
* Marker comments to identify regions in the generated files. * Marker comments to identify regions in the generated files.

View File

@ -35,16 +35,16 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes method documentation in HTML format. * Writes method documentation in HTML format.
@ -107,7 +107,7 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
for (Element method : methods) { for (Element method : methods) {
currentMethod = (ExecutableElement)method; currentMethod = (ExecutableElement)method;
Content methodContent = getMethodHeader(currentMethod); Content methodContent = getMethodHeader(currentMethod);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildSignature(div); buildSignature(div);
buildDeprecationInfo(div); buildDeprecationInfo(div);
buildPreviewInfo(div); buildPreviewInfo(div);
@ -187,7 +187,7 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.methodSummary, writer.addSummary(HtmlStyles.methodSummary,
HtmlIds.METHOD_SUMMARY, summariesList, content); HtmlIds.METHOD_SUMMARY, summariesList, content);
} }
@ -209,7 +209,7 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
heading.setId(anchors.getLast()); heading.setId(anchors.getLast());
} }
content.add(heading); content.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, content) return HtmlTree.SECTION(HtmlStyles.detail, content)
.setId(anchors.getFirst()); .setId(anchors.getFirst());
} }
@ -251,13 +251,13 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
? utils.getSimpleName(holder) ? utils.getSimpleName(holder)
: utils.getFullyQualifiedName(holder)); : utils.getFullyQualifiedName(holder));
var codeLink = HtmlTree.CODE(link); var codeLink = HtmlTree.CODE(link);
var descriptionFromTypeLabel = HtmlTree.SPAN(HtmlStyle.descriptionFromTypeLabel, var descriptionFromTypeLabel = HtmlTree.SPAN(HtmlStyles.descriptionFromTypeLabel,
utils.isClass(holder) utils.isClass(holder)
? contents.descriptionFromClassLabel ? contents.descriptionFromClassLabel
: contents.descriptionFromInterfaceLabel); : contents.descriptionFromInterfaceLabel);
descriptionFromTypeLabel.add(Entity.NO_BREAK_SPACE); descriptionFromTypeLabel.add(Entity.NO_BREAK_SPACE);
descriptionFromTypeLabel.add(codeLink); descriptionFromTypeLabel.add(codeLink);
methodContent.add(HtmlTree.DIV(HtmlStyle.block, descriptionFromTypeLabel)); methodContent.add(HtmlTree.DIV(HtmlStyles.block, descriptionFromTypeLabel));
} }
writer.addInlineComment(method, methodContent); writer.addInlineComment(method, methodContent);
} }
@ -270,7 +270,7 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
protected Content getMethodDetails(Content methodDetailsHeader, Content methodDetails) { protected Content getMethodDetails(Content methodDetailsHeader, Content methodDetails) {
Content c = new ContentBuilder(methodDetailsHeader, methodDetails); Content c = new ContentBuilder(methodDetailsHeader, methodDetails);
return getMember(HtmlTree.SECTION(HtmlStyle.methodDetails, c) return getMember(HtmlTree.SECTION(HtmlStyles.methodDetails, c)
.setId(HtmlIds.METHOD_DETAIL)); .setId(HtmlIds.METHOD_DETAIL));
} }
@ -289,9 +289,9 @@ public class MethodWriter extends AbstractExecutableMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast)
.setId(HtmlIds.METHOD_SUMMARY_TABLE) .setId(HtmlIds.METHOD_SUMMARY_TABLE)
.setDefaultTab(contents.getContent("doclet.All_Methods")) .setDefaultTab(contents.getContent("doclet.All_Methods"))
.addTab(contents.getContent("doclet.Static_Methods"), utils::isStatic) .addTab(contents.getContent("doclet.Static_Methods"), utils::isStatic)

View File

@ -31,10 +31,11 @@ import java.util.SortedSet;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate the module index page "index.html". * Generate the module index page "index.html".
@ -78,9 +79,9 @@ public class ModuleIndexWriter extends AbstractOverviewIndexWriter {
if (!groupModuleMap.keySet().isEmpty()) { if (!groupModuleMap.keySet().isEmpty()) {
TableHeader tableHeader = new TableHeader(contents.moduleLabel, contents.descriptionLabel); TableHeader tableHeader = new TableHeader(contents.moduleLabel, contents.descriptionLabel);
var table = new Table<ModuleElement>(HtmlStyle.summaryTable) var table = new Table<ModuleElement>(HtmlStyles.summaryTable)
.setHeader(tableHeader) .setHeader(tableHeader)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast)
.setId(HtmlIds.ALL_MODULES_TABLE) .setId(HtmlIds.ALL_MODULES_TABLE)
.setDefaultTab(contents.getContent("doclet.All_Modules")); .setDefaultTab(contents.getContent("doclet.All_Modules"));

View File

@ -41,18 +41,21 @@ import javax.lang.model.util.ElementFilter;
import com.sun.source.doctree.DeprecatedTree; import com.sun.source.doctree.DeprecatedTree;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.DocletEnvironment.ModuleMode; import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Class to generate file for each module contents in the right-hand frame. This will list all the * Class to generate file for each module contents in the right-hand frame. This will list all the
@ -191,8 +194,8 @@ public class ModuleWriter extends HtmlDocletWriter {
*/ */
protected void buildContent() { protected void buildContent() {
Content moduleContent = getContentHeader(); Content moduleContent = getContentHeader();
moduleContent.add(new HtmlTree(TagName.HR)); moduleContent.add(new HtmlTree(HtmlTag.HR));
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
addModuleSignature(div); addModuleSignature(div);
buildModuleDescription(div); buildModuleDescription(div);
moduleContent.add(div); moduleContent.add(div);
@ -261,13 +264,13 @@ public class ModuleWriter extends HtmlDocletWriter {
protected Content getModuleHeader(String heading) { protected Content getModuleHeader(String heading) {
HtmlTree body = getBody(getWindowTitle(mdle.getQualifiedName().toString())); HtmlTree body = getBody(getWindowTitle(mdle.getQualifiedName().toString()));
var div = HtmlTree.DIV(HtmlStyle.header); var div = HtmlTree.DIV(HtmlStyles.header);
Content moduleHead = new ContentBuilder(); Content moduleHead = new ContentBuilder();
moduleHead.add(mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL) moduleHead.add(mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL)
? contents.openModuleLabel : contents.moduleLabel); ? contents.openModuleLabel : contents.moduleLabel);
moduleHead.add(" ").add(heading); moduleHead.add(" ").add(heading);
var tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, moduleHead); HtmlStyles.title, moduleHead);
div.add(tHeading); div.add(tHeading);
bodyContents.setHeader(getHeader(PageMode.MODULE, mdle)) bodyContents.setHeader(getHeader(PageMode.MODULE, mdle))
.addMainContent(div); .addMainContent(div);
@ -279,11 +282,11 @@ public class ModuleWriter extends HtmlDocletWriter {
} }
protected Content getSummariesList() { protected Content getSummariesList() {
return HtmlTree.UL(HtmlStyle.summaryList); return HtmlTree.UL(HtmlStyles.summaryList);
} }
protected Content getSummary(Content source) { protected Content getSummary(Content source) {
return HtmlTree.SECTION(HtmlStyle.summary, source); return HtmlTree.SECTION(HtmlStyles.summary, source);
} }
/** /**
@ -502,10 +505,10 @@ public class ModuleWriter extends HtmlDocletWriter {
* @return a content object * @return a content object
*/ */
private Table<?> getTable2(Content caption, TableHeader tableHeader) { private Table<?> getTable2(Content caption, TableHeader tableHeader) {
return new Table<Void>(HtmlStyle.detailsTable) return new Table<Void>(HtmlStyles.detailsTable)
.setCaption(caption) .setCaption(caption)
.setHeader(tableHeader) .setHeader(tableHeader)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
} }
/** /**
@ -516,10 +519,10 @@ public class ModuleWriter extends HtmlDocletWriter {
* @return a content object * @return a content object
*/ */
private Table<?> getTable3(Content caption, TableHeader tableHeader) { private Table<?> getTable3(Content caption, TableHeader tableHeader) {
return new Table<Void>(HtmlStyle.detailsTable) return new Table<Void>(HtmlStyles.detailsTable)
.setCaption(caption) .setCaption(caption)
.setHeader(tableHeader) .setHeader(tableHeader)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast);
} }
protected void addModulesSummary(Content summariesList) { protected void addModulesSummary(Content summariesList) {
@ -528,7 +531,7 @@ public class ModuleWriter extends HtmlDocletWriter {
TableHeader requiresTableHeader = TableHeader requiresTableHeader =
new TableHeader(contents.modifierLabel, contents.moduleLabel, new TableHeader(contents.modifierLabel, contents.moduleLabel,
contents.descriptionLabel); contents.descriptionLabel);
var section = HtmlTree.SECTION(HtmlStyle.modulesSummary) var section = HtmlTree.SECTION(HtmlStyles.modulesSummary)
.setId(HtmlIds.MODULES); .setId(HtmlIds.MODULES);
addSummaryHeader(MarkerComments.START_OF_MODULES_SUMMARY, contents.navModules, section); addSummaryHeader(MarkerComments.START_OF_MODULES_SUMMARY, contents.navModules, section);
if (display(requires)) { if (display(requires)) {
@ -570,7 +573,7 @@ public class ModuleWriter extends HtmlDocletWriter {
if (display(packages) if (display(packages)
|| display(indirectPackages) || display(indirectOpenPackages)) { || display(indirectPackages) || display(indirectOpenPackages)) {
tableOfContents.addLink(HtmlIds.PACKAGES, contents.navPackages); tableOfContents.addLink(HtmlIds.PACKAGES, contents.navPackages);
var section = HtmlTree.SECTION(HtmlStyle.packagesSummary) var section = HtmlTree.SECTION(HtmlStyles.packagesSummary)
.setId(HtmlIds.PACKAGES); .setId(HtmlIds.PACKAGES);
addSummaryHeader(MarkerComments.START_OF_PACKAGES_SUMMARY, contents.navPackages, section); addSummaryHeader(MarkerComments.START_OF_PACKAGES_SUMMARY, contents.navPackages, section);
if (display(packages)) { if (display(packages)) {
@ -600,7 +603,7 @@ public class ModuleWriter extends HtmlDocletWriter {
* @param li the tree to which the summary will be added * @param li the tree to which the summary will be added
*/ */
public void addPackageSummary(HtmlTree li) { public void addPackageSummary(HtmlTree li) {
var table = new Table<PackageElement>(HtmlStyle.summaryTable) var table = new Table<PackageElement>(HtmlStyles.summaryTable)
.setId(HtmlIds.PACKAGE_SUMMARY_TABLE) .setId(HtmlIds.PACKAGE_SUMMARY_TABLE)
.setDefaultTab(contents.getContent("doclet.All_Packages")) .setDefaultTab(contents.getContent("doclet.All_Packages"))
.addTab(contents.getContent("doclet.Exported_Packages_Summary"), this::isExported) .addTab(contents.getContent("doclet.Exported_Packages_Summary"), this::isExported)
@ -636,20 +639,20 @@ public class ModuleWriter extends HtmlDocletWriter {
List<Content> colHeaders = new ArrayList<>(); List<Content> colHeaders = new ArrayList<>();
List<HtmlStyle> colStyles = new ArrayList<>(); List<HtmlStyle> colStyles = new ArrayList<>();
colHeaders.add(contents.packageLabel); colHeaders.add(contents.packageLabel);
colStyles.add(HtmlStyle.colFirst); colStyles.add(HtmlStyles.colFirst);
if (showExportedTo) { if (showExportedTo) {
colHeaders.add(contents.exportedTo); colHeaders.add(contents.exportedTo);
colStyles.add(HtmlStyle.colSecond); colStyles.add(HtmlStyles.colSecond);
} }
if (showOpenedTo) { if (showOpenedTo) {
colHeaders.add(contents.openedTo); colHeaders.add(contents.openedTo);
colStyles.add(HtmlStyle.colSecond); colStyles.add(HtmlStyles.colSecond);
} }
colHeaders.add(contents.descriptionLabel); colHeaders.add(contents.descriptionLabel);
colStyles.add(HtmlStyle.colLast); colStyles.add(HtmlStyles.colLast);
table.setHeader(new TableHeader(colHeaders).styles(colStyles)) table.setHeader(new TableHeader(colHeaders).styles(colStyles))
.setColumnStyles(colStyles); .setColumnStyles(colStyles);
@ -741,7 +744,7 @@ public class ModuleWriter extends HtmlDocletWriter {
if (haveProvides || haveUses) { if (haveProvides || haveUses) {
tableOfContents.addLink(HtmlIds.SERVICES, contents.navServices); tableOfContents.addLink(HtmlIds.SERVICES, contents.navServices);
var section = HtmlTree.SECTION(HtmlStyle.servicesSummary) var section = HtmlTree.SECTION(HtmlStyles.servicesSummary)
.setId(HtmlIds.SERVICES); .setId(HtmlIds.SERVICES);
addSummaryHeader(MarkerComments.START_OF_SERVICES_SUMMARY, contents.navServices, section); addSummaryHeader(MarkerComments.START_OF_SERVICES_SUMMARY, contents.navServices, section);
TableHeader usesProvidesTableHeader = TableHeader usesProvidesTableHeader =
@ -783,7 +786,7 @@ public class ModuleWriter extends HtmlDocletWriter {
if (display(usesTrees)) { if (display(usesTrees)) {
description = usesTrees.get(t); description = usesTrees.get(t);
if (description != null && !description.isEmpty()) { if (description != null && !description.isEmpty()) {
summary.add(HtmlTree.DIV(HtmlStyle.block, description)); summary.add(HtmlTree.DIV(HtmlStyles.block, description));
} else { } else {
addSummaryComment(t, summary); addSummaryComment(t, summary);
} }
@ -813,7 +816,7 @@ public class ModuleWriter extends HtmlDocletWriter {
if (display(providesTrees)) { if (display(providesTrees)) {
description = providesTrees.get(srv); description = providesTrees.get(srv);
if (description != null && !description.isEmpty()) { if (description != null && !description.isEmpty()) {
desc.add(HtmlTree.DIV(HtmlStyle.block, description)); desc.add(HtmlTree.DIV(HtmlStyles.block, description));
} else { } else {
addSummaryComment(srv, desc); addSummaryComment(srv, desc);
} }
@ -822,9 +825,9 @@ public class ModuleWriter extends HtmlDocletWriter {
} }
// Only display the implementation details in the "all" mode. // Only display the implementation details in the "all" mode.
if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) { if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) {
desc.add(new HtmlTree(TagName.BR)); desc.add(new HtmlTree(HtmlTag.BR));
desc.add("("); desc.add("(");
var implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, contents.implementation); var implSpan = HtmlTree.SPAN(HtmlStyles.implementationLabel, contents.implementation);
desc.add(implSpan); desc.add(implSpan);
desc.add(Entity.NO_BREAK_SPACE); desc.add(Entity.NO_BREAK_SPACE);
String sep = ""; String sep = "";
@ -848,8 +851,8 @@ public class ModuleWriter extends HtmlDocletWriter {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(mdle); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(mdle);
if (utils.isDeprecated(mdle)) { if (utils.isDeprecated(mdle)) {
CommentHelper ch = utils.getCommentHelper(mdle); CommentHelper ch = utils.getCommentHelper(mdle);
var deprDiv = HtmlTree.DIV(HtmlStyle.deprecationBlock); var deprDiv = HtmlTree.DIV(HtmlStyles.deprecationBlock);
var deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(mdle)); var deprPhrase = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(mdle));
deprDiv.add(deprPhrase); deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0)); List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
@ -864,7 +867,7 @@ public class ModuleWriter extends HtmlDocletWriter {
protected void addModuleDescription(Content moduleContent) { protected void addModuleDescription(Content moduleContent) {
addPreviewInfo(mdle, moduleContent); addPreviewInfo(mdle, moduleContent);
if (!utils.getFullBody(mdle).isEmpty()) { if (!utils.getFullBody(mdle).isEmpty()) {
var tree = HtmlTree.SECTION(HtmlStyle.moduleDescription) var tree = HtmlTree.SECTION(HtmlStyles.moduleDescription)
.setId(HtmlIds.MODULE_DESCRIPTION); .setId(HtmlIds.MODULE_DESCRIPTION);
addDeprecationInfo(tree); addDeprecationInfo(tree);
tree.add(MarkerComments.START_OF_MODULE_DESCRIPTION); tree.add(MarkerComments.START_OF_MODULE_DESCRIPTION);
@ -902,8 +905,8 @@ public class ModuleWriter extends HtmlDocletWriter {
public void addPackageDeprecationInfo(Content li, PackageElement pkg) { public void addPackageDeprecationInfo(Content li, PackageElement pkg) {
if (utils.isDeprecated(pkg)) { if (utils.isDeprecated(pkg)) {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(pkg); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(pkg);
var deprDiv = HtmlTree.DIV(HtmlStyle.deprecationBlock); var deprDiv = HtmlTree.DIV(HtmlStyles.deprecationBlock);
var deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(pkg)); var deprPhrase = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(pkg));
deprDiv.add(deprPhrase); deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
CommentHelper ch = utils.getCommentHelper(pkg); CommentHelper ch = utils.getCommentHelper(pkg);

View File

@ -35,19 +35,19 @@ import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Links; import jdk.javadoc.internal.doclets.formats.html.markup.Links;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Factory for navigation bar. * Factory for navigation bar.
@ -326,7 +326,7 @@ public class Navigation {
private void addActivePageLink(Content target, Content label, boolean display) { private void addActivePageLink(Content target, Content label, boolean display) {
if (display) { if (display) {
target.add(HtmlTree.LI(HtmlStyle.navBarCell1Rev, label)); target.add(HtmlTree.LI(HtmlStyles.navBarCell1Rev, label));
} }
} }
@ -409,7 +409,7 @@ public class Navigation {
default -> throw new IllegalArgumentException(Objects.toString(elem)); default -> throw new IllegalArgumentException(Objects.toString(elem));
}; };
if (selected) { if (selected) {
link.setStyle(HtmlStyle.currentSelection); link.setStyle(HtmlStyles.currentSelection);
} }
contents.add(link); contents.add(link);
} }
@ -499,7 +499,7 @@ public class Navigation {
.put(HtmlAttr.AUTOCOMPLETE, "off"); .put(HtmlAttr.AUTOCOMPLETE, "off");
var inputReset = HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlIds.RESET_SEARCH) var inputReset = HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlIds.RESET_SEARCH)
.put(HtmlAttr.VALUE, resources.getText("doclet.search_reset")); .put(HtmlAttr.VALUE, resources.getText("doclet.search_reset"));
var searchDiv = HtmlTree.DIV(HtmlStyle.navListSearch) var searchDiv = HtmlTree.DIV(HtmlStyles.navListSearch)
.add(inputText) .add(inputText)
.add(inputReset); .add(inputReset);
target.add(searchDiv); target.add(searchDiv);
@ -516,36 +516,36 @@ public class Navigation {
} }
var navigationBar = HtmlTree.NAV(); var navigationBar = HtmlTree.NAV();
var navContent = new HtmlTree(TagName.DIV); var navContent = new HtmlTree(HtmlTag.DIV);
Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links"); Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links");
String toggleNavLinks = configuration.getDocResources().getText("doclet.Toggle_navigation_links"); String toggleNavLinks = configuration.getDocResources().getText("doclet.Toggle_navigation_links");
navigationBar.add(MarkerComments.START_OF_TOP_NAVBAR); navigationBar.add(MarkerComments.START_OF_TOP_NAVBAR);
// The mobile menu button uses three empty spans to produce its animated icon // The mobile menu button uses three empty spans to produce its animated icon
HtmlTree iconSpan = HtmlTree.SPAN(HtmlStyle.navBarToggleIcon).add(Entity.NO_BREAK_SPACE); HtmlTree iconSpan = HtmlTree.SPAN(HtmlStyles.navBarToggleIcon).add(Entity.NO_BREAK_SPACE);
navContent.setStyle(HtmlStyle.navContent).add(HtmlTree.DIV(HtmlStyle.navMenuButton, navContent.setStyle(HtmlStyles.navContent).add(HtmlTree.DIV(HtmlStyles.navMenuButton,
new HtmlTree(TagName.BUTTON).setId(HtmlIds.NAVBAR_TOGGLE_BUTTON) new HtmlTree(HtmlTag.BUTTON).setId(HtmlIds.NAVBAR_TOGGLE_BUTTON)
.put(HtmlAttr.ARIA_CONTROLS, HtmlIds.NAVBAR_TOP.name()) .put(HtmlAttr.ARIA_CONTROLS, HtmlIds.NAVBAR_TOP.name())
.put(HtmlAttr.ARIA_EXPANDED, String.valueOf(false)) .put(HtmlAttr.ARIA_EXPANDED, String.valueOf(false))
.put(HtmlAttr.ARIA_LABEL, toggleNavLinks) .put(HtmlAttr.ARIA_LABEL, toggleNavLinks)
.add(iconSpan) .add(iconSpan)
.add(iconSpan) .add(iconSpan)
.add(iconSpan))) .add(iconSpan)))
.add(HtmlTree.DIV(HtmlStyle.skipNav, .add(HtmlTree.DIV(HtmlStyles.skipNav,
links.createLink(HtmlIds.SKIP_NAVBAR_TOP, skipNavLinks, links.createLink(HtmlIds.SKIP_NAVBAR_TOP, skipNavLinks,
skipNavLinks.toString()))); skipNavLinks.toString())));
Content aboutContent = userHeader; Content aboutContent = userHeader;
var navList = new HtmlTree(TagName.UL) var navList = new HtmlTree(HtmlTag.UL)
.setId(HtmlIds.NAVBAR_TOP_FIRSTROW) .setId(HtmlIds.NAVBAR_TOP_FIRSTROW)
.setStyle(HtmlStyle.navList) .setStyle(HtmlStyles.navList)
.put(HtmlAttr.TITLE, rowListTitle); .put(HtmlAttr.TITLE, rowListTitle);
addMainNavLinks(navList); addMainNavLinks(navList);
navContent.add(navList); navContent.add(navList);
var aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, aboutContent); var aboutDiv = HtmlTree.DIV(HtmlStyles.aboutLanguage, aboutContent);
navContent.add(aboutDiv); navContent.add(aboutDiv);
navigationBar.add(HtmlTree.DIV(HtmlStyle.topNav, navContent).setId(HtmlIds.NAVBAR_TOP)); navigationBar.add(HtmlTree.DIV(HtmlStyles.topNav, navContent).setId(HtmlIds.NAVBAR_TOP));
var subNavContent = HtmlTree.DIV(HtmlStyle.navContent); var subNavContent = HtmlTree.DIV(HtmlStyles.navContent);
List<Content> subNavLinks = new ArrayList<>(); List<Content> subNavLinks = new ArrayList<>();
switch (documentedPage) { switch (documentedPage) {
case MODULE, PACKAGE, CLASS, USE, DOC_FILE, TREE -> { case MODULE, PACKAGE, CLASS, USE, DOC_FILE, TREE -> {
@ -553,17 +553,17 @@ public class Navigation {
} }
} }
// Add the breadcrumb navigation links if present. // Add the breadcrumb navigation links if present.
var breadcrumbNav = HtmlTree.OL(HtmlStyle.subNavList); var breadcrumbNav = HtmlTree.OL(HtmlStyles.subNavList);
breadcrumbNav.addAll(subNavLinks, HtmlTree::LI); breadcrumbNav.addAll(subNavLinks, HtmlTree::LI);
subNavContent.addUnchecked(breadcrumbNav); subNavContent.addUnchecked(breadcrumbNav);
if (options.createIndex() && documentedPage != PageMode.SEARCH) { if (options.createIndex() && documentedPage != PageMode.SEARCH) {
addSearch(subNavContent); addSearch(subNavContent);
} }
navigationBar.add(HtmlTree.DIV(HtmlStyle.subNav, subNavContent)); navigationBar.add(HtmlTree.DIV(HtmlStyles.subNav, subNavContent));
navigationBar.add(MarkerComments.END_OF_TOP_NAVBAR); navigationBar.add(MarkerComments.END_OF_TOP_NAVBAR);
navigationBar.add(HtmlTree.SPAN(HtmlStyle.skipNav) navigationBar.add(HtmlTree.SPAN(HtmlStyles.skipNav)
.addUnchecked(Text.EMPTY) .addUnchecked(Text.EMPTY)
.setId(HtmlIds.SKIP_NAVBAR_TOP)); .setId(HtmlIds.SKIP_NAVBAR_TOP));

View File

@ -31,12 +31,14 @@ import java.util.List;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes nested class documentation in HTML format. * Writes nested class documentation in HTML format.
@ -71,7 +73,7 @@ public class NestedClassWriter extends AbstractMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.nestedClassSummary, writer.addSummary(HtmlStyles.nestedClassSummary,
HtmlIds.NESTED_CLASS_SUMMARY, summariesList, content); HtmlIds.NESTED_CLASS_SUMMARY, summariesList, content);
} }
@ -92,10 +94,10 @@ public class NestedClassWriter extends AbstractMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyle.colFirst, HtmlStyle.colSecond, List<HtmlStyle> bodyRowStyles = Arrays.asList(HtmlStyles.colFirst, HtmlStyles.colSecond,
HtmlStyle.colLast); HtmlStyles.colLast);
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setCaption(contents.getContent("doclet.Nested_Classes")) .setCaption(contents.getContent("doclet.Nested_Classes"))
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(bodyRowStyles); .setColumnStyles(bodyRowStyles);
@ -125,7 +127,7 @@ public class NestedClassWriter extends AbstractMemberWriter {
protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member, protected void addSummaryLink(HtmlLinkInfo.Kind context, TypeElement typeElement, Element member,
Content content) { Content content) {
Content memberLink = writer.getLink(new HtmlLinkInfo(configuration, context, (TypeElement)member) Content memberLink = writer.getLink(new HtmlLinkInfo(configuration, context, (TypeElement)member)
.style(HtmlStyle.typeNameLink)); .style(HtmlStyles.typeNameLink));
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);
content.add(code); content.add(code);
} }

View File

@ -32,14 +32,14 @@ import javax.lang.model.element.Element;
import com.sun.source.doctree.SinceTree; import com.sun.source.doctree.SinceTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder; import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static com.sun.source.doctree.DocTree.Kind.SINCE; import static com.sun.source.doctree.DocTree.Kind.SINCE;
@ -81,7 +81,7 @@ public class NewAPIListWriter extends SummaryListWriter<NewAPIBuilder> {
protected void addContentSelectors(Content content) { protected void addContentSelectors(Content content) {
List<String> releases = builder.releases; List<String> releases = builder.releases;
if (releases.size() > 1) { if (releases.size() > 1) {
Content tabs = HtmlTree.DIV(HtmlStyle.checkboxes, Content tabs = HtmlTree.DIV(HtmlStyles.checkboxes,
contents.getContent("doclet.New_API_Checkbox_Label")); contents.getContent("doclet.New_API_Checkbox_Label"));
// Table column ids are 1-based // Table column ids are 1-based
int index = 1; int index = 1;
@ -96,7 +96,7 @@ public class NewAPIListWriter extends SummaryListWriter<NewAPIBuilder> {
@Override @Override
protected void addTableTabs(Table<Element> table, String headingKey) { protected void addTableTabs(Table<Element> table, String headingKey) {
table.setGridStyle(HtmlStyle.threeColumnReleaseSummary); table.setGridStyle(HtmlStyles.threeColumnReleaseSummary);
List<String> releases = builder.releases; List<String> releases = builder.releases;
if (releases.size() > 1) { if (releases.size() > 1) {
table.setDefaultTab(getTableCaption(headingKey)) table.setDefaultTab(getTableCaption(headingKey))
@ -149,7 +149,7 @@ public class NewAPIListWriter extends SummaryListWriter<NewAPIBuilder> {
@Override @Override
protected HtmlStyle[] getColumnStyles() { protected HtmlStyle[] getColumnStyles() {
return new HtmlStyle[]{ HtmlStyle.colSummaryItemName, HtmlStyle.colSecond, HtmlStyle.colLast }; return new HtmlStyle[]{ HtmlStyles.colSummaryItemName, HtmlStyles.colSecond, HtmlStyles.colLast };
} }
private static String getHeading(HtmlConfiguration configuration) { private static String getHeading(HtmlConfiguration configuration) {

View File

@ -31,11 +31,12 @@ import java.util.SortedSet;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Group; import jdk.javadoc.internal.doclets.toolkit.util.Group;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate the package index page "index.html". * Generate the package index page "index.html".
@ -81,9 +82,9 @@ public class PackageIndexWriter extends AbstractOverviewIndexWriter {
= configuration.group.groupPackages(packages); = configuration.group.groupPackages(packages);
if (!groupPackageMap.keySet().isEmpty()) { if (!groupPackageMap.keySet().isEmpty()) {
var table = new Table<PackageElement>(HtmlStyle.summaryTable) var table = new Table<PackageElement>(HtmlStyles.summaryTable)
.setHeader(getPackageTableHeader()) .setHeader(getPackageTableHeader())
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast)
.setId(HtmlIds.ALL_PACKAGES_TABLE) .setId(HtmlIds.ALL_PACKAGES_TABLE)
.setDefaultTab(contents.getContent("doclet.All_Packages")); .setDefaultTab(contents.getContent("doclet.All_Packages"));

View File

@ -25,21 +25,17 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import java.util.ArrayList; import jdk.javadoc.internal.html.ContentBuilder;
import java.util.List; import jdk.javadoc.internal.html.HtmlTree;
/** /**
@ -100,8 +96,8 @@ public class PackageTreeWriter extends AbstractTreeWriter {
: contents.getContent("doclet.Hierarchy_For_Package", : contents.getContent("doclet.Hierarchy_For_Package",
getLocalizedPackageName(packageElement)); getLocalizedPackageName(packageElement));
var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headContent); HtmlStyles.title, headContent);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
mainContent.add(div); mainContent.add(div);
if (configuration.packages.size() > 1) { if (configuration.packages.size() > 1) {
addLinkToAllPackages(mainContent); addLinkToAllPackages(mainContent);
@ -136,10 +132,10 @@ public class PackageTreeWriter extends AbstractTreeWriter {
* @param target the content to which the link will be added * @param target the content to which the link will be added
*/ */
protected void addLinkToAllPackages(Content target) { protected void addLinkToAllPackages(Content target) {
var span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, var span = HtmlTree.SPAN(HtmlStyles.packageHierarchyLabel,
contents.packageHierarchies); contents.packageHierarchies);
target.add(span); target.add(span);
var ul = HtmlTree.UL(HtmlStyle.horizontal).addStyle(HtmlStyle.contentsList); var ul = HtmlTree.UL(HtmlStyles.horizontal).addStyle(HtmlStyles.contentsList);
// TODO the link should be more specific: // TODO the link should be more specific:
// it should point to the "all packages" section of the overview tree // it should point to the "all packages" section of the overview tree
ul.add(getNavLinkToOverviewTree(resources.getText("doclet.All_Packages"))); ul.add(getNavLinkToOverviewTree(resources.getText("doclet.All_Packages")));

View File

@ -25,28 +25,26 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate package usage information. * Generate package usage information.
@ -138,10 +136,10 @@ public class PackageUseWriter extends SubWriterHolderWriter {
Content caption = contents.getContent( Content caption = contents.getContent(
"doclet.ClassUse_Packages.that.use.0", "doclet.ClassUse_Packages.that.use.0",
getPackageLink(packageElement, getLocalizedPackageName(packageElement))); getPackageLink(packageElement, getLocalizedPackageName(packageElement)));
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(caption) .setCaption(caption)
.setHeader(getPackageTableHeader()) .setHeader(getPackageTableHeader())
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (String pkgname: usingPackageToUsedClasses.keySet()) { for (String pkgname: usingPackageToUsedClasses.keySet()) {
PackageElement pkg = utils.elementUtils.getPackageElement(pkgname); PackageElement pkg = utils.elementUtils.getPackageElement(pkgname);
Content packageLink = links.createLink(htmlIds.forPackage(pkg), Content packageLink = links.createLink(htmlIds.forPackage(pkg),
@ -165,19 +163,19 @@ public class PackageUseWriter extends SubWriterHolderWriter {
protected void addClassList(Content content) { protected void addClassList(Content content) {
TableHeader classTableHeader = new TableHeader( TableHeader classTableHeader = new TableHeader(
contents.classLabel, contents.descriptionLabel); contents.classLabel, contents.descriptionLabel);
var ul = HtmlTree.UL(HtmlStyle.blockList); var ul = HtmlTree.UL(HtmlStyles.blockList);
for (String packageName : usingPackageToUsedClasses.keySet()) { for (String packageName : usingPackageToUsedClasses.keySet()) {
PackageElement usingPackage = utils.elementUtils.getPackageElement(packageName); PackageElement usingPackage = utils.elementUtils.getPackageElement(packageName);
var section = HtmlTree.SECTION(HtmlStyle.detail) var section = HtmlTree.SECTION(HtmlStyles.detail)
.setId(htmlIds.forPackage(usingPackage)); .setId(htmlIds.forPackage(usingPackage));
Content caption = contents.getContent( Content caption = contents.getContent(
"doclet.ClassUse_Classes.in.0.used.by.1", "doclet.ClassUse_Classes.in.0.used.by.1",
getPackageLink(packageElement, getLocalizedPackageName(packageElement)), getPackageLink(packageElement, getLocalizedPackageName(packageElement)),
getPackageLink(usingPackage, getLocalizedPackageName(usingPackage))); getPackageLink(usingPackage, getLocalizedPackageName(usingPackage)));
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(caption) .setCaption(caption)
.setHeader(classTableHeader) .setHeader(classTableHeader)
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (TypeElement te : usingPackageToUsedClasses.get(packageName)) { for (TypeElement te : usingPackageToUsedClasses.get(packageName)) {
DocPath dp = pathString(te, DocPath dp = pathString(te,
DocPaths.CLASS_USE.resolve(docPaths.forName(te))); DocPaths.CLASS_USE.resolve(docPaths.forName(te)));
@ -192,7 +190,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
section.add(table); section.add(table);
ul.add(HtmlTree.LI(section)); ul.add(HtmlTree.LI(section));
} }
var li = HtmlTree.SECTION(HtmlStyle.packageUses, ul); var li = HtmlTree.SECTION(HtmlStyles.packageUses, ul);
content.add(li); content.add(li);
} }
@ -206,11 +204,11 @@ public class PackageUseWriter extends SubWriterHolderWriter {
HtmlTree body = getBody(getWindowTitle(title)); HtmlTree body = getBody(getWindowTitle(title));
ContentBuilder headingContent = new ContentBuilder(); ContentBuilder headingContent = new ContentBuilder();
headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText)); headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
headingContent.add(new HtmlTree(TagName.BR)); headingContent.add(new HtmlTree(HtmlTag.BR));
headingContent.add(name); headingContent.add(name);
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent); HtmlStyles.title, headingContent);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
bodyContents.setHeader(getHeader(PageMode.USE, packageElement)) bodyContents.setHeader(getHeader(PageMode.USE, packageElement))
.addMainContent(div); .addMainContent(div);
return body; return body;

View File

@ -33,25 +33,26 @@ import java.util.function.Predicate;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.lang.model.element.Element;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DeprecatedTree; import com.sun.source.doctree.DeprecatedTree;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Class to generate file for each package contents in the right-hand * Class to generate file for each package contents in the right-hand
@ -71,7 +72,7 @@ public class PackageWriter extends HtmlDocletWriter {
/** /**
* The HTML element for the section tag being written. * The HTML element for the section tag being written.
*/ */
private final HtmlTree section = HtmlTree.SECTION(HtmlStyle.packageDescription, new ContentBuilder()); private final HtmlTree section = HtmlTree.SECTION(HtmlStyles.packageDescription, new ContentBuilder());
private final BodyContents bodyContents = new BodyContents(); private final BodyContents bodyContents = new BodyContents();
@ -127,8 +128,8 @@ public class PackageWriter extends HtmlDocletWriter {
*/ */
protected void buildContent() { protected void buildContent() {
Content packageContent = getContentHeader(); Content packageContent = getContentHeader();
packageContent.add(new HtmlTree(TagName.HR)); packageContent.add(new HtmlTree(HtmlTag.HR));
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
addPackageSignature(div); addPackageSignature(div);
buildPackageDescription(div); buildPackageDescription(div);
buildPackageTags(div); buildPackageTags(div);
@ -202,14 +203,14 @@ public class PackageWriter extends HtmlDocletWriter {
protected Content getPackageHeader() { protected Content getPackageHeader() {
String packageName = getLocalizedPackageName(packageElement).toString(); String packageName = getLocalizedPackageName(packageElement).toString();
HtmlTree body = getBody(getWindowTitle(packageName)); HtmlTree body = getBody(getWindowTitle(packageName));
var div = HtmlTree.DIV(HtmlStyle.header); var div = HtmlTree.DIV(HtmlStyles.header);
Content packageHead = new ContentBuilder(); Content packageHead = new ContentBuilder();
if (!packageElement.isUnnamed()) { if (!packageElement.isUnnamed()) {
packageHead.add(contents.packageLabel).add(" "); packageHead.add(contents.packageLabel).add(" ");
} }
packageHead.add(packageName); packageHead.add(packageName);
var tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, packageHead); HtmlStyles.title, packageHead);
div.add(tHeading); div.add(tHeading);
bodyContents.setHeader(getHeader(PageMode.PACKAGE, packageElement)) bodyContents.setHeader(getHeader(PageMode.PACKAGE, packageElement))
.addMainContent(div); .addMainContent(div);
@ -277,8 +278,8 @@ public class PackageWriter extends HtmlDocletWriter {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(packageElement); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(packageElement);
if (utils.isDeprecated(packageElement)) { if (utils.isDeprecated(packageElement)) {
CommentHelper ch = utils.getCommentHelper(packageElement); CommentHelper ch = utils.getCommentHelper(packageElement);
var deprDiv = HtmlTree.DIV(HtmlStyle.deprecationBlock); var deprDiv = HtmlTree.DIV(HtmlStyles.deprecationBlock);
var deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(packageElement)); var deprPhrase = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(packageElement));
deprDiv.add(deprPhrase); deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0)); List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
@ -291,7 +292,7 @@ public class PackageWriter extends HtmlDocletWriter {
} }
protected Content getSummariesList() { protected Content getSummariesList() {
return HtmlTree.UL(HtmlStyle.summaryList); return HtmlTree.UL(HtmlStyles.summaryList);
} }
protected void addRelatedPackagesSummary(Content summaryContent) { protected void addRelatedPackagesSummary(Content summaryContent) {
@ -308,9 +309,9 @@ public class PackageWriter extends HtmlDocletWriter {
* @param target the content to which the links will be added * @param target the content to which the links will be added
*/ */
public void addAllClassesAndInterfacesSummary(Content target) { public void addAllClassesAndInterfacesSummary(Content target) {
var table = new Table<TypeElement>(HtmlStyle.summaryTable) var table = new Table<TypeElement>(HtmlStyles.summaryTable)
.setHeader(new TableHeader(contents.classLabel, contents.descriptionLabel)) .setHeader(new TableHeader(contents.classLabel, contents.descriptionLabel))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast)
.setId(HtmlIds.CLASS_SUMMARY) .setId(HtmlIds.CLASS_SUMMARY)
.setDefaultTab(contents.allClassesAndInterfacesLabel) .setDefaultTab(contents.allClassesAndInterfacesLabel)
.addTab(contents.interfaces, utils::isPlainInterface) .addTab(contents.interfaces, utils::isPlainInterface)
@ -347,14 +348,14 @@ public class PackageWriter extends HtmlDocletWriter {
boolean showModules) { boolean showModules) {
if (!relatedPackages.isEmpty()) { if (!relatedPackages.isEmpty()) {
tableOfContents.addLink(HtmlIds.RELATED_PACKAGE_SUMMARY, contents.relatedPackages); tableOfContents.addLink(HtmlIds.RELATED_PACKAGE_SUMMARY, contents.relatedPackages);
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setId(HtmlIds.RELATED_PACKAGE_SUMMARY) .setId(HtmlIds.RELATED_PACKAGE_SUMMARY)
.setCaption(contents.relatedPackages) .setCaption(contents.relatedPackages)
.setHeader(tableHeader); .setHeader(tableHeader);
if (showModules) { if (showModules) {
table.setColumnStyles(HtmlStyle.colPlain, HtmlStyle.colFirst, HtmlStyle.colLast); table.setColumnStyles(HtmlStyles.colPlain, HtmlStyles.colFirst, HtmlStyles.colLast);
} else { } else {
table.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); table.setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
} }
for (PackageElement pkg : relatedPackages) { for (PackageElement pkg : relatedPackages) {
@ -423,7 +424,7 @@ public class PackageWriter extends HtmlDocletWriter {
} }
protected Content getPackageSummary(Content summaryContent) { protected Content getPackageSummary(Content summaryContent) {
return HtmlTree.SECTION(HtmlStyle.summary, summaryContent); return HtmlTree.SECTION(HtmlStyles.summary, summaryContent);
} }
private boolean hasRelatedPackagesInOtherModules(List<PackageElement> relatedPackages) { private boolean hasRelatedPackagesInOtherModules(List<PackageElement> relatedPackages) {

View File

@ -33,12 +33,14 @@ import javax.lang.model.element.Element;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate File to list all the preview elements with the * Generate File to list all the preview elements with the
@ -81,7 +83,7 @@ public class PreviewListWriter extends SummaryListWriter<PreviewAPIListBuilder>
if (!jeps.isEmpty()) { if (!jeps.isEmpty()) {
int index = 1; int index = 1;
target.add(HtmlTree.P(contents.getContent("doclet.Preview_API_Checkbox_Label"))); target.add(HtmlTree.P(contents.getContent("doclet.Preview_API_Checkbox_Label")));
Content list = HtmlTree.UL(HtmlStyle.previewFeatureList).addStyle(HtmlStyle.checkboxes); Content list = HtmlTree.UL(HtmlStyles.previewFeatureList).addStyle(HtmlStyles.checkboxes);
for (var jep : jeps) { for (var jep : jeps) {
String jepUrl = resources.getText("doclet.Preview_JEP_URL", String.valueOf(jep.number())); String jepUrl = resources.getText("doclet.Preview_JEP_URL", String.valueOf(jep.number()));
Content label = new ContentBuilder(Text.of(jep.number() + ": ")) Content label = new ContentBuilder(Text.of(jep.number() + ": "))
@ -106,7 +108,7 @@ public class PreviewListWriter extends SummaryListWriter<PreviewAPIListBuilder>
@Override @Override
protected void addTableTabs(Table<Element> table, String headingKey) { protected void addTableTabs(Table<Element> table, String headingKey) {
table.setGridStyle(HtmlStyle.threeColumnSummary) table.setGridStyle(HtmlStyles.threeColumnSummary)
.setDefaultTab(getTableCaption(headingKey)) .setDefaultTab(getTableCaption(headingKey))
.setRenderTabs(false); .setRenderTabs(false);
for (PreviewAPIListBuilder.JEP jep : builder.getJEPs()) { for (PreviewAPIListBuilder.JEP jep : builder.getJEPs()) {
@ -131,6 +133,6 @@ public class PreviewListWriter extends SummaryListWriter<PreviewAPIListBuilder>
@Override @Override
protected HtmlStyle[] getColumnStyles() { protected HtmlStyle[] getColumnStyles() {
return new HtmlStyle[]{ HtmlStyle.colSummaryItemName, HtmlStyle.colSecond, HtmlStyle.colLast }; return new HtmlStyle[]{ HtmlStyles.colSummaryItemName, HtmlStyles.colSecond, HtmlStyles.colLast };
} }
} }

View File

@ -35,14 +35,15 @@ import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DocCommentTree; import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils; import jdk.javadoc.internal.doclets.toolkit.CommentUtils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Writes property documentation in HTML format. * Writes property documentation in HTML format.
@ -80,7 +81,7 @@ public class PropertyWriter extends AbstractMemberWriter {
for (Element property : properties) { for (Element property : properties) {
currentProperty = (ExecutableElement)property; currentProperty = (ExecutableElement)property;
Content propertyContent = getPropertyHeaderContent(currentProperty); Content propertyContent = getPropertyHeaderContent(currentProperty);
Content div = HtmlTree.DIV(HtmlStyle.horizontalScroll); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
buildSignature(div); buildSignature(div);
buildDeprecationInfo(div); buildDeprecationInfo(div);
buildPreviewInfo(div); buildPreviewInfo(div);
@ -161,7 +162,7 @@ public class PropertyWriter extends AbstractMemberWriter {
@Override @Override
public void buildSummary(Content summariesList, Content content) { public void buildSummary(Content summariesList, Content content) {
writer.addSummary(HtmlStyle.propertySummary, writer.addSummary(HtmlStyles.propertySummary,
HtmlIds.PROPERTY_SUMMARY, summariesList, content); HtmlIds.PROPERTY_SUMMARY, summariesList, content);
} }
@ -179,7 +180,7 @@ public class PropertyWriter extends AbstractMemberWriter {
var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING, var heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
Text.of(utils.getPropertyLabel(name(property)))); Text.of(utils.getPropertyLabel(name(property))));
content.add(heading); content.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, content) return HtmlTree.SECTION(HtmlStyles.detail, content)
.setId(htmlIds.forProperty(property)); .setId(htmlIds.forProperty(property));
} }
@ -210,13 +211,13 @@ public class PropertyWriter extends AbstractMemberWriter {
utils.isIncluded(holder) utils.isIncluded(holder)
? holder.getSimpleName() : holder.getQualifiedName()); ? holder.getSimpleName() : holder.getQualifiedName());
var codeLink = HtmlTree.CODE(link); var codeLink = HtmlTree.CODE(link);
var descriptionFromLabel = HtmlTree.SPAN(HtmlStyle.descriptionFromTypeLabel, var descriptionFromLabel = HtmlTree.SPAN(HtmlStyles.descriptionFromTypeLabel,
utils.isClass(holder) utils.isClass(holder)
? contents.descriptionFromClassLabel ? contents.descriptionFromClassLabel
: contents.descriptionFromInterfaceLabel); : contents.descriptionFromInterfaceLabel);
descriptionFromLabel.add(Entity.NO_BREAK_SPACE); descriptionFromLabel.add(Entity.NO_BREAK_SPACE);
descriptionFromLabel.add(codeLink); descriptionFromLabel.add(codeLink);
propertyContent.add(HtmlTree.DIV(HtmlStyle.block, descriptionFromLabel)); propertyContent.add(HtmlTree.DIV(HtmlStyles.block, descriptionFromLabel));
} }
writer.addInlineComment(property, propertyContent); writer.addInlineComment(property, propertyContent);
} }
@ -229,7 +230,7 @@ public class PropertyWriter extends AbstractMemberWriter {
protected Content getPropertyDetails(Content memberDetailsHeader, Content memberDetails) { protected Content getPropertyDetails(Content memberDetailsHeader, Content memberDetails) {
return writer.getDetailsListItem( return writer.getDetailsListItem(
HtmlTree.SECTION(HtmlStyle.propertyDetails) HtmlTree.SECTION(HtmlStyles.propertyDetails)
.setId(HtmlIds.PROPERTY_DETAIL) .setId(HtmlIds.PROPERTY_DETAIL)
.add(memberDetailsHeader) .add(memberDetailsHeader)
.add(memberDetails)); .add(memberDetails));
@ -250,10 +251,10 @@ public class PropertyWriter extends AbstractMemberWriter {
@Override @Override
protected Table<Element> createSummaryTable() { protected Table<Element> createSummaryTable() {
return new Table<Element>(HtmlStyle.summaryTable) return new Table<Element>(HtmlStyles.summaryTable)
.setCaption(contents.properties) .setCaption(contents.properties)
.setHeader(getSummaryTableHeader(typeElement)) .setHeader(getSummaryTableHeader(typeElement))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colSecond, HtmlStyles.colLast);
} }
@Override @Override
@ -284,7 +285,7 @@ public class PropertyWriter extends AbstractMemberWriter {
Content memberLink = writer.getDocLink(context, typeElement, Content memberLink = writer.getDocLink(context, typeElement,
member, member,
Text.of(utils.getPropertyLabel(name(member))), Text.of(utils.getPropertyLabel(name(member))),
HtmlStyle.memberNameLink, HtmlStyles.memberNameLink,
true); true);
var code = HtmlTree.CODE(memberLink); var code = HtmlTree.CODE(memberLink);

View File

@ -31,6 +31,7 @@ import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.doclets.toolkit.util.RestrictedAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.RestrictedAPIListBuilder;
import jdk.javadoc.internal.html.Content;
/** /**
* Generate File to list all the restricted methods with the * Generate File to list all the restricted methods with the

View File

@ -27,15 +27,16 @@ package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generates the search landing page for the generated API documentation. * Generates the search landing page for the generated API documentation.
@ -79,7 +80,7 @@ public class SearchWriter extends HtmlDocletWriter {
helpSection = HtmlTree.P(contents.getContent("doclet.search.help_page_info", helpLink)); helpSection = HtmlTree.P(contents.getContent("doclet.search.help_page_info", helpLink));
} }
contentTree.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, contentTree.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyles.title,
contents.getContent("doclet.search.main_heading"))) contents.getContent("doclet.search.main_heading")))
.add(HtmlTree.DIV(HtmlTree.INPUT(HtmlAttr.InputType.TEXT, HtmlId.of("page-search-input")) .add(HtmlTree.DIV(HtmlTree.INPUT(HtmlAttr.InputType.TEXT, HtmlId.of("page-search-input"))
.put(HtmlAttr.PLACEHOLDER, resources.getText("doclet.search_placeholder")) .put(HtmlAttr.PLACEHOLDER, resources.getText("doclet.search_placeholder"))
@ -88,31 +89,31 @@ public class SearchWriter extends HtmlDocletWriter {
.add(HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlId.of("page-search-reset")) .add(HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlId.of("page-search-reset"))
.put(HtmlAttr.VALUE, resources.getText("doclet.search_reset")) .put(HtmlAttr.VALUE, resources.getText("doclet.search_reset"))
.put(HtmlAttr.STYLE, "margin: 6px;")) .put(HtmlAttr.STYLE, "margin: 6px;"))
.add(HtmlTree.DETAILS(HtmlStyle.pageSearchDetails) .add(HtmlTree.DETAILS(HtmlStyles.pageSearchDetails)
.add(HtmlTree.SUMMARY(contents.getContent("doclet.search.show_more")) .add(HtmlTree.SUMMARY(contents.getContent("doclet.search.show_more"))
.setId(HtmlId.of("page-search-expand"))))) .setId(HtmlId.of("page-search-expand")))))
.add(HtmlTree.DIV(HtmlStyle.pageSearchInfo, helpSection) .add(HtmlTree.DIV(HtmlStyles.pageSearchInfo, helpSection)
.add(HtmlTree.P(contents.getContent("doclet.search.keyboard_info"))) .add(HtmlTree.P(contents.getContent("doclet.search.keyboard_info")))
.add(HtmlTree.P(contents.getContent("doclet.search.browser_info"))) .add(HtmlTree.P(contents.getContent("doclet.search.browser_info")))
.add(HtmlTree.SPAN(Text.of("link")) .add(HtmlTree.SPAN(Text.of("link"))
.setId(HtmlId.of("page-search-link"))) .setId(HtmlId.of("page-search-link")))
.add(new HtmlTree(TagName.BUTTON) .add(new HtmlTree(HtmlTag.BUTTON)
.add(new HtmlTree(TagName.IMG) .add(new HtmlTree(HtmlTag.IMG)
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
.resolve(DocPaths.CLIPBOARD_SVG).getPath()) .resolve(DocPaths.CLIPBOARD_SVG).getPath())
.put(HtmlAttr.ALT, copyUrlText)) .put(HtmlAttr.ALT, copyUrlText))
.add(HtmlTree.SPAN(Text.of(copyText)) .add(HtmlTree.SPAN(Text.of(copyText))
.put(HtmlAttr.DATA_COPIED, copiedText)) .put(HtmlAttr.DATA_COPIED, copiedText))
.addStyle(HtmlStyle.copy) .addStyle(HtmlStyles.copy)
.put(HtmlAttr.ARIA_LABEL, copyUrlText) .put(HtmlAttr.ARIA_LABEL, copyUrlText)
.setId(HtmlId.of("page-search-copy"))) .setId(HtmlId.of("page-search-copy")))
.add(HtmlTree.P(HtmlTree.INPUT(HtmlAttr.InputType.CHECKBOX, HtmlId.of("search-redirect"))) .add(HtmlTree.P(HtmlTree.INPUT(HtmlAttr.InputType.CHECKBOX, HtmlId.of("search-redirect")))
.add(HtmlTree.LABEL("search-redirect", .add(HtmlTree.LABEL("search-redirect",
contents.getContent("doclet.search.redirect"))))) contents.getContent("doclet.search.redirect")))))
.add(new HtmlTree(TagName.P) .add(new HtmlTree(HtmlTag.P)
.setId(HtmlId.of("page-search-notify")) .setId(HtmlId.of("page-search-notify"))
.add(contents.getContent("doclet.search.loading"))) .add(contents.getContent("doclet.search.loading")))
.add(HtmlTree.DIV(new HtmlTree(TagName.DIV) .add(HtmlTree.DIV(new HtmlTree(HtmlTag.DIV)
.setId(HtmlId.of("result-container")) .setId(HtmlId.of("result-container"))
.addUnchecked(Text.EMPTY)) .addUnchecked(Text.EMPTY))
.setId(HtmlId.of("result-section")) .setId(HtmlId.of("result-section"))

View File

@ -35,11 +35,12 @@ import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.SerialFieldTree; import com.sun.source.doctree.SerialFieldTree;
import com.sun.source.doctree.SerialTree; import com.sun.source.doctree.SerialTree;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.taglets.TagletWriter; import jdk.javadoc.internal.doclets.formats.html.taglets.TagletWriter;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generate serialized form for serializable fields. * Generate serialized form for serializable fields.
@ -53,15 +54,15 @@ public class SerialFieldWriter extends FieldWriter {
} }
protected Content getSerializableFieldsHeader() { protected Content getSerializableFieldsHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
protected Content getFieldsContentHeader() { protected Content getFieldsContentHeader() {
return new HtmlTree(TagName.LI).setStyle(HtmlStyle.blockList); return new HtmlTree(HtmlTag.LI).setStyle(HtmlStyles.blockList);
} }
protected Content getSerializableFields(String heading, Content source) { protected Content getSerializableFields(String heading, Content source) {
var section = HtmlTree.SECTION(HtmlStyle.detail); var section = HtmlTree.SECTION(HtmlStyles.detail);
if (!source.isEmpty()) { if (!source.isEmpty()) {
Content headingContent = Text.of(heading); Content headingContent = Text.of(heading);
var serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent); var serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent);
@ -75,7 +76,7 @@ public class SerialFieldWriter extends FieldWriter {
Content nameContent = Text.of(fieldName); Content nameContent = Text.of(fieldName);
var heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent); var heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent);
content.add(heading); content.add(heading);
var pre = new HtmlTree(TagName.PRE); var pre = new HtmlTree(HtmlTag.PRE);
Content fieldContent = writer.getLink(new HtmlLinkInfo( Content fieldContent = writer.getLink(new HtmlLinkInfo(
configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, fieldType)); configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, fieldType));
pre.add(fieldContent); pre.add(fieldContent);
@ -122,7 +123,7 @@ public class SerialFieldWriter extends FieldWriter {
Content serialFieldContent = writer.commentTagsToContent(field, Content serialFieldContent = writer.commentTagsToContent(field,
description, description,
new TagletWriter.Context(false, false)); new TagletWriter.Context(false, false));
var div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent); var div = HtmlTree.DIV(HtmlStyles.block, serialFieldContent);
content.add(div); content.add(div);
} }
} }
@ -136,7 +137,7 @@ public class SerialFieldWriter extends FieldWriter {
protected void addMemberTags(VariableElement field, Content content) { protected void addMemberTags(VariableElement field, Content content) {
Content tagContent = writer.getBlockTagOutput(field); Content tagContent = writer.getBlockTagOutput(field);
if (!tagContent.isEmpty()) { if (!tagContent.isEmpty()) {
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(tagContent); dl.add(tagContent);
content.add(dl); content.add(dl);
} }

View File

@ -28,11 +28,12 @@ package jdk.javadoc.internal.doclets.formats.html;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.taglets.TagletManager; import jdk.javadoc.internal.doclets.formats.html.taglets.TagletManager;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
@ -46,11 +47,11 @@ public class SerialMethodWriter extends MethodWriter {
} }
protected Content getSerializableMethodsHeader() { protected Content getSerializableMethodsHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
protected Content getMethodsContentHeader() { protected Content getMethodsContentHeader() {
return new HtmlTree(TagName.LI); return new HtmlTree(HtmlTag.LI);
} }
/** /**
@ -64,7 +65,7 @@ public class SerialMethodWriter extends MethodWriter {
protected Content getSerializableMethods(String heading, Content source) { protected Content getSerializableMethods(String heading, Content source) {
Content headingContent = Text.of(heading); Content headingContent = Text.of(heading);
var serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent); var serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent);
var section = HtmlTree.SECTION(HtmlStyle.detail, serialHeading); var section = HtmlTree.SECTION(HtmlStyles.detail, serialHeading);
section.add(source); section.add(source);
return HtmlTree.LI(section); return HtmlTree.LI(section);
} }
@ -121,7 +122,7 @@ public class SerialMethodWriter extends MethodWriter {
protected void addMemberTags(ExecutableElement member, Content methodsContent) { protected void addMemberTags(ExecutableElement member, Content methodsContent) {
TagletManager tagletManager = configuration.tagletManager; TagletManager tagletManager = configuration.tagletManager;
Content tagContent = writer.getBlockTagOutput(member, tagletManager.getSerializedFormTaglets()); Content tagContent = writer.getBlockTagOutput(member, tagletManager.getSerializedFormTaglets());
var dl = HtmlTree.DL(HtmlStyle.notes); var dl = HtmlTree.DL(HtmlStyles.notes);
dl.add(tagContent); dl.add(tagContent);
methodsContent.add(dl); methodsContent.add(dl);
if (name(member).equals("writeExternal") if (name(member).equals("writeExternal")

View File

@ -41,18 +41,19 @@ import javax.lang.model.type.TypeMirror;
import com.sun.source.doctree.SerialFieldTree; import com.sun.source.doctree.SerialFieldTree;
import com.sun.source.doctree.SerialTree; import com.sun.source.doctree.SerialTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Generates the Serialized Form Information Page, <i>serialized-form.html</i>. * Generates the Serialized Form Information Page, <i>serialized-form.html</i>.
@ -562,8 +563,8 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
HtmlTree body = getBody(getWindowTitle(header)); HtmlTree body = getBody(getWindowTitle(header));
Content h1Content = Text.of(header); Content h1Content = Text.of(header);
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, h1Content); HtmlStyles.title, h1Content);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
bodyContents.setHeader(getHeader(PageMode.SERIALIZED_FORM)) bodyContents.setHeader(getHeader(PageMode.SERIALIZED_FORM))
.addMainContent(div); .addMainContent(div);
return body; return body;
@ -575,7 +576,7 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
* @return the serialized form summaries header * @return the serialized form summaries header
*/ */
Content getSerializedSummariesHeader() { Content getSerializedSummariesHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
/** /**
@ -584,7 +585,7 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
* @return the package serialized form header tree * @return the package serialized form header tree
*/ */
Content getPackageSerializedHeader() { Content getPackageSerializedHeader() {
return HtmlTree.SECTION(HtmlStyle.serializedPackageContainer); return HtmlTree.SECTION(HtmlStyles.serializedPackageContainer);
} }
Content getPackageHeader(PackageElement packageElement) { Content getPackageHeader(PackageElement packageElement) {
@ -596,7 +597,7 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
} }
Content getClassSerializedHeader() { Content getClassSerializedHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
/** /**
@ -615,7 +616,7 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
? getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.PLAIN, typeElement) ? getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.PLAIN, typeElement)
.label(configuration.getClassName(typeElement))) .label(configuration.getClassName(typeElement)))
: Text.of(utils.getFullyQualifiedName(typeElement)); : Text.of(utils.getFullyQualifiedName(typeElement));
var section = HtmlTree.SECTION(HtmlStyle.serializedClassDetails) var section = HtmlTree.SECTION(HtmlStyles.serializedClassDetails)
.setId(htmlIds.forClass(typeElement)); .setId(htmlIds.forClass(typeElement));
Content superClassLink = typeElement.getSuperclass() != null Content superClassLink = typeElement.getSuperclass() != null
? getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, ? getLink(new HtmlLinkInfo(configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS,
@ -640,12 +641,12 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
signature.add(superClassLink); signature.add(superClassLink);
signature.add(" implements "); signature.add(" implements ");
signature.add(interfaceLink); signature.add(interfaceLink);
section.add(HtmlTree.DIV(HtmlStyle.typeSignature, signature)); section.add(HtmlTree.DIV(HtmlStyles.typeSignature, signature));
return section; return section;
} }
Content getSerialUIDInfoHeader() { Content getSerialUIDInfoHeader() {
return HtmlTree.DL(HtmlStyle.nameValue); return HtmlTree.DL(HtmlStyles.nameValue);
} }
/** /**
@ -667,7 +668,7 @@ public class SerializedFormWriter extends SubWriterHolderWriter {
} }
Content getClassContentHeader() { Content getClassContentHeader() {
return HtmlTree.UL(HtmlStyle.blockList); return HtmlTree.UL(HtmlStyles.blockList);
} }
/** /**

View File

@ -25,14 +25,12 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.doclet.DocletEnvironment; import java.util.ArrayList;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import java.util.List;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity; import java.util.Set;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import java.util.SortedSet;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import java.util.TreeSet;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import java.util.stream.Collectors;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind; import javax.lang.model.element.ElementKind;
@ -43,12 +41,16 @@ import javax.lang.model.element.RecordComponentElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementKindVisitor14; import javax.lang.model.util.ElementKindVisitor14;
import java.util.ArrayList;
import java.util.List; import jdk.javadoc.doclet.DocletEnvironment;
import java.util.Set; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import java.util.SortedSet; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import java.util.TreeSet; import jdk.javadoc.internal.html.Content;
import java.util.stream.Collectors; import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.ABSTRACT;
import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.FINAL;
@ -63,17 +65,17 @@ import static javax.lang.model.element.Modifier.SYNCHRONIZED;
public class Signatures { public class Signatures {
public static Content getModuleSignature(ModuleElement mdle, ModuleWriter moduleWriter) { public static Content getModuleSignature(ModuleElement mdle, ModuleWriter moduleWriter) {
var signature = HtmlTree.DIV(HtmlStyle.moduleSignature); var signature = HtmlTree.DIV(HtmlStyles.moduleSignature);
Content annotations = moduleWriter.getAnnotationInfo(mdle, true); Content annotations = moduleWriter.getAnnotationInfo(mdle, true);
if (!annotations.isEmpty()) { if (!annotations.isEmpty()) {
signature.add(HtmlTree.SPAN(HtmlStyle.annotations, annotations)); signature.add(HtmlTree.SPAN(HtmlStyles.annotations, annotations));
} }
DocletEnvironment docEnv = moduleWriter.configuration.docEnv; DocletEnvironment docEnv = moduleWriter.configuration.docEnv;
String label = mdle.isOpen() && (docEnv.getModuleMode() == DocletEnvironment.ModuleMode.ALL) String label = mdle.isOpen() && (docEnv.getModuleMode() == DocletEnvironment.ModuleMode.ALL)
? "open module" : "module"; ? "open module" : "module";
signature.add(label); signature.add(label);
signature.add(" "); signature.add(" ");
var nameSpan = HtmlTree.SPAN(HtmlStyle.elementName); var nameSpan = HtmlTree.SPAN(HtmlStyles.elementName);
nameSpan.add(mdle.getQualifiedName().toString()); nameSpan.add(mdle.getQualifiedName().toString());
signature.add(nameSpan); signature.add(nameSpan);
return signature; return signature;
@ -83,13 +85,13 @@ public class Signatures {
if (pkg.isUnnamed()) { if (pkg.isUnnamed()) {
return Text.EMPTY; return Text.EMPTY;
} }
var signature = HtmlTree.DIV(HtmlStyle.packageSignature); var signature = HtmlTree.DIV(HtmlStyles.packageSignature);
Content annotations = pkgWriter.getAnnotationInfo(pkg, true); Content annotations = pkgWriter.getAnnotationInfo(pkg, true);
if (!annotations.isEmpty()) { if (!annotations.isEmpty()) {
signature.add(HtmlTree.SPAN(HtmlStyle.annotations, annotations)); signature.add(HtmlTree.SPAN(HtmlStyles.annotations, annotations));
} }
signature.add("package "); signature.add("package ");
var nameSpan = HtmlTree.SPAN(HtmlStyle.elementName); var nameSpan = HtmlTree.SPAN(HtmlStyles.elementName);
nameSpan.add(pkg.getQualifiedName().toString()); nameSpan.add(pkg.getQualifiedName().toString());
signature.add(nameSpan); signature.add(nameSpan);
return signature; return signature;
@ -122,16 +124,16 @@ public class Signatures {
Content content = new ContentBuilder(); Content content = new ContentBuilder();
Content annotationInfo = writer.getAnnotationInfo(typeElement, true); Content annotationInfo = writer.getAnnotationInfo(typeElement, true);
if (!annotationInfo.isEmpty()) { if (!annotationInfo.isEmpty()) {
content.add(HtmlTree.SPAN(HtmlStyle.annotations, annotationInfo)); content.add(HtmlTree.SPAN(HtmlStyles.annotations, annotationInfo));
} }
content.add(HtmlTree.SPAN(HtmlStyle.modifiers, modifiers)); content.add(HtmlTree.SPAN(HtmlStyles.modifiers, modifiers));
var nameSpan = HtmlTree.SPAN(HtmlStyle.elementName); var nameSpan = HtmlTree.SPAN(HtmlStyles.elementName);
Content className = Text.of(utils.getSimpleName(typeElement)); Content className = Text.of(utils.getSimpleName(typeElement));
if (configuration.getOptions().linkSource()) { if (configuration.getOptions().linkSource()) {
writer.addSrcLink(typeElement, className, nameSpan); writer.addSrcLink(typeElement, className, nameSpan);
} else { } else {
nameSpan.addStyle(HtmlStyle.typeNameLabel).add(className); nameSpan.addStyle(HtmlStyles.typeNameLabel).add(className);
} }
HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration, HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement) HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement)
@ -144,7 +146,7 @@ public class Signatures {
content.add(getRecordComponents()); content.add(getRecordComponents());
} }
if (!utils.isAnnotationInterface(typeElement)) { if (!utils.isAnnotationInterface(typeElement)) {
var extendsImplements = HtmlTree.SPAN(HtmlStyle.extendsImplements); var extendsImplements = HtmlTree.SPAN(HtmlStyles.extendsImplements);
if (!utils.isPlainInterface(typeElement)) { if (!utils.isPlainInterface(typeElement)) {
TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement); TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement);
if (superclass != null) { if (superclass != null) {
@ -186,7 +188,7 @@ public class Signatures {
.filter(t -> utils.isLinkable(utils.asTypeElement(t))) .filter(t -> utils.isLinkable(utils.asTypeElement(t)))
.toList(); .toList();
if (!linkablePermits.isEmpty()) { if (!linkablePermits.isEmpty()) {
var permitsSpan = HtmlTree.SPAN(HtmlStyle.permits); var permitsSpan = HtmlTree.SPAN(HtmlStyles.permits);
boolean isFirst = true; boolean isFirst = true;
for (TypeMirror type : linkablePermits) { for (TypeMirror type : linkablePermits) {
if (isFirst) { if (isFirst) {
@ -205,11 +207,11 @@ public class Signatures {
if (linkablePermits.size() < permits.size()) { if (linkablePermits.size() < permits.size()) {
Content c = Text.of(configuration.getDocResources().getText("doclet.not.exhaustive")); Content c = Text.of(configuration.getDocResources().getText("doclet.not.exhaustive"));
permitsSpan.add(" "); permitsSpan.add(" ");
permitsSpan.add(HtmlTree.SPAN(HtmlStyle.permitsNote, c)); permitsSpan.add(HtmlTree.SPAN(HtmlStyles.permitsNote, c));
} }
content.add(permitsSpan); content.add(permitsSpan);
} }
return HtmlTree.DIV(HtmlStyle.typeSignature, content); return HtmlTree.DIV(HtmlStyles.typeSignature, content);
} }
private Content getRecordComponents() { private Content getRecordComponents() {
@ -450,7 +452,7 @@ public class Signatures {
// Annotations // Annotations
if (annotations != null && !annotations.isEmpty()) { if (annotations != null && !annotations.isEmpty()) {
content.add(HtmlTree.SPAN(HtmlStyle.annotations, annotations)); content.add(HtmlTree.SPAN(HtmlStyles.annotations, annotations));
lastLineSeparator = content.charCount(); lastLineSeparator = content.charCount();
} }
@ -464,12 +466,12 @@ public class Signatures {
// Return type // Return type
if (returnType != null) { if (returnType != null) {
content.add(HtmlTree.SPAN(HtmlStyle.returnType, returnType)); content.add(HtmlTree.SPAN(HtmlStyles.returnType, returnType));
content.add(Entity.NO_BREAK_SPACE); content.add(Entity.NO_BREAK_SPACE);
} }
// Name // Name
var nameSpan = HtmlTree.SPAN(HtmlStyle.elementName); var nameSpan = HtmlTree.SPAN(HtmlStyles.elementName);
if (memberWriter.options.linkSource()) { if (memberWriter.options.linkSource()) {
Content name = Text.of(memberWriter.name(element)); Content name = Text.of(memberWriter.name(element));
memberWriter.writer.addSrcLink(element, name, nameSpan); memberWriter.writer.addSrcLink(element, name, nameSpan);
@ -483,7 +485,7 @@ public class Signatures {
appendParametersAndExceptions(content, lastLineSeparator); appendParametersAndExceptions(content, lastLineSeparator);
} }
return HtmlTree.DIV(HtmlStyle.memberSignature, content); return HtmlTree.DIV(HtmlStyles.memberSignature, content);
} }
/** /**
@ -514,7 +516,7 @@ public class Signatures {
} }
if (!set.isEmpty()) { if (!set.isEmpty()) {
String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" ")); String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
target.add(HtmlTree.SPAN(HtmlStyle.modifiers, Text.of(mods))) target.add(HtmlTree.SPAN(HtmlStyles.modifiers, Text.of(mods)))
.add(Entity.NO_BREAK_SPACE); .add(Entity.NO_BREAK_SPACE);
} }
} }
@ -533,9 +535,9 @@ public class Signatures {
int typeParamLength = typeParameters.charCount(); int typeParamLength = typeParameters.charCount();
if (typeParamLength >= TYPE_PARAMS_MAX_INLINE_LENGTH) { if (typeParamLength >= TYPE_PARAMS_MAX_INLINE_LENGTH) {
target.add(HtmlTree.SPAN(HtmlStyle.typeParametersLong, typeParameters)); target.add(HtmlTree.SPAN(HtmlStyles.typeParametersLong, typeParameters));
} else { } else {
target.add(HtmlTree.SPAN(HtmlStyle.typeParameters, typeParameters)); target.add(HtmlTree.SPAN(HtmlStyles.typeParameters, typeParameters));
} }
int lineLength = target.charCount() - lastLineSeparator; int lineLength = target.charCount() - lastLineSeparator;
@ -567,8 +569,8 @@ public class Signatures {
// empty parameters are added without packing // empty parameters are added without packing
target.add(parameters); target.add(parameters);
} else { } else {
target.add(new HtmlTree(TagName.WBR)) target.add(new HtmlTree(HtmlTag.WBR))
.add(HtmlTree.SPAN(HtmlStyle.parameters, parameters)); .add(HtmlTree.SPAN(HtmlStyles.parameters, parameters));
} }
// Exceptions // Exceptions
@ -577,7 +579,7 @@ public class Signatures {
target.add(Text.NL) target.add(Text.NL)
.add(indent) .add(indent)
.add("throws ") .add("throws ")
.add(HtmlTree.SPAN(HtmlStyle.exceptions, exceptions)); .add(HtmlTree.SPAN(HtmlStyles.exceptions, exceptions));
} }
} }
} }

View File

@ -25,8 +25,6 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import java.io.IOException; import java.io.IOException;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.io.Reader; import java.io.Reader;
@ -38,12 +36,9 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.tools.FileObject; import javax.tools.FileObject;
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@ -52,6 +47,11 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Converts Java Source Code to HTML. * Converts Java Source Code to HTML.
@ -201,7 +201,7 @@ public class SourceToHTMLConverter {
.resolve(configuration.docPaths.forPackage(te)) .resolve(configuration.docPaths.forPackage(te))
.invert(); .invert();
Content body = getHeader(); Content body = getHeader();
var pre = new HtmlTree(TagName.PRE); var pre = new HtmlTree(HtmlTag.PRE);
try (var reader = new LineNumberReader(r)) { try (var reader = new LineNumberReader(r)) {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
addLineNo(pre, lineno); addLineNo(pre, lineno);
@ -210,7 +210,7 @@ public class SourceToHTMLConverter {
} }
} }
addBlankLines(pre); addBlankLines(pre);
var div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre); var div = HtmlTree.DIV(HtmlStyles.sourceContainer, pre);
body.add(HtmlTree.MAIN(div)); body.add(HtmlTree.MAIN(div));
writeToFile(body, outputdir.resolve(configuration.docPaths.forClass(te)), te); writeToFile(body, outputdir.resolve(configuration.docPaths.forClass(te)), te);
} catch (IOException e) { } catch (IOException e) {
@ -246,7 +246,7 @@ public class SourceToHTMLConverter {
* @return the header content for the HTML file * @return the header content for the HTML file
*/ */
private static Content getHeader() { private static Content getHeader() {
return new HtmlTree(TagName.BODY).setStyle(HtmlStyle.sourcePage); return new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.sourcePage);
} }
/** /**
@ -256,7 +256,7 @@ public class SourceToHTMLConverter {
* @param lineno The line number * @param lineno The line number
*/ */
private static void addLineNo(Content pre, int lineno) { private static void addLineNo(Content pre, int lineno) {
var span = HtmlTree.SPAN(HtmlStyle.sourceLineNo); var span = HtmlTree.SPAN(HtmlStyles.sourceLineNo);
if (lineno < 10) { if (lineno < 10) {
span.add("00" + lineno); span.add("00" + lineno);
} else if (lineno < 100) { } else if (lineno < 100) {

View File

@ -25,20 +25,23 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.util.*; import java.util.List;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DeprecatedTree; import com.sun.source.doctree.DeprecatedTree;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.toolkit.PropertyUtils; import jdk.javadoc.internal.doclets.toolkit.PropertyUtils;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* This abstract class exists to provide functionality needed in the * This abstract class exists to provide functionality needed in the
@ -117,8 +120,8 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(member); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(member);
Content div; Content div;
if (utils.isDeprecated(member)) { if (utils.isDeprecated(member)) {
var deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(member)); var deprLabel = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(member));
div = HtmlTree.DIV(HtmlStyle.block, deprLabel); div = HtmlTree.DIV(HtmlStyles.block, deprLabel);
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
addSummaryDeprecatedComment(member, deprs.get(0), div); addSummaryDeprecatedComment(member, deprs.get(0), div);
} }
@ -127,8 +130,8 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
} else { } else {
Element te = member.getEnclosingElement(); Element te = member.getEnclosingElement();
if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) { if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) {
var deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(te)); var deprLabel = HtmlTree.SPAN(HtmlStyles.deprecatedLabel, getDeprecatedPhrase(te));
div = HtmlTree.DIV(HtmlStyle.block, deprLabel); div = HtmlTree.DIV(HtmlStyles.block, deprLabel);
tdSummaryContent.add(div); tdSummaryContent.add(div);
} }
} }
@ -200,7 +203,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
* @return a list to be used for the list of summaries for members of a given kind * @return a list to be used for the list of summaries for members of a given kind
*/ */
public Content getSummariesList() { public Content getSummariesList() {
return HtmlTree.UL(HtmlStyle.summaryList); return HtmlTree.UL(HtmlStyles.summaryList);
} }
/** /**
@ -219,7 +222,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
* @return a list to be used for the list of details for members of a given kind * @return a list to be used for the list of details for members of a given kind
*/ */
public Content getDetailsList() { public Content getDetailsList() {
return HtmlTree.UL(HtmlStyle.detailsList); return HtmlTree.UL(HtmlStyles.detailsList);
} }
/** /**
@ -236,7 +239,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
* {@return a list to add member items to} * {@return a list to add member items to}
*/ */
public Content getMemberList() { public Content getMemberList() {
return HtmlTree.UL(HtmlStyle.memberList); return HtmlTree.UL(HtmlStyles.memberList);
} }
/** /**
@ -249,7 +252,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
} }
public Content getMemberInherited() { public Content getMemberInherited() {
return HtmlTree.DIV(HtmlStyle.inheritedList); return HtmlTree.DIV(HtmlStyles.inheritedList);
} }
/** /**
@ -281,7 +284,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
* @param memberContent the content used to generate the member summary * @param memberContent the content used to generate the member summary
*/ */
public Content getMemberSummary(Content memberContent) { public Content getMemberSummary(Content memberContent) {
return HtmlTree.SECTION(HtmlStyle.summary, memberContent); return HtmlTree.SECTION(HtmlStyles.summary, memberContent);
} }
/** /**

View File

@ -31,18 +31,20 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder.SummaryElementKind; import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder.SummaryElementKind;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Script;
import jdk.javadoc.internal.html.Text;
/** /**
* Base class for generating a summary page that lists elements with a common characteristic, * Base class for generating a summary page that lists elements with a common characteristic,
@ -139,8 +141,8 @@ public abstract class SummaryListWriter<B extends SummaryAPIListBuilder> extends
HtmlTree body = getHeader(getPageMode(), getTitleKey()); HtmlTree body = getHeader(getPageMode(), getTitleKey());
Content content = new ContentBuilder(); Content content = new ContentBuilder();
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, getHeadContent()); HtmlStyles.title, getHeadContent());
content.add(HtmlTree.DIV(HtmlStyle.header, heading)); content.add(HtmlTree.DIV(HtmlStyles.header, heading));
addContentSelectors(content); addContentSelectors(content);
if (showContentsList()) { if (showContentsList()) {
content.add(HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING, contents.contentsHeading)); content.add(HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING, contents.contentsHeading));
@ -201,7 +203,7 @@ public abstract class SummaryListWriter<B extends SummaryAPIListBuilder> extends
* @return the contents list * @return the contents list
*/ */
public Content getContentsList() { public Content getContentsList() {
var ul= HtmlTree.UL(HtmlStyle.contentsList); var ul= HtmlTree.UL(HtmlStyles.contentsList);
addExtraIndexLink(ul); addExtraIndexLink(ul);
for (SummaryElementKind kind : SummaryElementKind.values()) { for (SummaryElementKind kind : SummaryElementKind.values()) {
if (builder.hasDocumentation(kind)) { if (builder.hasDocumentation(kind)) {
@ -238,7 +240,7 @@ public abstract class SummaryListWriter<B extends SummaryAPIListBuilder> extends
if (apiList.size() > 0) { if (apiList.size() > 0) {
TableHeader tableHeader = getTableHeader(headerKey); TableHeader tableHeader = getTableHeader(headerKey);
var table = new Table<Element>(HtmlStyle.summaryTable) var table = new Table<Element>(HtmlStyles.summaryTable)
.setCaption(getTableCaption(headingKey)) .setCaption(getTableCaption(headingKey))
.setHeader(tableHeader) .setHeader(tableHeader)
.setId(id) .setId(id)
@ -267,7 +269,7 @@ public abstract class SummaryListWriter<B extends SummaryAPIListBuilder> extends
} }
} }
// note: singleton list // note: singleton list
content.add(HtmlTree.UL(HtmlStyle.blockList, HtmlTree.LI(table))); content.add(HtmlTree.UL(HtmlStyles.blockList, HtmlTree.LI(table)));
} }
} }
@ -370,7 +372,7 @@ public abstract class SummaryListWriter<B extends SummaryAPIListBuilder> extends
* @return the styles to use for table columns * @return the styles to use for table columns
*/ */
protected HtmlStyle[] getColumnStyles() { protected HtmlStyle[] getColumnStyles() {
return new HtmlStyle[]{ HtmlStyle.colSummaryItemName, HtmlStyle.colLast }; return new HtmlStyle[]{ HtmlStyles.colSummaryItemName, HtmlStyles.colLast };
} }
/** /**

View File

@ -38,15 +38,16 @@ import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents; import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.DocFileElement; import jdk.javadoc.internal.doclets.toolkit.DocFileElement;
import jdk.javadoc.internal.doclets.toolkit.OverviewElement; import jdk.javadoc.internal.doclets.toolkit.OverviewElement;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.groupingBy;
@ -86,7 +87,7 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
addSystemProperties(mainContent); addSystemProperties(mainContent);
body.add(new BodyContents() body.add(new BodyContents()
.setHeader(getHeader(PageMode.SYSTEM_PROPERTIES)) .setHeader(getHeader(PageMode.SYSTEM_PROPERTIES))
.addMainContent(HtmlTree.DIV(HtmlStyle.header, .addMainContent(HtmlTree.DIV(HtmlStyles.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.systemProperties")))) contents.getContent("doclet.systemProperties"))))
.addMainContent(mainContent) .addMainContent(mainContent)
@ -106,10 +107,10 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
protected void addSystemProperties(Content target) { protected void addSystemProperties(Content target) {
Map<String, List<IndexItem>> searchIndexMap = groupSystemProperties(); Map<String, List<IndexItem>> searchIndexMap = groupSystemProperties();
Content separator = Text.of(", "); Content separator = Text.of(", ");
var table = new Table<Void>(HtmlStyle.summaryTable) var table = new Table<Void>(HtmlStyles.summaryTable)
.setCaption(contents.systemPropertiesSummaryLabel) .setCaption(contents.systemPropertiesSummaryLabel)
.setHeader(new TableHeader(contents.propertyLabel, contents.referencedIn)) .setHeader(new TableHeader(contents.propertyLabel, contents.referencedIn))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast);
for (Entry<String, List<IndexItem>> entry : searchIndexMap.entrySet()) { for (Entry<String, List<IndexItem>> entry : searchIndexMap.entrySet()) {
Content propertyName = Text.of(entry.getKey()); Content propertyName = Text.of(entry.getKey());
List<IndexItem> searchIndexItems = entry.getValue(); List<IndexItem> searchIndexItems = entry.getValue();
@ -119,7 +120,7 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
separatedReferenceLinks.add(separator); separatedReferenceLinks.add(separator);
separatedReferenceLinks.add(createLink(searchIndexItems.get(i))); separatedReferenceLinks.add(createLink(searchIndexItems.get(i)));
} }
table.addRow(propertyName, HtmlTree.DIV(HtmlStyle.block, separatedReferenceLinks)); table.addRow(propertyName, HtmlTree.DIV(HtmlStyles.block, separatedReferenceLinks));
} }
target.add(table); target.add(table);
} }

View File

@ -34,13 +34,15 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId; import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName; import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* An HTML container used to display summary tables for various kinds of elements * An HTML container used to display summary tables for various kinds of elements
@ -303,7 +305,7 @@ public class Table<T> extends Content {
Content row = new ContentBuilder(); Content row = new ContentBuilder();
int rowIndex = bodyRows.size(); int rowIndex = bodyRows.size();
HtmlStyle rowStyle = rowIndex % 2 == 0 ? HtmlStyle.evenRowColor : HtmlStyle.oddRowColor; HtmlStyle rowStyle = rowIndex % 2 == 0 ? HtmlStyles.evenRowColor : HtmlStyles.oddRowColor;
List<String> tabClasses = new ArrayList<>(); List<String> tabClasses = new ArrayList<>();
if (tabs != null) { if (tabs != null) {
@ -359,16 +361,16 @@ public class Table<T> extends Content {
private Content toContent() { private Content toContent() {
Content main; Content main;
if (id != null) { if (id != null) {
main = new HtmlTree(TagName.DIV).setId(id); main = new HtmlTree(HtmlTag.DIV).setId(id);
} else { } else {
main = new ContentBuilder(); main = new ContentBuilder();
} }
// If no grid style is set use on of the default styles // If no grid style is set use on of the default styles
if (gridStyle == null) { if (gridStyle == null) {
gridStyle = switch (columnStyles.size()) { gridStyle = switch (columnStyles.size()) {
case 2 -> HtmlStyle.twoColumnSummary; case 2 -> HtmlStyles.twoColumnSummary;
case 3 -> HtmlStyle.threeColumnSummary; case 3 -> HtmlStyles.threeColumnSummary;
case 4 -> HtmlStyle.fourColumnSummary; case 4 -> HtmlStyles.fourColumnSummary;
default -> throw new IllegalStateException(); default -> throw new IllegalStateException();
}; };
} }
@ -383,16 +385,16 @@ public class Table<T> extends Content {
table.add(getTableBody()); table.add(getTableBody());
main.add(table); main.add(table);
} else { } else {
var tablist = HtmlTree.DIV(HtmlStyle.tableTabs) var tablist = HtmlTree.DIV(HtmlStyles.tableTabs)
.put(HtmlAttr.ROLE, "tablist") .put(HtmlAttr.ROLE, "tablist")
.put(HtmlAttr.ARIA_ORIENTATION, "horizontal"); .put(HtmlAttr.ARIA_ORIENTATION, "horizontal");
HtmlId defaultTabId = HtmlIds.forTab(id, 0); HtmlId defaultTabId = HtmlIds.forTab(id, 0);
if (renderTabs) { if (renderTabs) {
tablist.add(createTab(defaultTabId, HtmlStyle.activeTableTab, true, defaultTab)); tablist.add(createTab(defaultTabId, HtmlStyles.activeTableTab, true, defaultTab));
for (var tab : tabs) { for (var tab : tabs) {
if (occurringTabs.contains(tab)) { if (occurringTabs.contains(tab)) {
tablist.add(createTab(HtmlIds.forTab(id, tab.index()), HtmlStyle.tableTab, false, tab.label())); tablist.add(createTab(HtmlIds.forTab(id, tab.index()), HtmlStyles.tableTab, false, tab.label()));
} }
} }
} else { } else {
@ -401,7 +403,7 @@ public class Table<T> extends Content {
if (id == null) { if (id == null) {
throw new IllegalStateException("no id set for table"); throw new IllegalStateException("no id set for table");
} }
var tabpanel = new HtmlTree(TagName.DIV) var tabpanel = new HtmlTree(HtmlTag.DIV)
.setId(HtmlIds.forTabPanel(id)) .setId(HtmlIds.forTabPanel(id))
.put(HtmlAttr.ROLE, "tabpanel") .put(HtmlAttr.ROLE, "tabpanel")
.put(HtmlAttr.ARIA_LABELLEDBY, defaultTabId.name()); .put(HtmlAttr.ARIA_LABELLEDBY, defaultTabId.name());
@ -414,7 +416,7 @@ public class Table<T> extends Content {
} }
private HtmlTree createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel) { private HtmlTree createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel) {
var tab = new HtmlTree(TagName.BUTTON) var tab = new HtmlTree(HtmlTag.BUTTON)
.setId(tabId) .setId(tabId)
.put(HtmlAttr.ROLE, "tab") .put(HtmlAttr.ROLE, "tab")
.put(HtmlAttr.ARIA_SELECTED, defaultTab ? "true" : "false") .put(HtmlAttr.ARIA_SELECTED, defaultTab ? "true" : "false")
@ -436,6 +438,6 @@ public class Table<T> extends Content {
} }
private HtmlTree getCaption(Content title) { private HtmlTree getCaption(Content title) {
return HtmlTree.DIV(HtmlStyle.caption, HtmlTree.SPAN(title)); return HtmlTree.DIV(HtmlStyles.caption, HtmlTree.SPAN(title));
} }
} }

View File

@ -30,10 +30,12 @@ import java.io.Writer;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* A row of header cells for an HTML table. * A row of header cells for an HTML table.
@ -152,10 +154,10 @@ public class TableHeader extends Content {
int i = 0; int i = 0;
for (Content cellContent : cellContents) { for (Content cellContent : cellContents) {
HtmlStyle style = (styles != null) ? styles.get(i) HtmlStyle style = (styles != null) ? styles.get(i)
: (i == 0) ? HtmlStyle.colFirst : (i == 0) ? HtmlStyles.colFirst
: (i == (cellContents.size() - 1)) ? HtmlStyle.colLast : (i == (cellContents.size() - 1)) ? HtmlStyles.colLast
: (i == 1) ? HtmlStyle.colSecond : null; : (i == 1) ? HtmlStyles.colSecond : null;
var cell = HtmlTree.DIV(HtmlStyle.tableHeader, cellContent); var cell = HtmlTree.DIV(HtmlStyles.tableHeader, cellContent);
if (style != null) { if (style != null) {
cell.addStyle(style); cell.addStyle(style);
} }

View File

@ -24,14 +24,15 @@
*/ */
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId; import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.ListBuilder; import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName; import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.html.ListBuilder;
import jdk.javadoc.internal.html.Text;
/** /**
* A class used by various {@link HtmlDocletWriter} subclasses to build tables of contents. * A class used by various {@link HtmlDocletWriter} subclasses to build tables of contents.
@ -46,7 +47,7 @@ public class TableOfContents {
*/ */
public TableOfContents(HtmlDocletWriter writer) { public TableOfContents(HtmlDocletWriter writer) {
this.writer = writer; this.writer = writer;
listBuilder = new ListBuilder(HtmlTree.OL(HtmlStyle.tocList)); listBuilder = new ListBuilder(HtmlTree.OL(HtmlStyles.tocList));
} }
/** /**
@ -64,7 +65,7 @@ public class TableOfContents {
* Adds a new nested list to add new items to. * Adds a new nested list to add new items to.
*/ */
public void pushNestedList() { public void pushNestedList() {
listBuilder.pushNestedList(HtmlTree.OL(HtmlStyle.tocList)); listBuilder.pushNestedList(HtmlTree.OL(HtmlStyles.tocList));
} }
/** /**
@ -87,23 +88,23 @@ public class TableOfContents {
return Text.EMPTY; return Text.EMPTY;
} }
var content = HtmlTree.NAV() var content = HtmlTree.NAV()
.setStyle(HtmlStyle.toc) .setStyle(HtmlStyles.toc)
.put(HtmlAttr.ARIA_LABEL, writer.resources.getText("doclet.table_of_contents")); .put(HtmlAttr.ARIA_LABEL, writer.resources.getText("doclet.table_of_contents"));
var header = HtmlTree.DIV(HtmlStyle.tocHeader, writer.contents.contentsHeading); var header = HtmlTree.DIV(HtmlStyles.tocHeader, writer.contents.contentsHeading);
if (hasFilterInput) { if (hasFilterInput) {
header.add(Entity.NO_BREAK_SPACE) header.add(Entity.NO_BREAK_SPACE)
.add(HtmlTree.INPUT(HtmlAttr.InputType.TEXT, HtmlStyle.filterInput) .add(HtmlTree.INPUT(HtmlAttr.InputType.TEXT, HtmlStyles.filterInput)
.put(HtmlAttr.PLACEHOLDER, writer.resources.getText("doclet.filter_label")) .put(HtmlAttr.PLACEHOLDER, writer.resources.getText("doclet.filter_label"))
.put(HtmlAttr.ARIA_LABEL, writer.resources.getText("doclet.filter_table_of_contents")) .put(HtmlAttr.ARIA_LABEL, writer.resources.getText("doclet.filter_table_of_contents"))
.put(HtmlAttr.AUTOCOMPLETE, "off")) .put(HtmlAttr.AUTOCOMPLETE, "off"))
.add(HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlStyle.resetFilter) .add(HtmlTree.INPUT(HtmlAttr.InputType.RESET, HtmlStyles.resetFilter)
.put(HtmlAttr.VALUE, writer.resources.getText("doclet.filter_reset"))); .put(HtmlAttr.VALUE, writer.resources.getText("doclet.filter_reset")));
} }
content.add(header); content.add(header);
content.add(new HtmlTree(TagName.BUTTON).addStyle(HtmlStyle.hideSidebar) content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.hideSidebar)
.add(HtmlTree.SPAN(writer.contents.hideSidebar).add(Entity.NO_BREAK_SPACE)) .add(HtmlTree.SPAN(writer.contents.hideSidebar).add(Entity.NO_BREAK_SPACE))
.add(Entity.LEFT_POINTING_ANGLE)); .add(Entity.LEFT_POINTING_ANGLE));
content.add(new HtmlTree(TagName.BUTTON).addStyle(HtmlStyle.showSidebar) content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.showSidebar)
.add(Entity.RIGHT_POINTING_ANGLE) .add(Entity.RIGHT_POINTING_ANGLE)
.add(HtmlTree.SPAN(Entity.NO_BREAK_SPACE).add(writer.contents.showSidebar))); .add(HtmlTree.SPAN(Entity.NO_BREAK_SPACE).add(writer.contents.showSidebar)));
return content.add(listBuilder); return content.add(listBuilder);

View File

@ -29,15 +29,16 @@ import java.util.SortedSet;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* Generate Class Hierarchy page for all the Classes in this run. Use * Generate Class Hierarchy page for all the Classes in this run. Use
@ -78,8 +79,8 @@ public class TreeWriter extends AbstractTreeWriter {
HtmlTree body = getBody(); HtmlTree body = getBody();
Content headContent = contents.hierarchyForAllPackages; Content headContent = contents.hierarchyForAllPackages;
var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, var heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headContent); HtmlStyles.title, headContent);
var div = HtmlTree.DIV(HtmlStyle.header, heading); var div = HtmlTree.DIV(HtmlStyles.header, heading);
Content mainContent = new ContentBuilder(); Content mainContent = new ContentBuilder();
mainContent.add(div); mainContent.add(div);
addPackageTreeLinks(mainContent); addPackageTreeLinks(mainContent);
@ -105,10 +106,10 @@ public class TreeWriter extends AbstractTreeWriter {
return; return;
} }
if (!classesOnly) { if (!classesOnly) {
var span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, var span = HtmlTree.SPAN(HtmlStyles.packageHierarchyLabel,
contents.packageHierarchies); contents.packageHierarchies);
content.add(span); content.add(span);
var ul = HtmlTree.UL(HtmlStyle.horizontal).addStyle(HtmlStyle.contentsList); var ul = HtmlTree.UL(HtmlStyles.horizontal).addStyle(HtmlStyles.contentsList);
int i = 0; int i = 0;
for (PackageElement pkg : packages) { for (PackageElement pkg : packages) {
// If the package name length is 0 or if -nodeprecated option // If the package name length is 0 or if -nodeprecated option

View File

@ -25,14 +25,17 @@
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.doclets.formats.html.markup;
import jdk.javadoc.internal.doclets.formats.html.Content;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Content for the {@code <body>} element. * Content for the {@code <body>} element.
* *
@ -96,7 +99,7 @@ public class BodyContents extends Content {
return new ContentBuilder() return new ContentBuilder()
.add(header) .add(header)
.add(HtmlTree.DIV(HtmlStyle.mainGrid) .add(HtmlTree.DIV(HtmlStyles.mainGrid)
.add(side == null ? Text.EMPTY : side) .add(side == null ? Text.EMPTY : side)
.add(HtmlTree.MAIN() .add(HtmlTree.MAIN()
.add(mainContents) .add(mainContents)

View File

@ -34,10 +34,15 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.html.Comment;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Script;
/** /**
* An HTML {@code <head>} element. * An HTML {@code <head>} element.
@ -267,7 +272,7 @@ public class Head extends Content {
* @return the HTML * @return the HTML
*/ */
private Content toContent() { private Content toContent() {
var head = new HtmlTree(TagName.HEAD); var head = new HtmlTree(HtmlTag.HEAD);
head.add(getGeneratedBy(showTimestamp, generatedDate)); head.add(getGeneratedBy(showTimestamp, generatedDate));
head.add(HtmlTree.TITLE(title)); head.add(HtmlTree.TITLE(title));
@ -295,7 +300,7 @@ public class Head extends Content {
} }
if (canonicalLink != null) { if (canonicalLink != null) {
var link = new HtmlTree(TagName.LINK); var link = new HtmlTree(HtmlTag.LINK);
link.put(HtmlAttr.REL, "canonical"); link.put(HtmlAttr.REL, "canonical");
link.put(HtmlAttr.HREF, canonicalLink.getPath()); link.put(HtmlAttr.HREF, canonicalLink.getPath());
head.add(link); head.add(link);

View File

@ -1,123 +0,0 @@
/*
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.javadoc.internal.doclets.formats.html.markup;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
/**
* Enum representing HTML tag attributes.
*/
public enum HtmlAttr {
ALT,
ARIA_CONTROLS("aria-controls"),
ARIA_EXPANDED("aria-expanded"),
ARIA_LABEL("aria-label"),
ARIA_LABELLEDBY("aria-labelledby"),
ARIA_ORIENTATION("aria-orientation"),
ARIA_SELECTED("aria-selected"),
AUTOCOMPLETE,
CHECKED,
CLASS,
CLEAR,
COLS,
CONTENT,
DATA_COPIED("data-copied"), // custom HTML5 data attribute
DISABLED,
FOR,
HREF,
HTTP_EQUIV("http-equiv"),
ID,
LANG,
NAME,
ONCLICK,
ONKEYDOWN,
ONLOAD,
PLACEHOLDER,
REL,
ROLE,
ROWS,
SCOPE,
SCROLLING,
SRC,
STYLE,
SUMMARY,
TABINDEX,
TARGET,
TITLE,
TYPE,
VALUE,
WIDTH;
private final String value;
public enum Role {
BANNER,
CONTENTINFO,
MAIN,
NAVIGATION,
REGION;
private final String role;
Role() {
role = Utils.toLowerCase(name());
}
public String toString() {
return role;
}
}
public enum InputType {
CHECKBOX,
RESET,
TEXT;
private final String type;
InputType() {
type = Utils.toLowerCase(name());
}
public String toString() {
return type;
}
}
HtmlAttr() {
this.value = Utils.toLowerCase(name());
}
HtmlAttr(String name) {
this.value = name;
}
public String toString() {
return value;
}
}

View File

@ -29,9 +29,11 @@ import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.DocType;
import jdk.javadoc.internal.html.HtmlTag;
/** /**
* Class for generating an HTML document for javadoc output. * Class for generating an HTML document for javadoc output.
@ -43,7 +45,7 @@ public class HtmlDocument {
/** /**
* Constructs an HTML document. * Constructs an HTML document.
* *
* @param html the {@link TagName#HTML HTML} element of the document * @param html the {@link HtmlTag#HTML HTML} element of the document
*/ */
public HtmlDocument(Content html) { public HtmlDocument(Content html) {
docContent = html; docContent = html;

View File

@ -28,6 +28,8 @@ package jdk.javadoc.internal.doclets.formats.html.markup;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import jdk.javadoc.internal.html.HtmlStyle;
/** /**
* Enum representing HTML styles, with associated entries in the stylesheet files. * Enum representing HTML styles, with associated entries in the stylesheet files.
* *
@ -49,7 +51,7 @@ import java.util.regex.Pattern;
* *
* @see <a href="https://html.spec.whatwg.org/#classes">WhatWG: {@code class} attribute</a> * @see <a href="https://html.spec.whatwg.org/#classes">WhatWG: {@code class} attribute</a>
*/ */
public enum HtmlStyle { public enum HtmlStyles implements HtmlStyle {
//<editor-fold desc="navigation bar"> //<editor-fold desc="navigation bar">
// //
@ -1098,13 +1100,13 @@ public enum HtmlStyle {
private final String cssName; private final String cssName;
HtmlStyle() { HtmlStyles() {
cssName = Pattern.compile("\\p{Upper}") cssName = Pattern.compile("\\p{Upper}")
.matcher(toString()) .matcher(toString())
.replaceAll(mr -> "-" + mr.group().toLowerCase(Locale.US)); .replaceAll(mr -> "-" + mr.group().toLowerCase(Locale.US));
} }
HtmlStyle(String cssName) { HtmlStyles(String cssName) {
this.cssName = cssName; this.cssName = cssName;
} }

View File

@ -25,9 +25,14 @@
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.doclets.formats.html.markup;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Factory for HTML A elements: links (with a {@code href} attribute). * Factory for HTML A elements: links (with a {@code href} attribute).
@ -197,7 +202,7 @@ public class Links {
} }
if (isExternal) { if (isExternal) {
// Use addStyle as external links might have an explicit style set above as well. // Use addStyle as external links might have an explicit style set above as well.
l.addStyle(HtmlStyle.externalLink); l.addStyle(HtmlStyles.externalLink);
} }
return l; return l;
} }
@ -211,6 +216,6 @@ public class Links {
*/ */
public HtmlTree createExternalLink(DocLink link, Content label) { public HtmlTree createExternalLink(DocLink link, Content label) {
return HtmlTree.A(link.relativizeAgainst(file).toString(), label) return HtmlTree.A(link.relativizeAgainst(file).toString(), label)
.setStyle(HtmlStyle.externalLink); .setStyle(HtmlStyles.externalLink);
} }
} }

View File

@ -1,118 +0,0 @@
/*
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.javadoc.internal.doclets.formats.html.markup;
import java.util.Locale;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
/**
* Enum representing the names for HTML elements.
*
* @see <a href="https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-name">WhatWG: Tag Name</a>
* @see <a href="https://www.w3.org/TR/html51/syntax.html#tag-name">HTML 5.1: Tag Name</a>
*/
public enum TagName {
A(true),
ASIDE,
BUTTON(true),
BLOCKQUOTE,
BODY,
BR(true),
CAPTION,
CODE(true),
DD,
DETAILS,
DIV,
DL,
DT,
EM(true),
FOOTER,
FORM,
H1,
H2,
H3,
H4,
H5,
H6,
HEAD,
HEADER,
HR,
HTML,
I(true),
IMG(true),
INPUT(true),
LABEL(true),
LI,
LISTING,
LINK(true),
MAIN,
MENU,
META,
NAV,
NOSCRIPT(true),
OL,
P,
PRE,
SCRIPT(true),
SECTION,
SMALL(true),
SPAN(true),
STRONG(true),
SUB(true),
SUMMARY,
SUP(true),
TABLE,
TBODY,
THEAD,
TD,
TH,
TITLE,
TR,
UL,
WBR(true);
public final String value;
public final boolean phrasingContent;
static TagName of(String s) {
return valueOf(s.toUpperCase(Locale.ROOT));
}
TagName() {
this(false);
}
TagName(boolean phrasingContent) {
this.value = Utils.toLowerCase(name());
this.phrasingContent = phrasingContent;
}
public String toString() {
return value;
}
}

View File

@ -27,7 +27,7 @@
* This package contains classes that create and write HTML markup tags. * This package contains classes that create and write HTML markup tags.
* *
* <p>The primary low level classes are * <p>The primary low level classes are
* {@link jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree HtmlTree} * {@link jdk.javadoc.internal.html.HtmlTree HtmlTree}
* and other subtypes of {@code Content}. In addition, there are mid-level builders * and other subtypes of {@code Content}. In addition, there are mid-level builders
* like {@link jdk.javadoc.internal.doclets.formats.html.TableHeader TableHeader} * like {@link jdk.javadoc.internal.doclets.formats.html.TableHeader TableHeader}
* and {@link jdk.javadoc.internal.doclets.formats.html.Table Table} * and {@link jdk.javadoc.internal.doclets.formats.html.Table Table}

View File

@ -33,10 +33,10 @@ import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.Taglet.Location; import jdk.javadoc.doclet.Taglet.Location;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
/** /**
* A base class that implements the {@link Taglet} interface. * A base class that implements the {@link Taglet} interface.

View File

@ -35,11 +35,11 @@ import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* A taglet that represents the {@code @deprecated} tag. * A taglet that represents the {@code @deprecated} tag.
@ -61,7 +61,7 @@ public class DeprecatedTaglet extends BaseTaglet {
List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(element); List<? extends DeprecatedTree> deprs = utils.getDeprecatedTrees(element);
if (utils.isTypeElement(element)) { if (utils.isTypeElement(element)) {
if (utils.isDeprecated(element)) { if (utils.isDeprecated(element)) {
result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, result.add(HtmlTree.SPAN(HtmlStyles.deprecatedLabel,
htmlWriter.getDeprecatedPhrase(element))); htmlWriter.getDeprecatedPhrase(element)));
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
List<? extends DocTree> commentTrees = ch.getDescription(deprs.get(0)); List<? extends DocTree> commentTrees = ch.getDescription(deprs.get(0));
@ -72,18 +72,18 @@ public class DeprecatedTaglet extends BaseTaglet {
} }
} else { } else {
if (utils.isDeprecated(element)) { if (utils.isDeprecated(element)) {
result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, result.add(HtmlTree.SPAN(HtmlStyles.deprecatedLabel,
htmlWriter.getDeprecatedPhrase(element))); htmlWriter.getDeprecatedPhrase(element)));
if (!deprs.isEmpty()) { if (!deprs.isEmpty()) {
List<? extends DocTree> bodyTrees = ch.getBody(deprs.get(0)); List<? extends DocTree> bodyTrees = ch.getBody(deprs.get(0));
Content body = tagletWriter.commentTagsToOutput(element, null, bodyTrees, false); Content body = tagletWriter.commentTagsToOutput(element, null, bodyTrees, false);
if (!body.isEmpty()) if (!body.isEmpty())
result.add(HtmlTree.DIV(HtmlStyle.deprecationComment, body)); result.add(HtmlTree.DIV(HtmlStyles.deprecationComment, body));
} }
} else { } else {
Element ee = utils.getEnclosingTypeElement(element); Element ee = utils.getEnclosingTypeElement(element);
if (utils.isDeprecated(ee)) { if (utils.isDeprecated(ee)) {
result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, result.add(HtmlTree.SPAN(HtmlStyles.deprecatedLabel,
htmlWriter.getDeprecatedPhrase(ee))); htmlWriter.getDeprecatedPhrase(ee)));
} }
} }

View File

@ -33,8 +33,8 @@ import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.Text;
/** /**
* An inline taglet representing {@code {@docRoot}}. This taglet is * An inline taglet representing {@code {@docRoot}}. This taglet is

View File

@ -35,7 +35,7 @@ import com.sun.source.doctree.TextTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.Content;
/** /**
* An inline taglet used to index a word or a phrase. * An inline taglet used to index a word or a phrase.

View File

@ -39,12 +39,12 @@ import com.sun.source.util.DocTreePath;
import jdk.javadoc.doclet.Taglet.Location; import jdk.javadoc.doclet.Taglet.Location;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Result; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Result;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
/** /**
* A taglet that represents the {@code {@inheritDoc}} tag. * A taglet that represents the {@code {@inheritDoc}} tag.

View File

@ -46,12 +46,12 @@ import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.ClassWriter; import jdk.javadoc.internal.doclets.formats.html.ClassWriter;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo; import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static com.sun.source.doctree.DocTree.Kind.LINK; import static com.sun.source.doctree.DocTree.Kind.LINK;
import static com.sun.source.doctree.DocTree.Kind.LINK_PLAIN; import static com.sun.source.doctree.DocTree.Kind.LINK_PLAIN;

View File

@ -34,9 +34,9 @@ import com.sun.source.doctree.LiteralTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.markup.Text; import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.Text;
/** /**
* An inline taglet used to denote literal text, possibly in monospace font. * An inline taglet used to denote literal text, possibly in monospace font.

View File

@ -43,13 +43,13 @@ import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlIds; import jdk.javadoc.internal.doclets.formats.html.HtmlIds;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* A taglet that represents the {@code @param} tag. * A taglet that represents the {@code @param} tag.

View File

@ -41,11 +41,11 @@ import com.sun.source.doctree.ReturnTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* A taglet that represents the {@code @return} and {@code {@return }} tags. * A taglet that represents the {@code @return} and {@code {@return }} tags.

View File

@ -45,16 +45,16 @@ import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter; import jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter;
import jdk.javadoc.internal.doclets.formats.html.SerializedFormWriter; import jdk.javadoc.internal.doclets.formats.html.SerializedFormWriter;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
public class SeeTaglet extends BaseTaglet implements InheritableTaglet { public class SeeTaglet extends BaseTaglet implements InheritableTaglet {
SeeTaglet(HtmlConfiguration config) { SeeTaglet(HtmlConfiguration config) {

View File

@ -42,11 +42,11 @@ import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.RawHtml;
/** /**
* A custom single-argument block tag. * A custom single-argument block tag.

View File

@ -51,21 +51,21 @@ import com.sun.source.util.DocTreePath;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Action; import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Action;
import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.ParseException; import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.ParseException;
import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Parser; import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Parser;
import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Style; import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.Style;
import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.StyledText; import jdk.javadoc.internal.doclets.formats.html.taglets.snippet.StyledText;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletElement; import jdk.javadoc.internal.doclets.toolkit.DocletElement;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
import static jdk.javadoc.internal.doclets.formats.html.taglets.SnippetTaglet.Language.*; import static jdk.javadoc.internal.doclets.formats.html.taglets.SnippetTaglet.Language.*;
@ -122,13 +122,13 @@ public class SnippetTaglet extends BaseTaglet {
private Content snippetTagOutput(Element element, SnippetTree tag, StyledText content, private Content snippetTagOutput(Element element, SnippetTree tag, StyledText content,
String id, String lang) { String id, String lang) {
var pathToRoot = tagletWriter.htmlWriter.pathToRoot; var pathToRoot = tagletWriter.htmlWriter.pathToRoot;
var pre = new HtmlTree(TagName.PRE).setStyle(HtmlStyle.snippet); var pre = new HtmlTree(HtmlTag.PRE).setStyle(HtmlStyles.snippet);
if (id != null && !id.isBlank()) { if (id != null && !id.isBlank()) {
pre.put(HtmlAttr.ID, id); pre.put(HtmlAttr.ID, id);
} else { } else {
pre.put(HtmlAttr.ID, config.htmlIds.forSnippet(element, ids).name()); pre.put(HtmlAttr.ID, config.htmlIds.forSnippet(element, ids).name());
} }
var code = new HtmlTree(TagName.CODE) var code = new HtmlTree(HtmlTag.CODE)
.addUnchecked(Text.EMPTY); // Make sure the element is always rendered .addUnchecked(Text.EMPTY); // Make sure the element is always rendered
if (lang != null && !lang.isBlank()) { if (lang != null && !lang.isBlank()) {
code.addStyle("language-" + lang); code.addStyle("language-" + lang);
@ -196,16 +196,16 @@ public class SnippetTaglet extends BaseTaglet {
String copyText = resources.getText("doclet.Copy_to_clipboard"); String copyText = resources.getText("doclet.Copy_to_clipboard");
String copiedText = resources.getText("doclet.Copied_to_clipboard"); String copiedText = resources.getText("doclet.Copied_to_clipboard");
String copySnippetText = resources.getText("doclet.Copy_snippet_to_clipboard"); String copySnippetText = resources.getText("doclet.Copy_snippet_to_clipboard");
var snippetContainer = HtmlTree.DIV(HtmlStyle.snippetContainer, var snippetContainer = HtmlTree.DIV(HtmlStyles.snippetContainer,
new HtmlTree(TagName.BUTTON) new HtmlTree(HtmlTag.BUTTON)
.add(HtmlTree.SPAN(Text.of(copyText)) .add(HtmlTree.SPAN(Text.of(copyText))
.put(HtmlAttr.DATA_COPIED, copiedText)) .put(HtmlAttr.DATA_COPIED, copiedText))
.add(new HtmlTree(TagName.IMG) .add(new HtmlTree(HtmlTag.IMG)
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
.resolve(DocPaths.CLIPBOARD_SVG).getPath()) .resolve(DocPaths.CLIPBOARD_SVG).getPath())
.put(HtmlAttr.ALT, copySnippetText)) .put(HtmlAttr.ALT, copySnippetText))
.addStyle(HtmlStyle.copy) .addStyle(HtmlStyles.copy)
.addStyle(HtmlStyle.snippetCopy) .addStyle(HtmlStyles.snippetCopy)
.put(HtmlAttr.ARIA_LABEL, copySnippetText) .put(HtmlAttr.ARIA_LABEL, copySnippetText)
.put(HtmlAttr.ONCLICK, "copySnippet(this)")); .put(HtmlAttr.ONCLICK, "copySnippet(this)"));
return snippetContainer.add(pre.add(code)); return snippetContainer.add(pre.add(code));

View File

@ -30,7 +30,6 @@ import java.net.URISyntaxException;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
@ -42,16 +41,16 @@ import com.sun.source.util.DocTreePath;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.formats.html.markup.TextBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.Entity;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.RawHtml;
import jdk.javadoc.internal.html.Text;
import jdk.javadoc.internal.html.TextBuilder;
/** /**
* A taglet that represents the {@code @spec} tag. * A taglet that represents the {@code @spec} tag.

View File

@ -34,7 +34,7 @@ import com.sun.source.doctree.SummaryTree;
import jdk.javadoc.doclet.Taglet.Location; import jdk.javadoc.doclet.Taglet.Location;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.Content;
/** /**
* A taglet that represents the {@code {@summary}} tag. * A taglet that represents the {@code {@summary}} tag.

View File

@ -34,8 +34,8 @@ import com.sun.source.doctree.SystemPropertyTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.HtmlTree;
/** /**
* A taglet that represents the {@code @systemProperty} tag. * A taglet that represents the {@code @systemProperty} tag.

View File

@ -26,12 +26,14 @@
package jdk.javadoc.internal.doclets.formats.html.taglets; package jdk.javadoc.internal.doclets.formats.html.taglets;
import java.util.Set; import java.util.Set;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.Taglet.Location; import jdk.javadoc.doclet.Taglet.Location;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.HtmlTree;
/** /**
* This is the taglet interface used internally within the doclet. * This is the taglet interface used internally within the doclet.

View File

@ -43,20 +43,13 @@ import javax.lang.model.element.VariableElement;
import javax.lang.model.util.SimpleElementVisitor14; import javax.lang.model.util.SimpleElementVisitor14;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.InlineTagTree; import com.sun.source.doctree.InlineTagTree;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter; import jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter;
import jdk.javadoc.internal.doclets.formats.html.HtmlIds; import jdk.javadoc.internal.doclets.formats.html.HtmlIds;
import jdk.javadoc.internal.doclets.formats.html.HtmlOptions; import jdk.javadoc.internal.doclets.formats.html.HtmlOptions;
import jdk.javadoc.internal.doclets.formats.html.IndexWriter; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
import jdk.javadoc.internal.doclets.formats.html.SummaryListWriter;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlId;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.formats.html.taglets.Taglet.UnsupportedTagletOperationException; import jdk.javadoc.internal.doclets.formats.html.taglets.Taglet.UnsupportedTagletOperationException;
import jdk.javadoc.internal.doclets.toolkit.DocletElement; import jdk.javadoc.internal.doclets.toolkit.DocletElement;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
@ -64,6 +57,11 @@ import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlId;
import jdk.javadoc.internal.html.HtmlTree;
import jdk.javadoc.internal.html.Text;
/** /**
* Context and utility methods for taglet classes. * Context and utility methods for taglet classes.
@ -377,7 +375,7 @@ public class TagletWriter {
result = tagContent; result = tagContent;
} else { } else {
HtmlId id = HtmlIds.forText(tagText, htmlWriter.indexAnchorTable); HtmlId id = HtmlIds.forText(tagText, htmlWriter.indexAnchorTable);
result = HtmlTree.SPAN(id, HtmlStyle.searchTagResult, tagContent); result = HtmlTree.SPAN(id, HtmlStyles.searchTagResult, tagContent);
if (options.createIndex() && !tagText.isEmpty()) { if (options.createIndex() && !tagText.isEmpty()) {
String holder = getHolderName(element); String holder = getHolderName(element);
IndexItem item = IndexItem.of(element, tree, tagText, holder, desc, IndexItem item = IndexItem.of(element, tree, tagText, holder, desc,
@ -457,7 +455,7 @@ public class TagletWriter {
Content tagList(List<Content> items) { Content tagList(List<Content> items) {
// Use a different style if any list item is longer than 30 chars or contains commas. // Use a different style if any list item is longer than 30 chars or contains commas.
boolean hasLongLabels = items.stream().anyMatch(this::isLongOrHasComma); boolean hasLongLabels = items.stream().anyMatch(this::isLongOrHasComma);
var list = HtmlTree.UL(hasLongLabels ? HtmlStyle.tagListLong : HtmlStyle.tagList); var list = HtmlTree.UL(hasLongLabels ? HtmlStyles.tagListLong : HtmlStyles.tagList);
items.stream() items.stream()
.filter(Predicate.not(Content::isEmpty)) .filter(Predicate.not(Content::isEmpty))
.forEach(item -> list.add(HtmlTree.LI(item))); .forEach(item -> list.add(HtmlTree.LI(item)));

View File

@ -57,12 +57,12 @@ import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo; import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.ContentBuilder;
import jdk.javadoc.internal.html.HtmlTree;
/** /**
* A taglet that processes {@link ThrowsTree}, which represents {@code @throws} * A taglet that processes {@link ThrowsTree}, which represents {@code @throws}

View File

@ -32,8 +32,8 @@ import javax.lang.model.element.Element;
import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.doclets.formats.html.Content; import jdk.javadoc.internal.html.RawHtml;
/** /**
* A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.Taglet} * A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.Taglet}

View File

@ -39,10 +39,10 @@ import com.sun.source.doctree.ValueTree;
import jdk.javadoc.doclet.Taglet; import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo; import jdk.javadoc.internal.doclets.formats.html.HtmlLinkInfo;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.formats.html.Content;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.html.Content;
import jdk.javadoc.internal.html.Text;
/** /**
* An inline taglet representing the value tag. This tag should only be used with * An inline taglet representing the value tag. This tag should only be used with

View File

@ -101,9 +101,16 @@ import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.DefinedBy.Api;
import jdk.javadoc.internal.doclint.HtmlTag.AttrKind; import jdk.javadoc.internal.html.HtmlAttr;
import jdk.javadoc.internal.doclint.HtmlTag.ElemKind; import jdk.javadoc.internal.html.HtmlAttr.AttrKind;
import static jdk.javadoc.internal.doclint.Messages.Group.*; import jdk.javadoc.internal.html.HtmlTag;
import jdk.javadoc.internal.html.HtmlTag.ElemKind;
import static jdk.javadoc.internal.doclint.Messages.Group.ACCESSIBILITY;
import static jdk.javadoc.internal.doclint.Messages.Group.HTML;
import static jdk.javadoc.internal.doclint.Messages.Group.MISSING;
import static jdk.javadoc.internal.doclint.Messages.Group.REFERENCE;
import static jdk.javadoc.internal.doclint.Messages.Group.SYNTAX;
/** /**
@ -132,12 +139,12 @@ public class Checker extends DocTreePathScanner<Void, Void> {
static class TagStackItem { static class TagStackItem {
final DocTree tree; // typically, but not always, StartElementTree final DocTree tree; // typically, but not always, StartElementTree
final HtmlTag tag; final HtmlTag tag;
final Set<HtmlTag.Attr> attrs; final Set<HtmlAttr> attrs;
final Set<Flag> flags; final Set<Flag> flags;
TagStackItem(DocTree tree, HtmlTag tag) { TagStackItem(DocTree tree, HtmlTag tag) {
this.tree = tree; this.tree = tree;
this.tag = tag; this.tag = tag;
attrs = EnumSet.noneOf(HtmlTag.Attr.class); attrs = EnumSet.noneOf(HtmlAttr.class);
flags = EnumSet.noneOf(Flag.class); flags = EnumSet.noneOf(Flag.class);
} }
@Override @Override
@ -399,7 +406,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE) @Override @DefinedBy(Api.COMPILER_TREE)
public Void visitStartElement(StartElementTree tree, Void ignore) { public Void visitStartElement(StartElementTree tree, Void ignore) {
final Name treeName = tree.getName(); final Name treeName = tree.getName();
final HtmlTag t = HtmlTag.get(treeName); final HtmlTag t = HtmlTag.of(treeName);
if (t == null) { if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName); env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else if (t.elemKind == ElemKind.HTML4) { } else if (t.elemKind == ElemKind.HTML4) {
@ -472,7 +479,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
} }
case IMG -> { case IMG -> {
if (!top.attrs.contains(HtmlTag.Attr.ALT)) if (!top.attrs.contains(HtmlAttr.ALT))
env.messages.error(ACCESSIBILITY, tree, "dc.no.alt.attr.for.image"); env.messages.error(ACCESSIBILITY, tree, "dc.no.alt.attr.for.image");
} }
} }
@ -592,7 +599,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE) @Override @DefinedBy(Api.COMPILER_TREE)
public Void visitEndElement(EndElementTree tree, Void ignore) { public Void visitEndElement(EndElementTree tree, Void ignore) {
final Name treeName = tree.getName(); final Name treeName = tree.getName();
final HtmlTag t = HtmlTag.get(treeName); final HtmlTag t = HtmlTag.of(treeName);
if (t == null) { if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName); env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else if (t.endKind == HtmlTag.EndKind.NONE) { } else if (t.endKind == HtmlTag.EndKind.NONE) {
@ -605,7 +612,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
switch (t) { switch (t) {
case TABLE -> { case TABLE -> {
if (!top.flags.contains(Flag.TABLE_IS_PRESENTATION) if (!top.flags.contains(Flag.TABLE_IS_PRESENTATION)
&& !top.attrs.contains(HtmlTag.Attr.SUMMARY) && !top.attrs.contains(HtmlAttr.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");
@ -682,7 +689,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
HtmlTag currTag = tagStack.peek().tag; HtmlTag currTag = tagStack.peek().tag;
if (currTag != null && currTag.elemKind != ElemKind.HTML4) { if (currTag != null && currTag.elemKind != ElemKind.HTML4) {
Name name = tree.getName(); Name name = tree.getName();
HtmlTag.Attr attr = currTag.getAttr(name); HtmlAttr attr = currTag.getAttr(name);
if (attr != null) { if (attr != null) {
boolean first = tagStack.peek().attrs.add(attr); boolean first = tagStack.peek().attrs.add(attr);
if (!first) if (!first)
@ -758,19 +765,21 @@ public class Checker extends DocTreePathScanner<Void, Void> {
String v = getAttrValue(tree); String v = getAttrValue(tree);
try { try {
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1)) { if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1)) {
env.messages.error(HTML, tree, "dc.attr.table.border.not.valid", attr); env.messages.error(HTML, tree, "dc.attr.table.border.not.valid",
(v == null ? tree : v));
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
env.messages.error(HTML, tree, "dc.attr.table.border.not.number", attr); env.messages.error(HTML, tree, "dc.attr.table.border.not.number", v);
} }
} else if (currTag == HtmlTag.IMG) { } else if (currTag == HtmlTag.IMG) {
String v = getAttrValue(tree); String v = getAttrValue(tree);
try { try {
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 0)) { if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 0)) {
env.messages.error(HTML, tree, "dc.attr.img.border.not.valid", attr); env.messages.error(HTML, tree, "dc.attr.img.border.not.valid",
(v == null ? tree : v));
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
env.messages.error(HTML, tree, "dc.attr.img.border.not.number", attr); env.messages.error(HTML, tree, "dc.attr.img.border.not.number", v);
} }
} }
} }

View File

@ -23,14 +23,12 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.Objects; import java.util.Objects;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* Class for generating a comment for HTML pages of javadoc output. * Class for generating a comment for HTML pages of javadoc output.
*/ */

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -31,8 +31,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* A sequence of Content nodes. * A sequence of Content nodes.
*/ */

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
/** /**
* Supported DOCTYPE declarations. * Supported DOCTYPE declarations.

View File

@ -23,9 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import jdk.javadoc.internal.doclets.formats.html.Content;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;

View File

@ -0,0 +1,275 @@
/*
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.javadoc.internal.html;
import java.util.HashMap;
import java.util.Map;
import java.util.Locale;
/**
* An abstraction for the type-safe representation and use of HTML attributes.
*
* @apiNote
* Attributes are used when performing simple validity checks on HTML in
* documentation comments, and when generating HTML for output.
*
* @see HtmlTree#put(HtmlAttr, String)
*/
public enum HtmlAttr {
ABBR,
ACCESSKEY(true),
ALIGN,
ALINK,
ALT,
ARIA_ACTIVEDESCENDANT(true),
ARIA_CONTROLS(true),
ARIA_DESCRIBEDBY(true),
ARIA_EXPANDED(true),
ARIA_LABEL(true),
ARIA_LABELLEDBY(true),
ARIA_LEVEL(true),
ARIA_MULTISELECTABLE(true),
ARIA_ORIENTATION(true),
ARIA_OWNS(true),
ARIA_POSINSET(true),
ARIA_READONLY(true),
ARIA_REQUIRED(true),
ARIA_SELECTED(true),
ARIA_SETSIZE(true),
ARIA_SORT(true),
AUTOCAPITALIZE(true),
AUTOCOMPLETE,
AUTOFOCUS(true),
AXIS,
BACKGROUND,
BGCOLOR,
BORDER,
CELLPADDING,
CELLSPACING,
CHAR,
CHAROFF,
CHARSET,
CHECKED,
CITE,
CLASS(true),
CLEAR,
COLOR,
COLS,
COLSPAN,
COMPACT,
CONTENT,
CONTENTEDITABLE(true),
COORDS,
CROSSORIGIN,
DATA_COPIED, // custom HTML5 data attribute
DATETIME,
DIR(true),
DISABLED,
DRAGGABLE(true),
ENTERKEYHINT(true),
FACE,
FOR,
FORM,
FRAME,
FRAMEBORDER,
HEADERS,
HEIGHT,
HIDDEN(true),
HREF,
HSPACE,
HTTP_EQUIV,
ID(true),
INERT(true),
INPUTMODE(true),
IS(true),
ITEMID(true),
ITEMPROP(true),
ITEMREF(true),
ITEMSCOPE(true),
ITEMTYPE(true),
LANG(true),
LINK,
LONGDESC,
MARGINHEIGHT,
MARGINWIDTH,
NAME,
NONCE(true),
NOSHADE,
NOWRAP,
ONCLICK,
ONKEYDOWN,
ONLOAD,
PLACEHOLDER,
POPOVER(true),
PROFILE,
REL,
REV,
REVERSED,
ROLE(true),
ROWS,
ROWSPAN,
RULES,
SCHEME,
SCOPE,
SCROLLING,
SHAPE,
SIZE,
SPACE,
SPELLCHECK(true),
SRC,
START,
STYLE(true),
SUMMARY,
TABINDEX(true),
TARGET,
TEXT,
TITLE(true),
TRANSLATE(true),
TYPE,
VALIGN,
VALUE,
VERSION,
VLINK,
VSPACE,
WIDTH,
WRITINGSUGGESTIONS(true);
/**
* The "external" name of this attribute.
*/
private final String name;
/**
* Whether this is a global attribute, that can be used with all HTML tags.
*/
private final boolean isGlobal;
/**
* An abstraction for the type-safe representation and use of ARIA roles.
*
* @see HtmlTree#setRole(Role)
*/
public enum Role {
BANNER,
CONTENTINFO,
MAIN,
NAVIGATION,
REGION;
private final String role;
Role() {
role = name().toLowerCase(Locale.ROOT);
}
public String toString() {
return role;
}
}
/**
* An abstraction for the type-safe representation and use of "input" types.
*
* @see HtmlTree#INPUT(InputType, HtmlId)
* @see HtmlTree#INPUT(InputType, HtmlStyle)
*/
public enum InputType {
CHECKBOX,
RESET,
TEXT;
private final String type;
InputType() {
type = name().toLowerCase(Locale.ROOT);
}
public String toString() {
return type;
}
}
/**
* An abstraction for the kind of an attribute in the context of an HTML tag.
*
* @see HtmlTag#attrs(AttrKind,HtmlAttr...)
*/
public enum AttrKind {
OK,
INVALID,
OBSOLETE,
HTML4
}
HtmlAttr() {
this(false);
}
HtmlAttr(boolean flag) {
name = name().toLowerCase(Locale.ROOT).replace("_", "-");
isGlobal = flag;
}
/**
* {@return the "external" name of this attribute}
* The external name is the name of the enum member in lower case with {@code _} replaced by {@code -}.
*/
public String getName() {
return name;
}
/**
* {@return whether this attribute is a global attribute, that may appear on all tags}
*/
public boolean isGlobal() {
return isGlobal;
}
// FIXME: this is used in doclint Checker, when generating messages
@Override
public String toString() {
return name;
}
private static final Map<String, HtmlAttr> index = new HashMap<>();
static {
for (HtmlAttr t : values()) {
index.put(t.getName(), t);
}
}
/**
* {@return the attribute with the given name, or {@code null} if there is no known attribute}
*
* @param name the name
*/
public static HtmlAttr of(CharSequence name) {
return index.get(name.toString().toLowerCase(Locale.ROOT));
}
}

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
/** /**
* A type-safe wrapper around a {@code String}, for use as an "id" * A type-safe wrapper around a {@code String}, for use as an "id"

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.javadoc.internal.html;
/**
* An abstraction for the type-safe representation and use of CSS class names.
*
* @apiNote
* Despite the name, implementations of this interface provide values for the HTML
* {@code class} attribute, and <strong>not</strong> the HTML {@code style} attribute.
* This is to avoid confusion with the widespread use of the word "class" in the Java ecosystem,
* and the potential for clashes with methods called {@code setClass} instead of {@code setStyle}.
*
* @see HtmlTree#addStyle(HtmlStyle)
* @see HtmlTree#setStyle(HtmlStyle)
*/
public interface HtmlStyle {
String cssName();
}

View File

@ -23,18 +23,18 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclint; package jdk.javadoc.internal.html;
import java.io.Serial;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.lang.model.element.Name; import javax.lang.model.element.Name;
import com.sun.tools.javac.util.StringUtils; import static jdk.javadoc.internal.html.HtmlAttr.*;
import static jdk.javadoc.internal.doclint.HtmlTag.Attr.*;
/** /**
* Enum representing HTML tags. * Enum representing HTML tags.
@ -42,10 +42,6 @@ import static jdk.javadoc.internal.doclint.HtmlTag.Attr.*;
* The intent of this class is to embody the semantics of the current HTML standard, * The intent of this class is to embody the semantics of the current HTML standard,
* to the extent supported/used by javadoc. * to the extent supported/used by javadoc.
* *
* This class is derivative of {@link jdk.javadoc.internal.doclets.formats.html.markup.TagName}.
* Eventually, these two should be merged back together, and possibly made
* public.
*
* @see <a href="https://html.spec.whatwg.org/multipage/">HTML Living Standard</a> * @see <a href="https://html.spec.whatwg.org/multipage/">HTML Living Standard</a>
* @see <a href="http://www.w3.org/TR/html5/">HTML 5 Specification</a> * @see <a href="http://www.w3.org/TR/html5/">HTML 5 Specification</a>
* @see <a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 Specification</a> * @see <a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 Specification</a>
@ -88,6 +84,9 @@ public enum HtmlTag {
BR(BlockType.INLINE, EndKind.NONE, BR(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.HTML4, CLEAR)), attrs(AttrKind.HTML4, CLEAR)),
BUTTON(BlockType.INLINE, EndKind.REQUIRED,
attrs(AttrKind.OK, FORM, NAME, TYPE, VALUE)),
CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED, CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT), EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT),
attrs(AttrKind.HTML4, ALIGN)), attrs(AttrKind.HTML4, ALIGN)),
@ -117,7 +116,10 @@ public enum HtmlTag {
DEL(BlockType.INLINE, EndKind.REQUIRED, DEL(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST),
attrs(AttrKind.OK, Attr.CITE, Attr.DATETIME)), attrs(AttrKind.OK, HtmlAttr.CITE, HtmlAttr.DATETIME)),
DETAILS(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
DFN(BlockType.INLINE, EndKind.REQUIRED, DFN(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
@ -149,12 +151,10 @@ public enum HtmlTag {
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)) { EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)) {
@Override @Override
public boolean accepts(HtmlTag t) { public boolean accepts(HtmlTag t) {
switch (t) { return switch (t) {
case HEADER: case FOOTER: case MAIN: case HEADER, FOOTER, MAIN -> false;
return false; default -> (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
default: };
return (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
}
} }
}, },
@ -186,12 +186,10 @@ public enum HtmlTag {
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)) { EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)) {
@Override @Override
public boolean accepts(HtmlTag t) { public boolean accepts(HtmlTag t) {
switch (t) { return switch (t) {
case HEADER: case FOOTER: case MAIN: case HEADER, FOOTER, MAIN -> false;
return false; default -> (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
default: };
return (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
}
} }
}, },
@ -209,19 +207,25 @@ public enum HtmlTag {
attrs(AttrKind.OK, SRC, ALT, HEIGHT, WIDTH, CROSSORIGIN), attrs(AttrKind.OK, SRC, ALT, HEIGHT, WIDTH, CROSSORIGIN),
attrs(AttrKind.HTML4, NAME, ALIGN, HSPACE, VSPACE, BORDER)), attrs(AttrKind.HTML4, NAME, ALIGN, HSPACE, VSPACE, BORDER)),
INPUT(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.OK, NAME, TYPE, VALUE)),
INS(BlockType.INLINE, EndKind.REQUIRED, INS(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST),
attrs(AttrKind.OK, Attr.CITE, Attr.DATETIME)), attrs(AttrKind.OK, HtmlAttr.CITE, HtmlAttr.DATETIME)),
KBD(BlockType.INLINE, EndKind.REQUIRED, KBD(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
LABEL(BlockType.INLINE, EndKind.REQUIRED),
LI(BlockType.LIST_ITEM, EndKind.OPTIONAL, LI(BlockType.LIST_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, VALUE), attrs(AttrKind.OK, VALUE),
attrs(AttrKind.HTML4, TYPE)), attrs(AttrKind.HTML4, TYPE)),
LINK(BlockType.OTHER, EndKind.NONE), LINK(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.OK, REL)),
MAIN(BlockType.OTHER, EndKind.REQUIRED), MAIN(BlockType.OTHER, EndKind.REQUIRED),
@ -262,12 +266,10 @@ public enum HtmlTag {
attrs(AttrKind.HTML4, WIDTH)) { attrs(AttrKind.HTML4, WIDTH)) {
@Override @Override
public boolean accepts(HtmlTag t) { public boolean accepts(HtmlTag t) {
switch (t) { return switch (t) {
case IMG: case BIG: case SMALL: case SUB: case SUP: case IMG, BIG, SMALL, SUB, SUP -> false;
return false; default -> (t.blockType == BlockType.INLINE);
default: };
return (t.blockType == BlockType.INLINE);
}
} }
}, },
@ -280,8 +282,8 @@ public enum HtmlTag {
SAMP(BlockType.INLINE, EndKind.REQUIRED, SAMP(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
SCRIPT(BlockType.OTHER, EndKind.REQUIRED, SCRIPT(BlockType.INLINE, EndKind.REQUIRED,
attrs(AttrKind.OK, SRC)), attrs(AttrKind.OK, SRC, TYPE)),
SECTION(BlockType.BLOCK, EndKind.REQUIRED, SECTION(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)), EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
@ -303,25 +305,22 @@ public enum HtmlTag {
SUB(BlockType.INLINE, EndKind.REQUIRED, SUB(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
SUMMARY(BlockType.BLOCK, EndKind.REQUIRED),
SUP(BlockType.INLINE, EndKind.REQUIRED, SUP(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
TABLE(BlockType.BLOCK, EndKind.REQUIRED, TABLE(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT), EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, BORDER), attrs(AttrKind.OK, BORDER),
attrs(AttrKind.HTML4, SUMMARY, CELLPADDING, CELLSPACING, attrs(AttrKind.HTML4, HtmlAttr.SUMMARY, CELLPADDING, CELLSPACING,
Attr.FRAME, RULES, WIDTH, ALIGN, BGCOLOR)) { HtmlAttr.FRAME, RULES, WIDTH, ALIGN, BGCOLOR)) {
@Override @Override
public boolean accepts(HtmlTag t) { public boolean accepts(HtmlTag t) {
switch (t) { return switch (t) {
case CAPTION: case CAPTION, COLGROUP, THEAD, TBODY, TFOOT, TR -> true;
case COLGROUP: default -> false;
case THEAD: case TBODY: case TFOOT: };
case TR: // HTML 3.2
return true;
default:
return false;
}
} }
}, },
@ -337,7 +336,7 @@ public enum HtmlTag {
TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL, TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS), attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS),
attrs(AttrKind.HTML4, AXIS, Attr.ABBR, SCOPE, ALIGN, VALIGN, CHAR, CHAROFF, attrs(AttrKind.HTML4, AXIS, HtmlAttr.ABBR, SCOPE, ALIGN, VALIGN, CHAR, CHAROFF,
WIDTH, BGCOLOR, HEIGHT, NOWRAP)), WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
TEMPLATE(BlockType.BLOCK, EndKind.REQUIRED, TEMPLATE(BlockType.BLOCK, EndKind.REQUIRED,
@ -353,7 +352,7 @@ public enum HtmlTag {
TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL, TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, Attr.ABBR), attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, HtmlAttr.ABBR),
attrs(AttrKind.HTML4, WIDTH, BGCOLOR, HEIGHT, NOWRAP, AXIS, ALIGN, CHAR, CHAROFF, VALIGN)), attrs(AttrKind.HTML4, WIDTH, BGCOLOR, HEIGHT, NOWRAP, AXIS, ALIGN, CHAR, CHAROFF, VALIGN)),
THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED, THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED,
@ -408,6 +407,7 @@ public enum HtmlTag {
/** /**
* Enum representing the type of HTML element. * Enum representing the type of HTML element.
*/ */
// See JDK-8337586 for suggestions
public enum BlockType { public enum BlockType {
BLOCK, BLOCK,
INLINE, INLINE,
@ -432,150 +432,13 @@ public enum HtmlTag {
NO_NEST NO_NEST
} }
public enum Attr {
ABBR,
ACCESSKEY(true),
ALIGN,
ALINK,
ALT,
ARIA_ACTIVEDESCENDANT(true),
ARIA_CONTROLS(true),
ARIA_DESCRIBEDBY(true),
ARIA_EXPANDED(true),
ARIA_LABEL(true),
ARIA_LABELLEDBY(true),
ARIA_LEVEL(true),
ARIA_MULTISELECTABLE(true),
ARIA_OWNS(true),
ARIA_POSINSET(true),
ARIA_READONLY(true),
ARIA_REQUIRED(true),
ARIA_SELECTED(true),
ARIA_SETSIZE(true),
ARIA_SORT(true),
AUTOCAPITALIZE(true),
AUTOFOCUS(true),
AXIS,
BACKGROUND,
BGCOLOR,
BORDER,
CELLPADDING,
CELLSPACING,
CHAR,
CHAROFF,
CHARSET,
CITE,
CLASS(true),
CLEAR,
COLOR,
COLSPAN,
COMPACT,
CONTENTEDITABLE(true),
COORDS,
CROSSORIGIN,
DATETIME,
DIR(true),
DRAGGABLE(true),
ENTERKEYHINT(true),
FACE,
FRAME,
FRAMEBORDER,
HEADERS,
HEIGHT,
HIDDEN(true),
HREF,
HSPACE,
ID(true),
INERT(true),
INPUTMODE(true),
IS(true),
ITEMID(true),
ITEMPROP(true),
ITEMREF(true),
ITEMSCOPE(true),
ITEMTYPE(true),
LANG(true),
LINK,
LONGDESC,
MARGINHEIGHT,
MARGINWIDTH,
NAME,
NONCE(true),
NOSHADE,
NOWRAP,
POPOVER(true),
PROFILE,
REV,
REVERSED,
ROLE(true),
ROWSPAN,
RULES,
SCHEME,
SCOPE,
SCROLLING,
SHAPE,
SIZE,
SPACE,
SPELLCHECK(true),
SRC,
START,
STYLE(true),
SUMMARY,
TABINDEX(true),
TARGET,
TEXT,
TITLE(true),
TRANSLATE(true),
TYPE,
VALIGN,
VALUE,
VERSION,
VLINK,
VSPACE,
WIDTH,
WRITINGSUGGESTIONS(true);
private final String name;
private final boolean isGlobal;
Attr() {
this(false);
}
Attr(boolean flag) {
name = StringUtils.toLowerCase(name().replace("_", "-"));
isGlobal = flag;
}
public boolean isGlobal() {
return isGlobal;
}
public String getText() {
return name;
}
static final Map<String,Attr> index = new HashMap<>();
static {
for (Attr t: values()) {
index.put(t.getText(), t);
}
}
}
public enum AttrKind {
OK,
INVALID,
OBSOLETE,
HTML4
}
// This class exists to avoid warnings from using parameterized vararg type // This class exists to avoid warnings from using parameterized vararg type
// Map<Attr,AttrKind> in signature of HtmlTag constructor. // Map<Attr,AttrKind> in signature of HtmlTag constructor.
private static class AttrMap extends EnumMap<Attr,AttrKind> { private static class AttrMap extends EnumMap<HtmlAttr,AttrKind> {
@Serial
private static final long serialVersionUID = 0; private static final long serialVersionUID = 0;
AttrMap() { AttrMap() {
super(Attr.class); super(HtmlAttr.class);
} }
} }
@ -584,7 +447,7 @@ public enum HtmlTag {
public final BlockType blockType; public final BlockType blockType;
public final EndKind endKind; public final EndKind endKind;
public final Set<Flag> flags; public final Set<Flag> flags;
private final Map<Attr,AttrKind> attrs; private final Map<HtmlAttr,AttrKind> attrs;
HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) { HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
this(ElemKind.OK, blockType, endKind, Set.of(), attrMaps); this(ElemKind.OK, blockType, endKind, Set.of(), attrMaps);
@ -603,8 +466,8 @@ public enum HtmlTag {
this.blockType = blockType; this.blockType = blockType;
this.endKind = endKind; this.endKind = endKind;
this.flags = flags; this.flags = flags;
this.attrs = new EnumMap<>(Attr.class); this.attrs = new EnumMap<>(HtmlAttr.class);
for (Map<Attr,AttrKind> m: attrMaps) for (Map<HtmlAttr,AttrKind> m: attrMaps)
this.attrs.putAll(m); this.attrs.putAll(m);
} }
@ -615,19 +478,17 @@ public enum HtmlTag {
return (t.blockType == BlockType.BLOCK); return (t.blockType == BlockType.BLOCK);
} else if (flags.contains(Flag.ACCEPTS_INLINE)) { } else if (flags.contains(Flag.ACCEPTS_INLINE)) {
return (t.blockType == BlockType.INLINE); return (t.blockType == BlockType.INLINE);
} else } else {
switch (blockType) {
case BLOCK:
case INLINE:
return (t.blockType == BlockType.INLINE);
case OTHER:
// OTHER tags are invalid in doc comments, and will be
// reported separately, so silently accept/ignore any content
return true;
default:
// any combination which could otherwise arrive here // any combination which could otherwise arrive here
// ought to have been handled in an overriding method // ought to have been handled in an overriding method
throw new AssertionError(this + ":" + t); return switch (blockType) {
case BLOCK, INLINE -> (t.blockType == BlockType.INLINE);
case OTHER ->
// OTHER tags are invalid in doc comments, and will be
// reported separately, so silently accept/ignore any content
true;
default -> throw new AssertionError(this + ":" + t);
};
} }
} }
@ -637,16 +498,16 @@ public enum HtmlTag {
return accepts(B); return accepts(B);
} }
public String getText() { public String getName() {
return StringUtils.toLowerCase(name()); return name().toLowerCase(Locale.ROOT).replace("_", "-");
} }
public Attr getAttr(Name attrName) { public HtmlAttr getAttr(Name attrName) {
return Attr.index.get(StringUtils.toLowerCase(attrName.toString())); return HtmlAttr.of(attrName);
} }
public AttrKind getAttrKind(Name attrName) { public AttrKind getAttrKind(Name attrName) {
Attr attr = getAttr(attrName); HtmlAttr attr = getAttr(attrName);
if (attr == null) { if (attr == null) {
return AttrKind.INVALID; return AttrKind.INVALID;
} }
@ -655,20 +516,20 @@ public enum HtmlTag {
attrs.getOrDefault(attr, AttrKind.INVALID); attrs.getOrDefault(attr, AttrKind.INVALID);
} }
private static AttrMap attrs(AttrKind k, Attr... attrs) { private static AttrMap attrs(AttrKind k, HtmlAttr... attrs) {
AttrMap map = new AttrMap(); AttrMap map = new AttrMap();
for (Attr a: attrs) map.put(a, k); for (HtmlAttr a : attrs) map.put(a, k);
return map; return map;
} }
private static final Map<String, HtmlTag> index = new HashMap<>(); private static final Map<String, HtmlTag> index = new HashMap<>();
static { static {
for (HtmlTag t: values()) { for (HtmlTag t: values()) {
index.put(t.getText(), t); index.put(t.getName(), t);
} }
} }
public static HtmlTag get(Name tagName) { public static HtmlTag of(CharSequence tagName) {
return index.get(StringUtils.toLowerCase(tagName.toString())); return index.get(tagName.toString().toLowerCase(Locale.ROOT));
} }
} }

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -38,9 +38,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr.Role;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* A tree node representing an HTML element, containing the name of the element, * A tree node representing an HTML element, containing the name of the element,
* a collection of attributes, and content. * a collection of attributes, and content.
@ -63,10 +60,10 @@ import jdk.javadoc.internal.doclets.formats.html.Content;
public class HtmlTree extends Content { public class HtmlTree extends Content {
/** /**
* The name of the HTML element. * The tag for the HTML element.
* This value is never {@code null}. * This value is never {@code null}.
*/ */
public final TagName tagName; public final HtmlTag tag;
/** /**
* The attributes for the HTML element. * The attributes for the HTML element.
@ -84,10 +81,10 @@ public class HtmlTree extends Content {
* Creates an {@code HTMLTree} object representing an HTML element * Creates an {@code HTMLTree} object representing an HTML element
* with the given name. * with the given name.
* *
* @param tagName the name * @param tag the name
*/ */
public HtmlTree(TagName tagName) { public HtmlTree(HtmlTag tag) {
this.tagName = Objects.requireNonNull(tagName); this.tag = Objects.requireNonNull(tag);
} }
/** /**
@ -131,7 +128,7 @@ public class HtmlTree extends Content {
* @param role the role * @param role the role
* @return this object * @return this object
*/ */
public HtmlTree setRole(Role role) { public HtmlTree setRole(HtmlAttr.Role role) {
return put(HtmlAttr.ROLE, role.toString()); return put(HtmlAttr.ROLE, role.toString());
} }
@ -347,7 +344,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree A(String ref, Content body) { public static HtmlTree A(String ref, Content body) {
return new HtmlTree(TagName.A) return new HtmlTree(HtmlTag.A)
.put(HtmlAttr.HREF, encodeURL(ref)) .put(HtmlAttr.HREF, encodeURL(ref))
.add(body); .add(body);
} }
@ -363,7 +360,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree A(URI ref, Content body) { public static HtmlTree A(URI ref, Content body) {
return new HtmlTree(TagName.A) return new HtmlTree(HtmlTag.A)
.put(HtmlAttr.HREF, ref.toASCIIString()) .put(HtmlAttr.HREF, ref.toASCIIString())
.add(body); .add(body);
} }
@ -375,7 +372,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree CAPTION(Content body) { public static HtmlTree CAPTION(Content body) {
return new HtmlTree(TagName.CAPTION) return new HtmlTree(HtmlTag.CAPTION)
.add(body); .add(body);
} }
@ -386,7 +383,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree CODE(Content body) { public static HtmlTree CODE(Content body) {
return new HtmlTree(TagName.CODE) return new HtmlTree(HtmlTag.CODE)
.add(body); .add(body);
} }
@ -397,7 +394,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DD(Content body) { public static HtmlTree DD(Content body) {
return new HtmlTree(TagName.DD) return new HtmlTree(HtmlTag.DD)
.add(body); .add(body);
} }
@ -407,7 +404,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DETAILS() { public static HtmlTree DETAILS() {
return new HtmlTree(TagName.DETAILS); return new HtmlTree(HtmlTag.DETAILS);
} }
/** /**
@ -416,7 +413,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DETAILS(HtmlStyle style) { public static HtmlTree DETAILS(HtmlStyle style) {
return new HtmlTree(TagName.DETAILS) return new HtmlTree(HtmlTag.DETAILS)
.setStyle(style); .setStyle(style);
} }
@ -427,7 +424,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DL(HtmlStyle style) { public static HtmlTree DL(HtmlStyle style) {
return new HtmlTree(TagName.DL) return new HtmlTree(HtmlTag.DL)
.setStyle(style); .setStyle(style);
} }
@ -439,7 +436,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DL(HtmlStyle style, Content body) { public static HtmlTree DL(HtmlStyle style, Content body) {
return new HtmlTree(TagName.DL) return new HtmlTree(HtmlTag.DL)
.setStyle(style) .setStyle(style)
.add(body); .add(body);
} }
@ -451,7 +448,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DIV(HtmlStyle style) { public static HtmlTree DIV(HtmlStyle style) {
return new HtmlTree(TagName.DIV) return new HtmlTree(HtmlTag.DIV)
.setStyle(style); .setStyle(style);
} }
@ -463,7 +460,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DIV(HtmlStyle style, Content body) { public static HtmlTree DIV(HtmlStyle style, Content body) {
return new HtmlTree(TagName.DIV) return new HtmlTree(HtmlTag.DIV)
.setStyle(style) .setStyle(style)
.add(body); .add(body);
} }
@ -475,7 +472,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DIV(Content body) { public static HtmlTree DIV(Content body) {
return new HtmlTree(TagName.DIV) return new HtmlTree(HtmlTag.DIV)
.add(body); .add(body);
} }
@ -486,7 +483,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree DT(Content body) { public static HtmlTree DT(Content body) {
return new HtmlTree(TagName.DT) return new HtmlTree(HtmlTag.DT)
.add(body); .add(body);
} }
@ -497,8 +494,8 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree FOOTER() { public static HtmlTree FOOTER() {
return new HtmlTree(TagName.FOOTER) return new HtmlTree(HtmlTag.FOOTER)
.setRole(Role.CONTENTINFO); .setRole(HtmlAttr.Role.CONTENTINFO);
} }
/** /**
@ -508,8 +505,8 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree HEADER() { public static HtmlTree HEADER() {
return new HtmlTree(TagName.HEADER) return new HtmlTree(HtmlTag.HEADER)
.setRole(Role.BANNER); .setRole(HtmlAttr.Role.BANNER);
} }
/** /**
@ -519,7 +516,7 @@ public class HtmlTree extends Content {
* @param body the content * @param body the content
* @return the element * @return the element
*/ */
public static HtmlTree HEADING(TagName headingTag, Content body) { public static HtmlTree HEADING(HtmlTag headingTag, Content body) {
return new HtmlTree(checkHeading(headingTag)) return new HtmlTree(checkHeading(headingTag))
.add(body); .add(body);
} }
@ -532,7 +529,7 @@ public class HtmlTree extends Content {
* @param body the content * @param body the content
* @return the element * @return the element
*/ */
public static HtmlTree HEADING(TagName headingTag, HtmlStyle style, Content body) { public static HtmlTree HEADING(HtmlTag headingTag, HtmlStyle style, Content body) {
return new HtmlTree(checkHeading(headingTag)) return new HtmlTree(checkHeading(headingTag))
.setStyle(style) .setStyle(style)
.add(body); .add(body);
@ -547,7 +544,7 @@ public class HtmlTree extends Content {
* @param body the content * @param body the content
* @return the element * @return the element
*/ */
public static HtmlTree HEADING_TITLE(TagName headingTag, public static HtmlTree HEADING_TITLE(HtmlTag headingTag,
HtmlStyle style, Content body) { HtmlStyle style, Content body) {
return new HtmlTree(checkHeading(headingTag)) return new HtmlTree(checkHeading(headingTag))
.setTitle(body) .setTitle(body)
@ -563,13 +560,13 @@ public class HtmlTree extends Content {
* @param body the content * @param body the content
* @return the element * @return the element
*/ */
public static HtmlTree HEADING_TITLE(TagName headingTag, Content body) { public static HtmlTree HEADING_TITLE(HtmlTag headingTag, Content body) {
return new HtmlTree(checkHeading(headingTag)) return new HtmlTree(checkHeading(headingTag))
.setTitle(body) .setTitle(body)
.add(body); .add(body);
} }
private static TagName checkHeading(TagName headingTag) { private static HtmlTag checkHeading(HtmlTag headingTag) {
return switch (headingTag) { return switch (headingTag) {
case H1, H2, H3, H4, H5, H6 -> headingTag; case H1, H2, H3, H4, H5, H6 -> headingTag;
default -> throw new IllegalArgumentException(headingTag.toString()); default -> throw new IllegalArgumentException(headingTag.toString());
@ -586,7 +583,7 @@ public class HtmlTree extends Content {
* @return the {@code HTML} element * @return the {@code HTML} element
*/ */
public static HtmlTree HTML(String lang, Content head, Content body) { public static HtmlTree HTML(String lang, Content head, Content body) {
return new HtmlTree(TagName.HTML) return new HtmlTree(HtmlTag.HTML)
.put(HtmlAttr.LANG, lang) .put(HtmlAttr.LANG, lang)
.add(head) .add(head)
.add(body); .add(body);
@ -601,7 +598,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree INPUT(HtmlAttr.InputType type, HtmlId id) { public static HtmlTree INPUT(HtmlAttr.InputType type, HtmlId id) {
return new HtmlTree(TagName.INPUT) return new HtmlTree(HtmlTag.INPUT)
.put(HtmlAttr.TYPE, type.toString()) .put(HtmlAttr.TYPE, type.toString())
.setId(id) .setId(id)
.put(HtmlAttr.DISABLED, ""); .put(HtmlAttr.DISABLED, "");
@ -615,7 +612,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree INPUT(HtmlAttr.InputType type, HtmlStyle style) { public static HtmlTree INPUT(HtmlAttr.InputType type, HtmlStyle style) {
return new HtmlTree(TagName.INPUT) return new HtmlTree(HtmlTag.INPUT)
.put(HtmlAttr.TYPE, type.toString()) .put(HtmlAttr.TYPE, type.toString())
.setStyle(style) .setStyle(style)
.put(HtmlAttr.DISABLED, ""); .put(HtmlAttr.DISABLED, "");
@ -628,7 +625,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree LABEL(String forLabel, Content body) { public static HtmlTree LABEL(String forLabel, Content body) {
return new HtmlTree(TagName.LABEL) return new HtmlTree(HtmlTag.LABEL)
.put(HtmlAttr.FOR, forLabel) .put(HtmlAttr.FOR, forLabel)
.add(body); .add(body);
} }
@ -640,7 +637,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree LI(Content body) { public static HtmlTree LI(Content body) {
return new HtmlTree(TagName.LI) return new HtmlTree(HtmlTag.LI)
.add(body); .add(body);
} }
@ -666,7 +663,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree LINK(String rel, String type, String href, String title) { public static HtmlTree LINK(String rel, String type, String href, String title) {
return new HtmlTree(TagName.LINK) return new HtmlTree(HtmlTag.LINK)
.put(HtmlAttr.REL, rel) .put(HtmlAttr.REL, rel)
.put(HtmlAttr.TYPE, type) .put(HtmlAttr.TYPE, type)
.put(HtmlAttr.HREF, href) .put(HtmlAttr.HREF, href)
@ -680,8 +677,8 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree MAIN() { public static HtmlTree MAIN() {
return new HtmlTree(TagName.MAIN) return new HtmlTree(HtmlTag.MAIN)
.setRole(Role.MAIN); .setRole(HtmlAttr.Role.MAIN);
} }
/** /**
@ -691,8 +688,8 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree MAIN(Content body) { public static HtmlTree MAIN(Content body) {
return new HtmlTree(TagName.MAIN) return new HtmlTree(HtmlTag.MAIN)
.setRole(Role.MAIN) .setRole(HtmlAttr.Role.MAIN)
.add(body); .add(body);
} }
@ -705,7 +702,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree META(String httpEquiv, String content, String charset) { public static HtmlTree META(String httpEquiv, String content, String charset) {
return new HtmlTree(TagName.META) return new HtmlTree(HtmlTag.META)
.put(HtmlAttr.HTTP_EQUIV, httpEquiv) .put(HtmlAttr.HTTP_EQUIV, httpEquiv)
.put(HtmlAttr.CONTENT, content + "; charset=" + charset); .put(HtmlAttr.CONTENT, content + "; charset=" + charset);
} }
@ -718,7 +715,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree META(String name, String content) { public static HtmlTree META(String name, String content) {
return new HtmlTree(TagName.META) return new HtmlTree(HtmlTag.META)
.put(HtmlAttr.NAME, name) .put(HtmlAttr.NAME, name)
.put(HtmlAttr.CONTENT, content); .put(HtmlAttr.CONTENT, content);
} }
@ -730,8 +727,8 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree NAV() { public static HtmlTree NAV() {
return new HtmlTree(TagName.NAV) return new HtmlTree(HtmlTag.NAV)
.setRole(Role.NAVIGATION); .setRole(HtmlAttr.Role.NAVIGATION);
} }
/** /**
@ -741,7 +738,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree NOSCRIPT(Content body) { public static HtmlTree NOSCRIPT(Content body) {
return new HtmlTree(TagName.NOSCRIPT) return new HtmlTree(HtmlTag.NOSCRIPT)
.add(body); .add(body);
} }
@ -752,7 +749,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree OL(HtmlStyle style) { public static HtmlTree OL(HtmlStyle style) {
return new HtmlTree(TagName.OL) return new HtmlTree(HtmlTag.OL)
.setStyle(style); .setStyle(style);
} }
@ -763,7 +760,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree P(Content body) { public static HtmlTree P(Content body) {
return new HtmlTree(TagName.P) return new HtmlTree(HtmlTag.P)
.add(body); .add(body);
} }
@ -786,7 +783,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree PRE(Content body) { public static HtmlTree PRE(Content body) {
return new HtmlTree(TagName.PRE).add(body); return new HtmlTree(HtmlTag.PRE).add(body);
} }
/** /**
@ -797,7 +794,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SCRIPT(String src) { public static HtmlTree SCRIPT(String src) {
return new HtmlTree(TagName.SCRIPT) return new HtmlTree(HtmlTag.SCRIPT)
.put(HtmlAttr.TYPE, "text/javascript") .put(HtmlAttr.TYPE, "text/javascript")
.put(HtmlAttr.SRC, src); .put(HtmlAttr.SRC, src);
@ -810,7 +807,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SECTION(HtmlStyle style) { public static HtmlTree SECTION(HtmlStyle style) {
return new HtmlTree(TagName.SECTION) return new HtmlTree(HtmlTag.SECTION)
.setStyle(style); .setStyle(style);
} }
@ -822,7 +819,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SECTION(HtmlStyle style, Content body) { public static HtmlTree SECTION(HtmlStyle style, Content body) {
return new HtmlTree(TagName.SECTION) return new HtmlTree(HtmlTag.SECTION)
.setStyle(style) .setStyle(style)
.add(body); .add(body);
} }
@ -834,7 +831,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SMALL(Content body) { public static HtmlTree SMALL(Content body) {
return new HtmlTree(TagName.SMALL) return new HtmlTree(HtmlTag.SMALL)
.add(body); .add(body);
} }
@ -845,7 +842,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SPAN(Content body) { public static HtmlTree SPAN(Content body) {
return new HtmlTree(TagName.SPAN) return new HtmlTree(HtmlTag.SPAN)
.add(body); .add(body);
} }
@ -856,7 +853,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SPAN(HtmlStyle styleClass) { public static HtmlTree SPAN(HtmlStyle styleClass) {
return new HtmlTree(TagName.SPAN) return new HtmlTree(HtmlTag.SPAN)
.setStyle(styleClass); .setStyle(styleClass);
} }
@ -880,7 +877,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SPAN_ID(HtmlId id, Content body) { public static HtmlTree SPAN_ID(HtmlId id, Content body) {
return new HtmlTree(TagName.SPAN) return new HtmlTree(HtmlTag.SPAN)
.setId(id) .setId(id)
.add(body); .add(body);
} }
@ -894,7 +891,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SPAN(HtmlId id, HtmlStyle style, Content body) { public static HtmlTree SPAN(HtmlId id, HtmlStyle style, Content body) {
return new HtmlTree(TagName.SPAN) return new HtmlTree(HtmlTag.SPAN)
.setId(id) .setId(id)
.setStyle(style) .setStyle(style)
.add(body); .add(body);
@ -907,7 +904,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SUMMARY(Content body) { public static HtmlTree SUMMARY(Content body) {
return new HtmlTree(TagName.SUMMARY) return new HtmlTree(HtmlTag.SUMMARY)
.add(body); .add(body);
} }
@ -918,7 +915,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree SUP(Content body) { public static HtmlTree SUP(Content body) {
return new HtmlTree(TagName.SUP) return new HtmlTree(HtmlTag.SUP)
.add(body); .add(body);
} }
@ -930,7 +927,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree TD(HtmlStyle style, Content body) { public static HtmlTree TD(HtmlStyle style, Content body) {
return new HtmlTree(TagName.TD) return new HtmlTree(HtmlTag.TD)
.setStyle(style) .setStyle(style)
.add(body); .add(body);
} }
@ -944,7 +941,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree TH(HtmlStyle style, String scope, Content body) { public static HtmlTree TH(HtmlStyle style, String scope, Content body) {
return new HtmlTree(TagName.TH) return new HtmlTree(HtmlTag.TH)
.setStyle(style) .setStyle(style)
.put(HtmlAttr.SCOPE, scope) .put(HtmlAttr.SCOPE, scope)
.add(body); .add(body);
@ -958,7 +955,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree TH(String scope, Content body) { public static HtmlTree TH(String scope, Content body) {
return new HtmlTree(TagName.TH) return new HtmlTree(HtmlTag.TH)
.put(HtmlAttr.SCOPE, scope) .put(HtmlAttr.SCOPE, scope)
.add(body); .add(body);
} }
@ -970,7 +967,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree TITLE(String body) { public static HtmlTree TITLE(String body) {
return new HtmlTree(TagName.TITLE) return new HtmlTree(HtmlTag.TITLE)
.add(body); .add(body);
} }
@ -981,7 +978,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree UL(HtmlStyle style) { public static HtmlTree UL(HtmlStyle style) {
return new HtmlTree(TagName.UL) return new HtmlTree(HtmlTag.UL)
.setStyle(style); .setStyle(style);
} }
@ -994,7 +991,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static HtmlTree UL(HtmlStyle style, Content first, Content... more) { public static HtmlTree UL(HtmlStyle style, Content first, Content... more) {
var ul = new HtmlTree(TagName.UL) var ul = new HtmlTree(HtmlTag.UL)
.setStyle(style); .setStyle(style);
ul.add(first); ul.add(first);
for (Content c : more) { for (Content c : more) {
@ -1013,7 +1010,7 @@ public class HtmlTree extends Content {
* @return the element * @return the element
*/ */
public static <T> HtmlTree UL(HtmlStyle style, Collection<T> items, Function<T,Content> mapper) { public static <T> HtmlTree UL(HtmlStyle style, Collection<T> items, Function<T,Content> mapper) {
return new HtmlTree(TagName.UL) return new HtmlTree(HtmlTag.UL)
.setStyle(style) .setStyle(style)
.addAll(items, mapper); .addAll(items, mapper);
} }
@ -1025,7 +1022,7 @@ public class HtmlTree extends Content {
@Override @Override
public boolean isPhrasingContent() { public boolean isPhrasingContent() {
return tagName.phrasingContent; return tag.blockType == HtmlTag.BlockType.INLINE;
} }
/** /**
@ -1069,7 +1066,7 @@ public class HtmlTree extends Content {
return !isVoid() return !isVoid()
&& !hasContent() && !hasContent()
&& !hasAttr(HtmlAttr.ID) && !hasAttr(HtmlAttr.ID)
&& tagName != TagName.SCRIPT; && tag != HtmlTag.SCRIPT;
} }
/** /**
@ -1080,22 +1077,22 @@ public class HtmlTree extends Content {
* @see <a href="https://www.w3.org/TR/html51/dom.html#kinds-of-content-phrasing-content">Phrasing Content</a> * @see <a href="https://www.w3.org/TR/html51/dom.html#kinds-of-content-phrasing-content">Phrasing Content</a>
*/ */
public boolean isInline() { public boolean isInline() {
return switch (tagName) { return switch (tag) {
case A, BUTTON, BR, CODE, EM, I, IMG, LABEL, SMALL, SPAN, STRONG, SUB, SUP, WBR -> true; case A, BUTTON, BR, CODE, EM, I, IMG, LABEL, SMALL, SPAN, STRONG, SUB, SUP, WBR -> true;
default -> false; default -> false;
}; };
} }
/** /**
* Returns whether or not this is a <em>void</em> element. * Returns whether this is a <em>void</em> element.
* *
* @return whether or not this is a void element * @return whether this is a void element
* *
* @see <a href="https://www.w3.org/TR/html51/syntax.html#void-elements">Void Elements</a> * @see <a href="https://www.w3.org/TR/html51/syntax.html#void-elements">Void Elements</a>
*/ */
public boolean isVoid() { public boolean isVoid() {
return switch (tagName) { return switch (tag) {
case BR, HR, IMG, INPUT, LINK, META, WBR -> true; case BR, COL, FRAME, HR, IMG, INPUT, LINK, META, WBR -> true;
default -> false; default -> false;
}; };
} }
@ -1106,14 +1103,14 @@ public class HtmlTree extends Content {
if (!isInline && !atNewline) { if (!isInline && !atNewline) {
out.write(newline); out.write(newline);
} }
String tagString = tagName.toString(); String tagString = tag.getName();
out.write("<"); out.write("<");
out.write(tagString); out.write(tagString);
for (var attr : attrs.entrySet()) { for (var attr : attrs.entrySet()) {
var key = attr.getKey(); var key = attr.getKey();
var value = attr.getValue(); var value = attr.getValue();
out.write(" "); out.write(" ");
out.write(key.toString()); out.write(key.getName());
if (!value.isEmpty()) { if (!value.isEmpty()) {
out.write("=\""); out.write("=\"");
out.write(value.replace("\"", "&quot;")); out.write(value.replace("\"", "&quot;"));

View File

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -32,8 +32,6 @@ import java.util.Deque;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Objects; import java.util.Objects;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* A utility class for building nested HTML lists. This class is implemented as a * A utility class for building nested HTML lists. This class is implemented as a
* stack of nested list/item pairs where list items are added to the inner-most * stack of nested list/item pairs where list items are added to the inner-most

View File

@ -23,15 +23,13 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* Class for generating raw HTML content to be added to HTML pages of javadoc output. * Class for generating raw HTML content to be added to HTML pages of javadoc output.
*/ */
@ -147,8 +145,8 @@ public class RawHtml extends Content {
Matcher m = tag.matcher(rawHtmlContent); Matcher m = tag.matcher(rawHtmlContent);
while (m.find()) { while (m.find()) {
try { try {
var tn = TagName.of(m.group("tag")); var tn = HtmlTag.of(m.group("tag"));
if (!tn.phrasingContent) { if (tn.blockType != HtmlTag.BlockType.INLINE) {
return false; return false;
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View File

@ -23,13 +23,11 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* A builder for HTML script elements. * A builder for HTML script elements.
*/ */
@ -100,7 +98,7 @@ public class Script {
*/ */
public Content asContent() { public Content asContent() {
ScriptContent scriptContent = new ScriptContent(sb); ScriptContent scriptContent = new ScriptContent(sb);
var script = new HtmlTree(TagName.SCRIPT) { var script = new HtmlTree(HtmlTag.SCRIPT) {
@Override @Override
public HtmlTree add(Content c) { public HtmlTree add(Content c) {
if (c != scriptContent) { if (c != scriptContent) {

View File

@ -23,13 +23,11 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* Class for containing immutable string content for HTML tags of javadoc output. * Class for containing immutable string content for HTML tags of javadoc output.
* Newlines are always represented by {@code \n}. * Newlines are always represented by {@code \n}.

View File

@ -23,13 +23,11 @@
* questions. * questions.
*/ */
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.html;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import jdk.javadoc.internal.doclets.formats.html.Content;
/** /**
* Class for generating string content for HTML tags of javadoc output. * Class for generating string content for HTML tags of javadoc output.
* The content is mutable to the extent that additional content may be added. * The content is mutable to the extent that additional content may be added.

View File

@ -68,9 +68,9 @@
* library in the * library in the
* {@link jdk.javadoc.internal.doclets.formats.html.markup formats.html.markup} package, * {@link jdk.javadoc.internal.doclets.formats.html.markup formats.html.markup} package,
* to create trees (or acyclic graphs) of * to create trees (or acyclic graphs) of
* {@linkplain jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree HTML tree nodes}. * {@linkplain jdk.javadoc.internal.html.HtmlTree HTML tree nodes}.
* Apart from using a common format-neutral supertype, * Apart from using a common format-neutral supertype,
* {@link jdk.javadoc.internal.doclets.formats.html.Content}, the {@code markup} library * {@link jdk.javadoc.internal.html.Content}, the {@code markup} library
* is mostly independent of the rest of the javadoc software stack. * is mostly independent of the rest of the javadoc software stack.
* *
* <dt id="toolkit">Toolkit * <dt id="toolkit">Toolkit

View File

@ -26,7 +26,8 @@
* @test * @test
* @bug 8267574 * @bug 8267574
* @summary check stylesheet names against HtmlStyle * @summary check stylesheet names against HtmlStyle
* @modules jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup * @modules jdk.javadoc/jdk.javadoc.internal.html
* jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup
* jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open * jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open
*/ */
@ -44,10 +45,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.html.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
/** /**
* This test compares the set of CSS class names defined in HtmlStyle * This test compares the set of CSS class names defined in HtmlStyles
* and other files (such as search.js) against the set of CSS class names * and other files (such as search.js) against the set of CSS class names
* defined in the main stylesheet.css provided by the doclet. * defined in the main stylesheet.css provided by the doclet.
* *
@ -185,7 +187,7 @@ public class CheckStylesheetClasses {
} }
Set<String> getHtmlStyleNames() { Set<String> getHtmlStyleNames() {
return Arrays.stream(HtmlStyle.values()) return Arrays.stream(HtmlStyles.values())
.map(HtmlStyle::cssName) .map(HtmlStyle::cssName)
.collect(Collectors.toCollection(TreeSet::new)); .collect(Collectors.toCollection(TreeSet::new));
} }
@ -193,7 +195,7 @@ public class CheckStylesheetClasses {
Set<String> getStylesheetNames() throws IOException { Set<String> getStylesheetNames() throws IOException {
Set<String> names = new TreeSet<>(); Set<String> names = new TreeSet<>();
String stylesheet = "/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css"; String stylesheet = "/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css";
URL url = HtmlStyle.class.getResource(stylesheet); URL url = HtmlStyles.class.getResource(stylesheet);
readStylesheet(url, names); readStylesheet(url, names);
return names; return names;
} }

View File

@ -28,6 +28,7 @@
* @library ../../lib * @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup * @modules jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup
* jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util * jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util
* jdk.javadoc/jdk.javadoc.internal.html
* jdk.javadoc/jdk.javadoc.internal.tool * jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.* * @build javadoc.tester.*
* @run main TestHtmlDocument * @run main TestHtmlDocument
@ -35,6 +36,7 @@
import jdk.javadoc.internal.doclets.formats.html.markup.*; import jdk.javadoc.internal.doclets.formats.html.markup.*;
import jdk.javadoc.internal.html.*;
/** /**
* The class reads each file, complete with newlines, into a string to easily * The class reads each file, complete with newlines, into a string to easily
@ -68,19 +70,19 @@ public class TestHtmlDocument extends JavadocTester {
// Generate the HTML output using the HTML document generation within doclet. // Generate the HTML output using the HTML document generation within doclet.
public static String generateHtmlTree() { public static String generateHtmlTree() {
// Document type for the HTML document // Document type for the HTML document
HtmlTree html = new HtmlTree(TagName.HTML); HtmlTree html = new HtmlTree(HtmlTag.HTML);
HtmlTree head = new HtmlTree(TagName.HEAD); HtmlTree head = new HtmlTree(HtmlTag.HEAD);
HtmlTree title = new HtmlTree(TagName.TITLE); HtmlTree title = new HtmlTree(HtmlTag.TITLE);
// String content within the document // String content within the document
TextBuilder titleContent = new TextBuilder("Markup test"); TextBuilder titleContent = new TextBuilder("Markup test");
title.add(titleContent); title.add(titleContent);
head.add(title); head.add(title);
// Test META tag // Test META tag
HtmlTree meta = new HtmlTree(TagName.META); HtmlTree meta = new HtmlTree(HtmlTag.META);
meta.put(HtmlAttr.NAME, "keywords"); meta.put(HtmlAttr.NAME, "keywords");
meta.put(HtmlAttr.CONTENT, "testContent"); meta.put(HtmlAttr.CONTENT, "testContent");
head.add(meta); head.add(meta);
HtmlTree link = new HtmlTree(TagName.LINK); HtmlTree link = new HtmlTree(HtmlTag.LINK);
link.put(HtmlAttr.REL, "testRel"); link.put(HtmlAttr.REL, "testRel");
link.put(HtmlAttr.HREF, "testLink.html"); link.put(HtmlAttr.HREF, "testLink.html");
head.add(link); head.add(link);
@ -88,10 +90,10 @@ public class TestHtmlDocument extends JavadocTester {
// Comment within the document // Comment within the document
Comment bodyMarker = new Comment("======== START OF BODY ========"); Comment bodyMarker = new Comment("======== START OF BODY ========");
html.add(bodyMarker); html.add(bodyMarker);
HtmlTree body = new HtmlTree(TagName.BODY); HtmlTree body = new HtmlTree(HtmlTag.BODY);
Comment pMarker = new Comment("======== START OF PARAGRAPH ========"); Comment pMarker = new Comment("======== START OF PARAGRAPH ========");
body.add(pMarker); body.add(pMarker);
HtmlTree p = new HtmlTree(TagName.P); HtmlTree p = new HtmlTree(HtmlTag.P);
TextBuilder bodyContent = new TextBuilder( TextBuilder bodyContent = new TextBuilder(
"This document is generated from sample source code and HTML " + "This document is generated from sample source code and HTML " +
"files with examples of a wide variety of Java language constructs: packages, " + "files with examples of a wide variety of Java language constructs: packages, " +
@ -104,24 +106,24 @@ public class TestHtmlDocument extends JavadocTester {
TextBuilder pContent = new TextBuilder(" to <test> out a link."); TextBuilder pContent = new TextBuilder(" to <test> out a link.");
p.add(pContent); p.add(pContent);
body.add(p); body.add(p);
HtmlTree p1 = new HtmlTree(TagName.P); HtmlTree p1 = new HtmlTree(HtmlTag.P);
// Test another version of A tag. // Test another version of A tag.
HtmlTree anchor = new HtmlTree(TagName.A); HtmlTree anchor = new HtmlTree(HtmlTag.A);
anchor.put(HtmlAttr.HREF, "testLink.html"); anchor.put(HtmlAttr.HREF, "testLink.html");
anchor.put(HtmlAttr.ID, "Another version of a tag"); anchor.put(HtmlAttr.ID, "Another version of a tag");
p1.add(anchor); p1.add(anchor);
body.add(p1); body.add(p1);
// Test for empty tags. // Test for empty tags.
HtmlTree dl = new HtmlTree(TagName.DL); HtmlTree dl = new HtmlTree(HtmlTag.DL);
html.add(dl); html.add(dl);
// Test for empty nested tags. // Test for empty nested tags.
HtmlTree dlTree = new HtmlTree(TagName.DL); HtmlTree dlTree = new HtmlTree(HtmlTag.DL);
dlTree.add(new HtmlTree(TagName.DT)); dlTree.add(new HtmlTree(HtmlTag.DT));
dlTree.add(new HtmlTree (TagName.DD)); dlTree.add(new HtmlTree (HtmlTag.DD));
html.add(dlTree); html.add(dlTree);
HtmlTree dlDisplay = new HtmlTree(TagName.DL); HtmlTree dlDisplay = new HtmlTree(HtmlTag.DL);
dlDisplay.add(new HtmlTree(TagName.DT)); dlDisplay.add(new HtmlTree(HtmlTag.DT));
HtmlTree dd = new HtmlTree (TagName.DD); HtmlTree dd = new HtmlTree (HtmlTag.DD);
TextBuilder ddContent = new TextBuilder("Test DD"); TextBuilder ddContent = new TextBuilder("Test DD");
dd.add(ddContent); dd.add(ddContent);
dlDisplay.add(dd); dlDisplay.add(dd);
@ -130,7 +132,7 @@ public class TestHtmlDocument extends JavadocTester {
body.add(emptyString); body.add(emptyString);
Comment emptyComment = new Comment(""); Comment emptyComment = new Comment("");
body.add(emptyComment); body.add(emptyComment);
HtmlTree hr = new HtmlTree(TagName.HR); HtmlTree hr = new HtmlTree(HtmlTag.HR);
body.add(hr); body.add(hr);
html.add(body); html.add(body);
HtmlDocument htmlDoc = new HtmlDocument(html); HtmlDocument htmlDoc = new HtmlDocument(html);

Some files were not shown because too many files have changed in this diff Show More