Skip to content
Permalink
Browse files
8239817: Eliminate use of contentContainer and friends
Reviewed-by: hannesw
  • Loading branch information
jonathan-gibbons committed Mar 4, 2020
1 parent 01ef6d7 commit edb59b58b980584e139aa2e0141094f3d18edddb
Showing with 95 additions and 158 deletions.
  1. +1 −4 ....javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java
  2. +5 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
  3. +1 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java
  4. +3 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java
  5. +4 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
  6. +1 −3 ...k.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
  7. +3 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
  8. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java
  9. +4 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
  10. +1 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java
  11. +1 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
  12. +1 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
  13. +5 −8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java
  14. +5 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java
  15. +1 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
  16. +1 −3 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
  17. +7 −8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java
  18. +7 −8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
  19. +2 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
  20. +3 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SystemPropertiesWriter.java
  21. +4 −7 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
  22. +0 −9 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java
  23. +5 −14 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css
  24. +4 −4 test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java
  25. +1 −2 test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java
  26. +2 −3 test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java
  27. +20 −29 test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
  28. +2 −5 test/langtools/jdk/javadoc/doclet/testOverview/TestOverview.java
@@ -97,10 +97,7 @@ protected void addNavigationBarFooter(Content footer) {
protected void addOverviewHeader(Content main) {
addConfigurationTitle(main);
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
addOverviewComment(div);
main.add(div);
addOverviewComment(main);
}
}

