--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -33,6 +33,7 @@
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -81,30 +82,30 @@
/**
* Adds the navigation bar header to the documentation tree.
*
- * @param body the document tree to which the navigation bar header will be added
+ * @param header the document tree to which the navigation bar header will be added
*/
- protected abstract void addNavigationBarHeader(Content body);
+ protected abstract void addNavigationBarHeader(Content header);
/**
* Adds the navigation bar footer to the documentation tree.
*
- * @param body the document tree to which the navigation bar footer will be added
+ * @param footer the document tree to which the navigation bar footer will be added
*/
- protected abstract void addNavigationBarFooter(Content body);
+ protected abstract void addNavigationBarFooter(Content footer);
/**
* Adds the overview header to the documentation tree.
*
- * @param body the document tree to which the overview header will be added
+ * @param main the document tree to which the overview header will be added
*/
- protected abstract void addOverviewHeader(Content body);
+ protected abstract void addOverviewHeader(Content main);
/**
* Adds the modules list to the documentation tree.
*
- * @param body the document tree to which the modules list will be added
+ * @param main the document tree to which the modules list will be added
*/
- protected abstract void addModulesList(Content body);
+ protected abstract void addModulesList(Content main);
/**
* Adds the module packages list to the documentation tree.
@@ -112,11 +113,11 @@
* @param modules the set of modules
* @param text caption for the table
* @param tableSummary summary for the table
- * @param body the document tree to which the modules list will be added
+ * @param main the document tree to which the modules list will be added
* @param mdle the module being documented
*/
protected abstract void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
- String tableSummary, Content body, ModuleElement mdle);
+ String tableSummary, Content main, ModuleElement mdle);
/**
* Generate and prints the contents in the module index file. Call appropriate
@@ -130,11 +131,17 @@
protected void buildModuleIndexFile(String title, boolean includeScript) throws DocFileIOException {
String windowOverview = configuration.getText(title);
Content body = getBody(includeScript, getWindowTitle(windowOverview));
- addNavigationBarHeader(body);
- addOverviewHeader(body);
- addIndex(body);
- addOverview(body);
- addNavigationBarFooter(body);
+ Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
+ addNavigationBarHeader(header);
+ Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
+ addOverviewHeader(main);
+ addIndex(header, main);
+ addOverview(main);
+ Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
+ addNavigationBarFooter(footer);
+ body.addContent(header);
+ body.addContent(main);
+ body.addContent(footer);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
}
@@ -153,11 +160,17 @@
boolean includeScript, ModuleElement mdle) throws DocFileIOException {
String windowOverview = configuration.getText(title);
Content body = getBody(includeScript, getWindowTitle(windowOverview));
- addNavigationBarHeader(body);
- addOverviewHeader(body);
- addModulePackagesIndex(body, mdle);
- addOverview(body);
- addNavigationBarFooter(body);
+ Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
+ addNavigationBarHeader(header);
+ Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
+ addOverviewHeader(main);
+ addModulePackagesIndex(header, main, mdle);
+ addOverview(main);
+ Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
+ addNavigationBarFooter(footer);
+ body.addContent(header);
+ body.addContent(main);
+ body.addContent(footer);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
}
@@ -165,33 +178,35 @@
/**
* Default to no overview, override to add overview.
*
- * @param body the document tree to which the overview will be added
+ * @param main the document tree to which the overview will be added
*/
- protected void addOverview(Content body) { }
+ protected void addOverview(Content main) { }
/**
* Adds the frame or non-frame module index to the documentation tree.
*
- * @param body the document tree to which the index will be added
+ * @param header the document tree to which the navigational links will be added
+ * @param main the document tree to which the modules list will be added
*/
- protected void addIndex(Content body) {
+ protected void addIndex(Content header, Content main) {
addIndexContents(configuration.modules, "doclet.Module_Summary",
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Module_Summary"),
- configuration.getText("doclet.modules")), body);
+ configuration.getText("doclet.modules")), header, main);
}
/**
* Adds the frame or non-frame module packages index to the documentation tree.
*
- * @param body the document tree to which the index will be added
+ * @param header the document tree to which the navigational links will be added
+ * @param main the document tree to which the module packages list will be added
* @param mdle the module being documented
*/
- protected void addModulePackagesIndex(Content body, ModuleElement mdle) {
+ protected void addModulePackagesIndex(Content header, Content main, ModuleElement mdle) {
addModulePackagesIndexContents("doclet.Module_Summary",
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Module_Summary"),
- configuration.getText("doclet.modules")), body, mdle);
+ configuration.getText("doclet.modules")), header, main, mdle);
}
/**
@@ -201,20 +216,19 @@
* @param modules the modules to be documented
* @param text string which will be used as the heading
* @param tableSummary summary for the table
- * @param body the document tree to which the index contents will be added
+ * @param header the document tree to which the navgational links will be added
+ * @param main the document tree to which the modules list will be added
*/
protected void addIndexContents(Collection<ModuleElement> modules, String text,
- String tableSummary, Content body) {
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
- ? HtmlTree.NAV()
- : new HtmlTree(HtmlTag.DIV);
+ String tableSummary, Content header, Content main) {
+ HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
htmlTree.setStyle(HtmlStyle.indexNav);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
addAllClassesLink(ul);
addAllPackagesLink(ul);
htmlTree.addContent(ul);
- body.addContent(htmlTree);
- addModulesList(body);
+ header.addContent(htmlTree);
+ addModulesList(main);
}
/**
@@ -223,22 +237,21 @@
*
* @param text string which will be used as the heading
* @param tableSummary summary for the table
- * @param body the document tree to which the index contents will be added
+ * @param header the document tree to which the navigational links will be added
+ * @param main the document tree to which the module packages list will be added
* @param mdle the module being documented
*/
protected void addModulePackagesIndexContents(String text,
- String tableSummary, Content body, ModuleElement mdle) {
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
- ? HtmlTree.NAV()
- : new HtmlTree(HtmlTag.DIV);
+ String tableSummary, Content header, Content main, ModuleElement mdle) {
+ HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
htmlTree.setStyle(HtmlStyle.indexNav);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
addAllClassesLink(ul);
addAllPackagesLink(ul);
addAllModulesLink(ul);
htmlTree.addContent(ul);
- body.addContent(htmlTree);
- addModulePackagesList(modules, text, tableSummary, body, mdle);
+ header.addContent(htmlTree);
+ addModulePackagesList(modules, text, tableSummary, main, mdle);
}
/**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -29,6 +29,7 @@
import javax.lang.model.element.PackageElement;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -78,9 +79,9 @@
/**
* Adds the navigation bar header to the documentation tree.
*
- * @param body the document tree to which the navigation bar header will be added
+ * @param header the document tree to which the navigation bar header will be added
*/
- protected abstract void addNavigationBarHeader(Content body);
+ protected abstract void addNavigationBarHeader(Content header);
/**
* Adds the navigation bar footer to the documentation tree.
@@ -92,16 +93,16 @@
/**
* Adds the overview header to the documentation tree.
*
- * @param body the document tree to which the overview header will be added
+ * @param footer the document tree to which the overview header will be added
*/
- protected abstract void addOverviewHeader(Content body);
+ protected abstract void addOverviewHeader(Content footer);
/**
* Adds the packages list to the documentation tree.
*
- * @param body the document tree to which the packages list will be added
+ * @param main the document tree to which the packages list will be added
*/
- protected abstract void addPackagesList(Content body);
+ protected abstract void addPackagesList(Content main);
/**
* Generate and prints the contents in the package index file. Call appropriate
@@ -115,11 +116,17 @@
protected void buildPackageIndexFile(String title, boolean includeScript) throws DocFileIOException {
String windowOverview = configuration.getText(title);
Content body = getBody(includeScript, getWindowTitle(windowOverview));
- addNavigationBarHeader(body);
- addOverviewHeader(body);
- addIndex(body);
- addOverview(body);
- addNavigationBarFooter(body);
+ Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
+ addNavigationBarHeader(header);
+ Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
+ addOverviewHeader(main);
+ addIndex(header, main);
+ addOverview(main);
+ Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
+ addNavigationBarFooter(footer);
+ body.addContent(header);
+ body.addContent(main);
+ body.addContent(footer);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
}
@@ -127,30 +134,30 @@
/**
* Default to no overview, override to add overview.
*
- * @param body the document tree to which the overview will be added
+ * @param main the document tree to which the overview will be added
*/
- protected void addOverview(Content body) { }
+ protected void addOverview(Content main) { }
/**
* Adds the frame or non-frame package index to the documentation tree.
*
- * @param body the document tree to which the index will be added
+ * @param header the document tree to which the navigation links will be added
+ * @param main the document tree to which the packages list will be added
*/
- protected void addIndex(Content body) {
- addIndexContents(body);
+ protected void addIndex(Content header, Content main) {
+ addIndexContents(header, main);
}
/**
* Adds package index contents. Call appropriate methods from
* the sub-classes. Adds it to the body HtmlTree
*
- * @param body the document tree to which the index contents will be added
+ * @param header the document tree to which navigation links will be added
+ * @param main the document tree to which the packages list will be added
*/
- protected void addIndexContents(Content body) {
+ protected void addIndexContents(Content header, Content main) {
if (!packages.isEmpty()) {
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
- ? HtmlTree.NAV()
- : new HtmlTree(HtmlTag.DIV);
+ HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
htmlTree.setStyle(HtmlStyle.indexNav);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
addAllClassesLink(ul);
@@ -158,8 +165,8 @@
addAllModulesLink(ul);
}
htmlTree.addContent(ul);
- body.addContent(htmlTree);
- addPackagesList(body);
+ header.addContent(htmlTree);
+ addPackagesList(main);
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -29,6 +29,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -111,15 +112,15 @@
protected void buildAllClassesFile(boolean wantFrames) throws DocFileIOException {
String label = configuration.getText("doclet.All_Classes");
Content body = getBody(false, getWindowTitle(label));
+ Content htmlTree = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
HtmlStyle.bar, contents.allClassesLabel);
- body.addContent(heading);
+ htmlTree.addContent(heading);
Content ul = new HtmlTree(HtmlTag.UL);
// Generate the class links and add it to the tdFont tree.
addAllClasses(ul, wantFrames);
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
- ? HtmlTree.MAIN(HtmlStyle.indexContainer, ul)
- : HtmlTree.DIV(HtmlStyle.indexContainer, ul);
+ HtmlTree div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
+ htmlTree.addContent(div);
body.addContent(htmlTree);
printHtmlDocument(null, false, body);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -29,6 +29,7 @@
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
import java.util.*;
+import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -2105,4 +2106,20 @@
Script getMainBodyScript() {
return mainBodyScript;
}
+
+ /**
+ * Creates the HTML tag if the tag is supported by this specific HTML version
+ * otherwise return the Content instance provided by Supplier ifNotSupported.
+ * @param tag the HTML tag
+ * @param ifSupported create this instance if HTML tag is supported
+ * @param ifNotSupported create this instance if HTML tag is not supported
+ * @return
+ */
+ protected Content createTagIfAllowed(HtmlTag tag, Supplier<Content> ifSupported, Supplier<Content> ifNotSupported) {
+ if (configuration.allowTag(tag)) {
+ return ifSupported.get();
+ } else {
+ return ifNotSupported.get();
+ }
+ }
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -83,19 +83,17 @@
/**
* {@inheritDoc}
*/
- protected void addModulesList(Content body) {
+ protected void addModulesList(Content main) {
Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true,
contents.modulesLabel);
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
- ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
- : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+ HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.setTitle(contents.modulesLabel);
for (ModuleElement mdle: configuration.modules) {
ul.addContent(getModuleLink(mdle));
}
htmlTree.addContent(ul);
- body.addContent(htmlTree);
+ main.addContent(htmlTree);
}
/**
@@ -126,7 +124,7 @@
/**
* {@inheritDoc}
*/
- protected void addNavigationBarHeader(Content body) {
+ protected void addNavigationBarHeader(Content header) {
Content headerContent;
if (configuration.packagesheader.length() > 0) {
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
@@ -135,7 +133,7 @@
}
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.bar, headerContent);
- body.addContent(heading);
+ header.addContent(heading);
}
/**
@@ -173,12 +171,12 @@
/**
* {@inheritDoc}
*/
- protected void addNavigationBarFooter(Content body) {
+ protected void addNavigationBarFooter(Content footer) {
Content p = HtmlTree.P(Contents.SPACE);
- body.addContent(p);
+ footer.addContent(p);
}
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
- String tableSummary, Content body, ModuleElement mdle) {
+ String tableSummary, Content main, ModuleElement mdle) {
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -57,11 +57,6 @@
public class ModuleIndexWriter extends AbstractModuleIndexWriter {
/**
- * HTML tree for main tag.
- */
- private final HtmlTree htmlTree = HtmlTree.MAIN();
-
- /**
* Construct the ModuleIndexWriter.
* @param configuration the configuration object
* @param filename the name of the generated file
@@ -85,22 +80,22 @@
/**
* Add the module index.
*
- * @param body the documentation tree to which the index will be added
+ * @param header the documentation tree to which the navigational links will be added
+ * @param main the documentation tree to which the modules list will be added
*/
@Override
- protected void addIndex(Content body) {
- addIndexContents(body);
+ protected void addIndex(Content header, Content main) {
+ addIndexContents(header, main);
}
/**
* Adds module index contents.
*
- * @param body the document tree to which the index contents will be added
+ * @param header the document tree to which the navigational links will be added
+ * @param main the document tree to which the modules list will be added
*/
- protected void addIndexContents(Content body) {
- HtmlTree htmltree = (configuration.allowTag(HtmlTag.NAV))
- ? HtmlTree.NAV()
- : new HtmlTree(HtmlTag.DIV);
+ protected void addIndexContents(Content header, Content main) {
+ HtmlTree htmltree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
htmltree.setStyle(HtmlStyle.indexNav);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
addAllClassesLink(ul);
@@ -108,17 +103,17 @@
addAllModulesLink(ul);
}
htmltree.addContent(ul);
- body.addContent(htmltree);
- addModulesList(body);
+ header.addContent(htmltree);
+ addModulesList(main);
}
/**
* Add the list of modules.
*
- * @param body the content tree to which the module list will be added
+ * @param main the content tree to which the module list will be added
*/
@Override
- protected void addModulesList(Content body) {
+ protected void addModulesList(Content main) {
Map<String, SortedSet<ModuleElement>> groupModuleMap
= configuration.group.groupModules(configuration.modules);
@@ -154,11 +149,7 @@
}
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- } else {
- body.addContent(div);
- }
+ main.addContent(div);
if (table.needsScript()) {
mainBodyScript.append(table.getScript());
@@ -171,20 +162,16 @@
* summary at the top of the page and generate a link to the description,
* which is added at the end of this page.
*
- * @param body the documentation tree to which the overview header will be added
+ * @param main the documentation tree to which the overview header will be added
*/
@Override
- protected void addOverviewHeader(Content body) {
- addConfigurationTitle(body);
+ 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);
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- } else {
- body.addContent(div);
- }
+ main.addContent(div);
}
}
@@ -202,58 +189,34 @@
}
/**
- * For HTML 5, add the htmlTree to the body. For HTML 4, do nothing.
- *
- * @param body the documentation tree to which the overview will be added
- */
- @Override
- protected void addOverview(Content body) {
- if (configuration.allowTag(HtmlTag.MAIN)) {
- body.addContent(htmlTree);
- }
- }
-
- /**
* Adds the top text (from the -top option), the upper
* navigation bar, and then the title (from the"-title"
* option), at the top of page.
*
- * @param body the documentation tree to which the navigation bar header will be added
+ * @param header the documentation tree to which the navigation bar header will be added
*/
@Override
- protected void addNavigationBarHeader(Content body) {
- Content tree = (configuration.allowTag(HtmlTag.HEADER))
- ? HtmlTree.HEADER()
- : body;
- addTop(tree);
+ protected void addNavigationBarHeader(Content header) {
+ addTop(header);
navBar.setUserHeader(getUserHeaderFooter(true));
- tree.addContent(navBar.getContent(true));
- if (configuration.allowTag(HtmlTag.HEADER)) {
- body.addContent(tree);
- }
+ header.addContent(navBar.getContent(true));
}
/**
* Adds the lower navigation bar and the bottom text
* (from the -bottom option) at the bottom of page.
*
- * @param body the documentation tree to which the navigation bar footer will be added
+ * @param footer the documentation tree to which the navigation bar footer will be added
*/
@Override
- protected void addNavigationBarFooter(Content body) {
- Content htmltree = (configuration.allowTag(HtmlTag.FOOTER))
- ? HtmlTree.FOOTER()
- : body;
+ protected void addNavigationBarFooter(Content footer) {
navBar.setUserFooter(getUserHeaderFooter(false));
- htmltree.addContent(navBar.getContent(false));
- addBottom(htmltree);
- if (configuration.allowTag(HtmlTag.FOOTER)) {
- body.addContent(htmltree);
- }
+ footer.addContent(navBar.getContent(false));
+ addBottom(footer);
}
@Override
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
- String tableSummary, Content body, ModuleElement mdle) {
+ String tableSummary, Content main, ModuleElement mdle) {
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -84,15 +84,13 @@
* {@inheritDoc}
*/
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
- String tableSummary, Content body, ModuleElement mdle) {
+ String tableSummary, Content main, ModuleElement mdle) {
Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
getTargetModuleLink("classFrame", profNameContent, mdle));
heading.addContent(Contents.SPACE);
heading.addContent(contents.packagesLabel);
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
- ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
- : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+ HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.setTitle(contents.packagesLabel);
List<PackageElement> packages = new ArrayList<>(modules.get(mdle));
@@ -102,7 +100,7 @@
}
}
htmlTree.addContent(ul);
- body.addContent(htmlTree);
+ main.addContent(htmlTree);
}
/**
@@ -157,7 +155,7 @@
/**
* {@inheritDoc}
*/
- protected void addNavigationBarHeader(Content body) {
+ protected void addNavigationBarHeader(Content header) {
Content headerContent;
if (configuration.packagesheader.length() > 0) {
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
@@ -166,7 +164,7 @@
}
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.bar, headerContent);
- body.addContent(heading);
+ header.addContent(heading);
}
/**
@@ -232,8 +230,8 @@
/**
* {@inheritDoc}
*/
- protected void addNavigationBarFooter(Content body) {
+ protected void addNavigationBarFooter(Content footer) {
Content p = HtmlTree.P(Contents.SPACE);
- body.addContent(p);
+ footer.addContent(p);
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -77,12 +77,10 @@
* {@inheritDoc}
*/
@Override
- protected void addPackagesList(Content body) {
+ protected void addPackagesList(Content main) {
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
contents.packagesLabel);
- HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
- ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
- : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+ HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.setTitle(contents.packagesLabel);
for (PackageElement aPackage : packages) {
@@ -94,7 +92,7 @@
}
}
htmlTree.addContent(ul);
- body.addContent(htmlTree);
+ main.addContent(htmlTree);
}
/**
@@ -124,7 +122,7 @@
* {@inheritDoc}
*/
@Override
- protected void addNavigationBarHeader(Content body) {
+ protected void addNavigationBarHeader(Content header) {
Content headerContent;
if (configuration.packagesheader.length() > 0) {
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
@@ -133,7 +131,7 @@
}
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.bar, headerContent);
- body.addContent(heading);
+ header.addContent(heading);
}
/**
@@ -175,8 +173,8 @@
* {@inheritDoc}
*/
@Override
- protected void addNavigationBarFooter(Content body) {
+ protected void addNavigationBarFooter(Content footer) {
Content p = HtmlTree.P(Contents.SPACE);
- body.addContent(p);
+ footer.addContent(p);
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Tue Sep 18 21:46:17 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Wed Sep 19 12:14:53 2018 +0530
@@ -57,11 +57,6 @@
public class PackageIndexWriter extends AbstractPackageIndexWriter {
/**
- * HTML tree for main tag.
- */
- private final HtmlTree htmlTree = HtmlTree.MAIN();
-
- /**
* Construct the PackageIndexWriter. Also constructs the grouping
* information as provided on the command line by "-group" option. Stores
* the order of groups specified by the user.
@@ -90,18 +85,19 @@
* Depending upon the grouping information and their titles, add
* separate table indices for each package group.
*
- * @param body the documentation tree to which the index will be added
+ * @param header the documentation tree to which the navigational links will be added
+ * @param main the documentation tree to which the packages list will be added
*/
@Override
- protected void addIndex(Content body) {
- addIndexContents(body);
+ protected void addIndex(Content header, Content main) {
+ addIndexContents(header, main);
}
/**
* {@inheritDoc}
*/
@Override
- protected void addPackagesList(Content body) {
+ protected void addPackagesList(Content main) {
Map<String, SortedSet<PackageElement>> groupPackageMap
= configuration.group.groupPackages(packages);
@@ -136,11 +132,7 @@
}
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- } else {
- body.addContent(div);
- }
+ main.addContent(div);
if (table.needsScript()) {
getMainBodyScript().append(table.getScript());
@@ -153,20 +145,16 @@
* summary at the top of the page and generate a link to the description,
* which is added at the end of this page.
*
- * @param body the documentation tree to which the overview header will be added
+ * @param main the documentation tree to which the overview header will be added
*/
@Override
- protected void addOverviewHeader(Content body) {
- addConfigurationTitle(body);
+ 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);
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- } else {
- body.addContent(div);
- }
+ main.addContent(div);
}
}
@@ -184,53 +172,29 @@
}
/**
- * For HTML 5, add the htmlTree to the body. For HTML 4, do nothing.
- *
- * @param body the documentation tree to which the overview will be added
- */
- @Override
- protected void addOverview(Content body) {
- if (configuration.allowTag(HtmlTag.MAIN)) {
- body.addContent(htmlTree);
- }
- }
-
- /**
* Adds the top text (from the -top option), the upper
* navigation bar, and then the title (from the"-title"
* option), at the top of page.
*
- * @param body the documentation tree to which the navigation bar header will be added
+ * @param header the documentation tree to which the navigation bar header will be added
*/
@Override
- protected void addNavigationBarHeader(Content body) {
- Content tree = (configuration.allowTag(HtmlTag.HEADER))
- ? HtmlTree.HEADER()
- : body;
- addTop(tree);
+ protected void addNavigationBarHeader(Content header) {
+ addTop(header);
navBar.setUserHeader(getUserHeaderFooter(true));
- tree.addContent(navBar.getContent(true));
- if (configuration.allowTag(HtmlTag.HEADER)) {
- body.addContent(tree);
- }
+ header.addContent(navBar.getContent(true));
}
/**
* Adds the lower navigation bar and the bottom text
* (from the -bottom option) at the bottom of page.
*
- * @param body the documentation tree to which the navigation bar footer will be added
+ * @param footer the documentation tree to which the navigation bar footer will be added
*/
@Override
- protected void addNavigationBarFooter(Content body) {
- Content tree = (configuration.allowTag(HtmlTag.FOOTER))
- ? HtmlTree.FOOTER()
- : body;
+ protected void addNavigationBarFooter(Content footer) {
navBar.setUserFooter(getUserHeaderFooter(false));
- tree.addContent(navBar.getContent(false));
- addBottom(tree);
- if (configuration.allowTag(HtmlTag.FOOTER)) {
- body.addContent(tree);
- }
+ footer.addContent(navBar.getContent(false));
+ addBottom(footer);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLankmarkRegions.java Wed Sep 19 12:14:53 2018 +0530
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+/*
+ * @test
+ * @bug 8210047
+ * @summary some pages contains content outside of landmark region
+ * @library /tools/lib ../lib
+ * @modules
+ * jdk.javadoc/jdk.javadoc.internal.tool
+ * jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build JavadocTester
+ * @run main TestHtmlLankmarkRegions
+ */
+
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import builder.ClassBuilder;
+import toolbox.ModuleBuilder;
+import toolbox.ToolBox;
+
+public class TestHtmlLankmarkRegions extends JavadocTester {
+
+ final ToolBox tb;
+
+ public static void main(String... args) throws Exception {
+ TestHtmlLankmarkRegions tester = new TestHtmlLankmarkRegions();
+ tester.runTests(m -> new Object[]{Paths.get(m.getName())});
+ }
+
+ TestHtmlLankmarkRegions() {
+ tb = new ToolBox();
+ }
+
+ @Test
+ void testModules(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createModules(srcDir);
+
+ Path outDir = base.resolve("out");
+ javadoc("-d", outDir.toString(),
+ "-doctitle", "Document Title",
+ "-header", "Test Header",
+ "--frames",
+ "--module-source-path", srcDir.toString(),
+ "--module", "m1,m2");
+
+ checkExit(Exit.OK);
+
+ checkOrder("module-overview-frame.html",
+ "<header role=\"banner\">\n"
+ + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<nav role=\"navigation\" class=\"indexNav\">",
+ "<main role=\"main\">\n"
+ + "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"Modules\">Modules</h2>\n"
+ + "<ul title=\"Modules\">",
+ "<footer role=\"contentinfo\">");
+
+ checkOrder("m1/module-frame.html",
+ "<header role=\"banner\">\n"
+ + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<nav role=\"navigation\" class=\"indexNav\">",
+ "<main role=\"main\">\n"
+ + "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"m1\"><a href=\"module-summary.html\" target=\"classFrame\">m1</a> Packages</h2>",
+ "<footer role=\"contentinfo\">");
+
+ checkOrder("overview-summary.html",
+ "<header role=\"banner\">\n"
+ + "<nav role=\"navigation\">",
+ "<main role=\"main\">\n"
+ + "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>",
+ "<footer role=\"contentinfo\">\n"
+ + "<nav role=\"navigation\">");
+ }
+
+ @Test
+ void testModulesHtml4(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createModules(srcDir);
+
+ Path outDir = base.resolve("out2");
+ javadoc("-d", outDir.toString(),
+ "-doctitle", "Document Title",
+ "-header", "Test Header",
+ "--frames",
+ "--module-source-path", srcDir.toString(),
+ "--module", "m1,m2",
+ "-html4");
+
+ checkExit(Exit.OK);
+
+ checkOrder("module-overview-frame.html",
+ "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<div class=\"indexNav\">",
+ "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"Modules\">Modules</h2>\n"
+ + "<ul title=\"Modules\">");
+
+ checkOrder("m1/module-frame.html",
+ "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<div class=\"indexNav\">",
+ "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"m1\"><a href=\"module-summary.html\" target=\"classFrame\">m1</a> Packages</h2>");
+
+ checkOrder("overview-summary.html",
+ "<div class=\"fixedNav\">",
+ "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>",
+ "<div class=\"bottomNav\"><a name=\"navbar.bottom\">");
+ }
+
+ @Test
+ void testPackages(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createPackages(srcDir);
+
+ Path outDir = base.resolve("out3");
+ javadoc("-d", outDir.toString(),
+ "-doctitle", "Document Title",
+ "-header", "Test Header",
+ "--frames",
+ "-sourcepath", srcDir.toString(),
+ "pkg1", "pkg2");
+
+ checkExit(Exit.OK);
+
+ checkOrder("overview-summary.html",
+ "<header role=\"banner\">\n"
+ + "<nav role=\"navigation\">",
+ "<main role=\"main\">\n"
+ + "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>",
+ "<footer role=\"contentinfo\">\n" +
+ "<nav role=\"navigation\">");
+
+ checkOrder("overview-frame.html",
+ "<header role=\"banner\">\n"
+ + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<nav role=\"navigation\" class=\"indexNav\">",
+ "<main role=\"main\">\n"
+ + "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"Packages\">Packages</h2>",
+ "<footer role=\"contentinfo\">");
+ }
+
+ @Test
+ void testPackagesHtml4(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createPackages(srcDir);
+
+ Path outDir = base.resolve("out4");
+ javadoc("-d", outDir.toString(),
+ "-doctitle", "Document Title",
+ "-header", "Test Header",
+ "--frames",
+ "-sourcepath", srcDir.toString(),
+ "pkg1", "pkg2",
+ "-html4");
+
+ checkExit(Exit.OK);
+
+ checkOrder("overview-summary.html",
+ "<div class=\"fixedNav\">",
+ "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>",
+ "<div class=\"bottomNav\"><a name=\"navbar.bottom\">");
+
+ checkOrder("overview-frame.html",
+ "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
+ + "<div class=\"indexNav\">",
+ "<div class=\"indexContainer\">\n"
+ + "<h2 title=\"Packages\">Packages</h2>"
+ );
+ }
+
+ void createModules(Path srcDir) throws Exception {
+ new ModuleBuilder(tb, "m1")
+ .classes("package p1; public class a{}")
+ .classes("package p2; public class b{}")
+ .write(srcDir);
+ new ModuleBuilder(tb, "m2")
+ .classes("package p3; public class c{}")
+ .classes("package p4; public class d{}")
+ .write(srcDir);
+ }
+
+ void createPackages(Path srcDir) throws Exception {
+ new ClassBuilder(tb, "pkg1.A")
+ .setModifiers("public", "class")
+ .write(srcDir);
+ new ClassBuilder(tb, "pkg2.B")
+ .setModifiers("public", "class")
+ .write(srcDir);
+ }
+}
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Tue Sep 18 21:46:17 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Wed Sep 19 12:14:53 2018 +0530
@@ -24,7 +24,7 @@
/*
* @test
* @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819 8183037 8182765 8196202
- * 8202624
+ * 8202624 8210047
* @summary Test the version of HTML generated by the javadoc tool.
* @author bpatel
* @library ../lib
@@ -106,14 +106,17 @@
"<nav role=\"navigation\" class=\"indexNav\">\n"
+ "<ul>\n"
+ "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All Classes</a></li>",
- "<main role=\"main\" class=\"indexContainer\">\n"
+ "<main role=\"main\">\n"
+ + "<div class=\"indexContainer\">\n"
+ "<h2 title=\"Packages\">Packages</h2>");
// Test for allclasses-frame page
checkOutput("allclasses-frame.html", true,
"<!DOCTYPE HTML>",
"<meta name=\"dc.created\"",
- "<main role=\"main\" class=\"indexContainer\">\n"
+ "<main role=\"main\">\n"
+ + "<h1 class=\"bar\">All Classes</h1>\n"
+ + "<div class=\"indexContainer\">\n"
+ "<ul>\n"
+ "<li>");
@@ -636,14 +639,14 @@
"<div class=\"indexNav\">\n"
+ "<ul>\n"
+ "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All Classes</a></li>",
- "<div class=\"indexContainer\">\n"
+ "<main class=\"indexContainer\">\n"
+ "<h2 title=\"Packages\">Packages</h2>");
// Negated test for allclasses-frame page
checkOutput("allclasses-frame.html", false,
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
"<meta name=\"date\"",
- "<div class=\"indexContainer\">\n"
+ "<main class=\"indexContainer\">\n"
+ "<ul>\n"
+ "<li>");
--- a/test/langtools/jdk/javadoc/doclet/testOverview/TestOverview.java Tue Sep 18 21:46:17 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testOverview/TestOverview.java Wed Sep 19 12:14:53 2018 +0530
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8173302 8182765 8196202
+ * @bug 8173302 8182765 8196202 8210047
* @summary make sure the overview-summary and module-summary pages don't
* don't have the See link, and the overview is copied correctly.
* @library ../lib
@@ -95,10 +95,10 @@
void checkOverview() {
checkOutput("overview-summary.html", true,
- "<div class=\"header\">\n"
+ "<main role=\"main\">\n"
+ + "<div class=\"header\">\n"
+ "<h1 class=\"title\">Document Title</h1>\n"
+ "</div>\n"
- + "<main role=\"main\">\n"
+ "<div class=\"contentContainer\">\n"
+ "<div class=\"block\">This is line1. This is line 2.</div>\n"
+ "</div>\n"