@@ -103,14 +103,14 @@ protected void addLevelInfo(TypeElement parent, Collection<TypeElement> collecti
* @param sset classes which are at the most base level, all the
* other classes in this run will derive from these classes
* @param heading heading for the tree
* @param div the content tree to which the tree will be added
* @param content the content tree to which the tree will be added
*/
protected void addTree(SortedSet<TypeElement> sset, String heading, HtmlTree div) {
addTree(sset, heading, div, false);
protected void addTree(SortedSet<TypeElement> sset, String heading, Content content) {
addTree(sset, heading, content, false);
}

protected void addTree(SortedSet<TypeElement> sset, String heading,
HtmlTree div, boolean isEnums) {
Content content, boolean isEnums) {
if (!sset.isEmpty()) {
TypeElement firstTypeElement = sset.first();
Content headingContent = contents.getContent(heading);
@@ -119,7 +119,7 @@ protected void addTree(SortedSet<TypeElement> sset, String heading,
HtmlTree htmlTree = HtmlTree.SECTION(HtmlStyle.hierarchy, sectionHeading);
addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
sset, isEnums, htmlTree);
div.add(htmlTree);
content.add(htmlTree);
}
}

@@ -149,9 +149,7 @@ protected void addContents(Content content) {
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
content.add(headerDiv);
if (!table.isEmpty()) {
HtmlTree div = new HtmlTree(HtmlTag.DIV, table.toContent());
div.setStyle(HtmlStyle.allClassesContainer);
content.add(div);
content.add(table.toContent());
if (table.needsScript()) {
getMainBodyScript().append(table.getScript());
}
@@ -81,9 +81,8 @@ protected void buildAllPackagesFile() throws DocFileIOException {
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(true));
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.allPackagesContainer);
addPackages(div);
Content mainContent = new ContentBuilder();
addPackages(mainContent);
Content titleContent = contents.allPackagesLabel;
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, titleContent);
@@ -96,7 +95,7 @@ protected void buildAllPackagesFile() throws DocFileIOException {
bodyTree.add(new BodyContents()
.setHeader(headerContent)
.addMainContent(headerDiv)
.addMainContent(div)
.addMainContent(mainContent)
.setFooter(footer)
.toContent());
printHtmlDocument(null, "package index", bodyTree);
@@ -219,15 +219,14 @@ public static void generate(HtmlConfiguration configuration, ClassUseMapper mapp
*/
protected void generateClassUseFile() throws DocFileIOException {
HtmlTree body = getClassUseHeader();
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.classUseContainer);
Content mainContent = new ContentBuilder();
if (pkgSet.size() > 0) {
addClassUse(div);
addClassUse(mainContent);
} else {
div.add(contents.getContent("doclet.ClassUse_No.usage.of.0",
mainContent.add(contents.getContent("doclet.ClassUse_No.usage.of.0",
utils.getFullyQualifiedName(typeElement)));
}
bodyContents.addMainContent(div);
bodyContents.addMainContent(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(false));
@@ -149,9 +149,7 @@ public void addContentsList(Content contentListTree) {

@Override
public Content getConstantSummaries() {
HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
summariesDiv.setStyle(HtmlStyle.constantValuesContainer);
return summariesDiv;
return new ContentBuilder();
}

@Override
@@ -283,8 +283,7 @@ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
HtmlTree body = getHeader();
bodyContents.addMainContent(getContentsList(deprapi));
String memberTableSummary;
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
Content content = new ContentBuilder();
for (DeprElementKind kind : DeprElementKind.values()) {
if (deprapi.hasDocumentation(kind)) {
memberTableSummary = resources.getText("doclet.Member_Table_Summary",
@@ -293,10 +292,10 @@ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
TableHeader memberTableHeader = new TableHeader(
contents.getContent(getHeaderKey(kind)), contents.descriptionLabel);
addDeprecatedAPI(deprapi.getSet(kind), getAnchorName(kind),
getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
getHeadingKey(kind), memberTableSummary, memberTableHeader, content);
}
}
bodyContents.addMainContent(div);
bodyContents.addMainContent(content);
HtmlTree htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(false));
@@ -208,7 +208,7 @@ private void handleHtmlFile(DocFile srcfile, DocPath dstPath) throws DocFileIOEx
docletWriter.addBottom(footer);
htmlContent.add(new BodyContents()
.setHeader(headerContent)
.addMainContent(HtmlTree.DIV(HtmlStyle.contentContainer, pageContent))
.addMainContent(pageContent)
.setFooter(footer)
.toContent());
docletWriter.printHtmlDocument(Collections.emptyList(), null, localTagsContent, Collections.emptyList(), htmlContent);
@@ -346,11 +346,9 @@ protected void addHelpFileContents(Content contentTree) {
htmlTree.add(searchRefer);
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));

Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
divContent.add(new HtmlTree(HtmlTag.HR));
Content footnote = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase,
contents.getContent("doclet.help.footnote"));
divContent.add(footnote);
contentTree.add(divContent);
contentTree.add(ul);
contentTree.add(new HtmlTree(HtmlTag.HR));
contentTree.add(HtmlTree.SPAN(HtmlStyle.emphasizedPhrase,
contents.getContent("doclet.help.footnote")));
}
}
@@ -117,8 +117,7 @@ protected void addIndex(Content main) {
}
}

Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
main.add(div);
main.add(table.toContent());

if (table.needsScript()) {
mainBodyScript.append(table.getScript());
@@ -218,9 +218,7 @@ public Content getModuleHeader(String heading) {
*/
@Override
public Content getContentHeader() {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
return div;
return new ContentBuilder();
}

/**
@@ -118,8 +118,7 @@ protected void addIndex(Content main) {
}
}

Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
main.add(div);
main.add(table.toContent());

if (table.needsScript()) {
getMainBodyScript().append(table.getScript());
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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
@@ -108,13 +108,10 @@ protected void generatePackageTreeFile() throws DocFileIOException {
addLinkToMainTree(div);
}
mainContent.add(div);
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
mainContent.add(divTree);
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", mainContent);
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", mainContent);
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", mainContent);
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", mainContent, true);
bodyContents.addMainContent(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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
@@ -125,14 +125,13 @@ public static void generate(HtmlConfiguration configuration,
*/
protected void generatePackageUseFile() throws DocFileIOException {
HtmlTree body = getPackageUseHeader();
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
Content mainContent = new ContentBuilder();
if (usingPackageToUsedClasses.isEmpty()) {
div.add(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
mainContent.add(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
} else {
addPackageUse(div);
addPackageUse(mainContent);
}
bodyContents.addMainContent(div);
bodyContents.addMainContent(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(false));
@@ -134,9 +134,7 @@ public Content getPackageHeader(String heading) {

@Override
public Content getContentHeader() {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
return div;
return new ContentBuilder();
}

/**
@@ -225,9 +225,7 @@ public Content getClassContentHeader() {
*/
@Override
public void addSerializedContent(Content serializedTreeContent) {
HtmlTree divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
serializedTreeContent);
bodyContents.addMainContent(divContent);
bodyContents.addMainContent(serializedTreeContent);
}

@Override
@@ -99,22 +99,21 @@ protected void generateIndexFile() throws DocFileIOException {
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(true));
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
Content mainContent = new ContentBuilder();
elements = new TreeSet<>(indexBuilder.asMap().keySet());
elements.addAll(tagSearchIndexMap.keySet());
addLinksForIndexes(divTree);
addLinksForIndexes(mainContent);
for (Character unicode : elements) {
if (tagSearchIndexMap.get(unicode) == null) {
addContents(unicode, indexBuilder.getMemberList(unicode), divTree);
addContents(unicode, indexBuilder.getMemberList(unicode), mainContent);
} else if (indexBuilder.getMemberList(unicode) == null) {
addSearchContents(unicode, tagSearchIndexMap.get(unicode), divTree);
addSearchContents(unicode, tagSearchIndexMap.get(unicode), mainContent);
} else {
addContents(unicode, indexBuilder.getMemberList(unicode),
tagSearchIndexMap.get(unicode), divTree);
tagSearchIndexMap.get(unicode), mainContent);
}
}
addLinksForIndexes(divTree);
addLinksForIndexes(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(false));
@@ -124,7 +123,7 @@ protected void generateIndexFile() throws DocFileIOException {
.addMainContent(HtmlTree.DIV(HtmlStyle.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.Index"))))
.addMainContent(divTree)
.addMainContent(mainContent)
.setFooter(footer)
.toContent());
createSearchIndexFiles();
@@ -130,19 +130,18 @@ protected void generateIndexFile(Character unicode) throws DocFileIOException {
main.add(HtmlTree.DIV(HtmlStyle.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.Index"))));
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
addLinksForIndexes(divTree);
Content mainContent = new ContentBuilder();
addLinksForIndexes(mainContent);
if (tagSearchIndexMap.get(unicode) == null) {
addContents(unicode, indexBuilder.getMemberList(unicode), divTree);
addContents(unicode, indexBuilder.getMemberList(unicode), mainContent);
} else if (indexBuilder.getMemberList(unicode) == null) {
addSearchContents(unicode, tagSearchIndexMap.get(unicode), divTree);
addSearchContents(unicode, tagSearchIndexMap.get(unicode), mainContent);
} else {
addContents(unicode, indexBuilder.getMemberList(unicode),
tagSearchIndexMap.get(unicode), divTree);
tagSearchIndexMap.get(unicode), mainContent);
}
addLinksForIndexes(divTree);
main.add(divTree);
addLinksForIndexes(mainContent);
main.add(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(false));
@@ -32,6 +32,7 @@

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.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -179,9 +180,7 @@ public void addInheritedMemberSummary(AbstractMemberWriter mw,
* @return a content tree the document content header
*/
public Content getContentHeader() {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.contentContainer);
return div;
return new ContentBuilder();
}

/**
@@ -98,15 +98,14 @@ protected void buildSystemPropertiesPage() throws DocFileIOException {
navBar.setUserHeader(getUserHeaderFooter(true));
header.add(navBar.getContent(true));
bodyTree.add(header);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.systemPropertiesContainer);
addSystemProperties(div);
Content mainContent = new ContentBuilder();
addSystemProperties(mainContent);
Content titleContent = new StringContent(resources.getText("doclet.systemProperties"));
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
mainTree.add(headerDiv);
mainTree.add(div);
mainTree.add(mainContent);
bodyTree.add(mainTree);
Content footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
@@ -115,13 +115,10 @@ public void generateTreeFile() throws DocFileIOException {
addPackageTreeLinks(div);
Content mainContent = new ContentBuilder();
mainContent.add(div);
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
mainContent.add(divTree);
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", mainContent);
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", mainContent);
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", mainContent);
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", mainContent, true);
HtmlTree footerTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footerTree.add(navBar.getContent(false));

0 comments on commit edb59b5

Please sign in to comment.