8248320: Provide a unique accessible name for <nav role="navigation">

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons 2020-11-03 17:15:17 +00:00
parent 64a981124a
commit d47336bf1c
31 changed files with 270 additions and 543 deletions

View File

@ -46,8 +46,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
*/
public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
protected Navigation navBar;
/**
* Constructs the AbstractOverviewIndexWriter.
*
@ -57,32 +55,6 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
public AbstractOverviewIndexWriter(HtmlConfiguration configuration,
DocPath filename) {
super(configuration, filename);
this.navBar = new Navigation(null, configuration, PageMode.OVERVIEW, path);
}
/**
* Adds the top text (from the -top option), the upper
* navigation bar, and then the title (from the"-header"
* option), at the top of page.
*
* @param header the documentation tree to which the navigation bar header will be added
*/
protected void addNavigationBarHeader(Content header) {
addTop(header);
navBar.setUserHeader(getUserHeaderFooter(true));
header.add(navBar.getContent(Navigation.Position.TOP));
}
/**
* Adds the lower navigation bar and the bottom text
* (from the -bottom option) at the bottom of page.
*
* @param footer the documentation tree to which the navigation bar footer will be added
*/
protected void addNavigationBarFooter(Content footer) {
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
}
/**
@ -123,17 +95,13 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
throws DocFileIOException {
String windowOverview = resources.getText(title);
Content body = getBody(getWindowTitle(windowOverview));
Content header = new ContentBuilder();
addNavigationBarHeader(header);
Content main = new ContentBuilder();
addOverviewHeader(main);
addIndex(main);
Content footer = HtmlTree.FOOTER();
addNavigationBarFooter(footer);
body.add(new BodyContents()
.setHeader(header)
.setHeader(getHeader(PageMode.OVERVIEW))
.addMainContent(main)
.setFooter(footer));
.setFooter(getFooter()));
printHtmlDocument(
configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle()),
description, body);

View File

@ -93,24 +93,15 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
*/
protected void buildAllClassesFile() throws DocFileIOException {
String label = resources.getText("doclet.All_Classes");
Content header = new ContentBuilder();
addTop(header);
Navigation navBar = new Navigation(null, configuration, PageMode.ALL_CLASSES, path);
navBar.setUserHeader(getUserHeaderFooter(true));
header.add(navBar.getContent(Navigation.Position.TOP));
Content allClassesContent = new ContentBuilder();
addContents(allClassesContent);
Content mainContent = new ContentBuilder();
mainContent.add(allClassesContent);
Content footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
HtmlTree bodyTree = getBody(getWindowTitle(label));
bodyTree.add(new BodyContents()
.setHeader(header)
.setHeader(getHeader(PageMode.ALL_CLASSES))
.addMainContent(mainContent)
.setFooter(footer));
.setFooter(getFooter()));
printHtmlDocument(null, "class index", bodyTree);
}

View File

@ -74,27 +74,18 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter {
*/
protected void buildAllPackagesFile() throws DocFileIOException {
String label = resources.getText("doclet.All_Packages");
Content headerContent = new ContentBuilder();
Navigation navBar = new Navigation(null, configuration, PageMode.ALL_PACKAGES, path);
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content mainContent = new ContentBuilder();
addPackages(mainContent);
Content titleContent = contents.allPackagesLabel;
Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
HtmlTree bodyTree = getBody(getWindowTitle(label));
bodyTree.add(new BodyContents()
.setHeader(headerContent)
.setHeader(getHeader(PageMode.ALL_PACKAGES))
.addMainContent(headerDiv)
.addMainContent(mainContent)
.setFooter(footer));
.setFooter(getFooter()));
printHtmlDocument(null, "package index", bodyTree);
}

View File

@ -94,7 +94,6 @@ public class ClassUseWriter extends SubWriterHolderWriter {
final ConstructorWriterImpl constrSubWriter;
final FieldWriterImpl fieldSubWriter;
final NestedClassWriterImpl classSubWriter;
private final Navigation navBar;
/**
* Constructor.
@ -147,7 +146,6 @@ public class ClassUseWriter extends SubWriterHolderWriter {
constrSubWriter.setFoundNonPubConstructor(true);
fieldSubWriter = new FieldWriterImpl(this);
classSubWriter = new NestedClassWriterImpl(this);
this.navBar = new Navigation(typeElement, configuration, PageMode.USE, path);
}
/**
@ -227,11 +225,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
utils.getFullyQualifiedName(typeElement)));
}
bodyContents.addMainContent(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
bodyContents.setFooter(footer);
bodyContents.setFooter(getFooter());
body.add(bodyContents);
String description = getDescription("use", typeElement);
printHtmlDocument(null, description, body);
@ -425,17 +419,6 @@ public class ClassUseWriter extends SubWriterHolderWriter {
String title = resources.getText("doclet.Window_ClassUse_Header",
cltype, clname);
HtmlTree bodyTree = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
contents.moduleLabel);
navBar.setNavLinkModule(mdleLinkContent);
Content classLinkContent = getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
.label(resources.getText("doclet.Class")));
navBar.setNavLinkClass(classLinkContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
ContentBuilder headingContent = new ContentBuilder();
headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
headingContent.add(new HtmlTree(TagName.BR));
@ -443,7 +426,19 @@ public class ClassUseWriter extends SubWriterHolderWriter {
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent).addMainContent(div);
bodyContents.setHeader(getHeader(PageMode.USE, typeElement)).addMainContent(div);
return bodyTree;
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
contents.moduleLabel);
Content classLinkContent = getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
.label(resources.getText("doclet.Class")));
return super.getNavBar(pageMode, element)
.setNavLinkModule(mdleLinkContent)
.setNavLinkClass(classLinkContent);
}
}

View File

@ -90,8 +90,6 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
protected final ClassTree classtree;
private final Navigation navBar;
/**
* @param configuration the configuration data for the doclet
* @param typeElement the class being documented.
@ -103,20 +101,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
this.typeElement = typeElement;
configuration.currentTypeElement = typeElement;
this.classtree = classTree;
this.navBar = new Navigation(typeElement, configuration, PageMode.CLASS, path);
}
@Override
public Content getHeader(String header) {
HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(typeElement)));
Content headerContent = new ContentBuilder();
addTop(headerContent);
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
contents.moduleLabel);
navBar.setNavLinkModule(linkContent);
navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
HtmlTree div = new HtmlTree(TagName.DIV);
div.setStyle(HtmlStyle.header);
if (configuration.showModules) {
@ -146,7 +135,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
HtmlStyle.title, new StringContent(header));
heading.add(getTypeParameterLinks(linkInfo));
div.add(heading);
bodyContents.setHeader(headerContent)
bodyContents.setHeader(getHeader(PageMode.CLASS, typeElement))
.addMainContent(MarkerComments.START_OF_CLASS_DATA)
.addMainContent(div);
return bodyTree;
@ -157,14 +146,19 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
return getContentHeader();
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(element),
contents.moduleLabel);
return super.getNavBar(pageMode, element)
.setNavLinkModule(linkContent)
.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
}
@Override
public void addFooter() {
bodyContents.addMainContent(MarkerComments.END_OF_CLASS_DATA);
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
}
@Override

View File

@ -73,8 +73,6 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
*/
private HtmlTree summaryTree;
private final Navigation navBar;
private final BodyContents bodyContents = new BodyContents();
private boolean hasConstants = false;
@ -88,7 +86,6 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
super(configuration, DocPaths.CONSTANT_VALUES);
constantsTableHeader = new TableHeader(
contents.modifierAndTypeLabel, contents.constantFieldLabel, contents.valueLabel);
this.navBar = new Navigation(null, configuration, PageMode.CONSTANT_VALUES, path);
configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.CONSTANT_VALUES);
}
@ -96,11 +93,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
public Content getHeader() {
String label = resources.getText("doclet.Constants_Summary");
HtmlTree bodyTree = getBody(getWindowTitle(label));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
bodyContents.setHeader(headerContent);
bodyContents.setHeader(getHeader(PageMode.CONSTANT_VALUES));
return bodyTree;
}
@ -271,11 +264,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
@Override
public void addFooter() {
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
}
@Override

View File

@ -207,8 +207,6 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
private EnumMap<DeprElementKind, AbstractMemberWriter> writerMap;
private final Navigation navBar;
/**
* Constructor.
*
@ -218,7 +216,6 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) {
super(configuration, filename);
this.navBar = new Navigation(null, configuration, PageMode.DEPRECATED, path);
NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
writerMap = new EnumMap<>(DeprElementKind.class);
for (DeprElementKind kind : DeprElementKind.values()) {
@ -295,11 +292,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
}
}
bodyContents.addMainContent(content);
HtmlTree htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
String description = "deprecated elements";
body.add(bodyContents);
printHtmlDocument(null, description, body);
@ -356,11 +349,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
public HtmlTree getHeader() {
String title = resources.getText("doclet.Window_Deprecated_List");
HtmlTree bodyTree = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
bodyContents.setHeader(headerContent);
bodyContents.setHeader(getHeader(PageMode.DEPRECATED));
return bodyTree;
}

View File

@ -64,7 +64,6 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
public final DocPath source;
public final HtmlConfiguration configuration;
private final HtmlOptions options;
private Navigation navBar;
/**
* Constructor to construct the DocFilesWriter object.
@ -196,7 +195,9 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
DocFileElement dfElement = new DocFileElement(utils, element, fileObject);
DocPath dfilePath = dstPath.resolve(srcfile.getName());
HtmlDocletWriter docletWriter = new DocFileWriter(configuration, dfilePath, element);
PackageElement pkg = dfElement.getPackageElement();
HtmlDocletWriter docletWriter = new DocFileWriter(configuration, dfilePath, element, pkg);
configuration.messages.notice("doclet.Generating_0", docletWriter.filename.getPath());
List<? extends DocTree> localTags = getLocalHeaderTags(utils.getPreamble(dfElement));
@ -204,30 +205,15 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
String title = getWindowTitle(docletWriter, dfElement).trim();
HtmlTree htmlContent = docletWriter.getBody(title);
PackageElement pkg = dfElement.getPackageElement();
this.navBar = new Navigation(element, configuration, PageMode.DOC_FILE, docletWriter.path);
Content headerContent = new ContentBuilder();
docletWriter.addTop(headerContent);
Content mdleLinkContent = docletWriter.getModuleLink(utils.elementUtils.getModuleOf(pkg),
docletWriter.contents.moduleLabel);
navBar.setNavLinkModule(mdleLinkContent);
Content pkgLinkContent = docletWriter.getPackageLink(pkg, docletWriter.contents.packageLabel);
navBar.setNavLinkPackage(pkgLinkContent);
navBar.setUserHeader(docletWriter.getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
List<? extends DocTree> fullBody = utils.getFullBody(dfElement);
Content pageContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false);
docletWriter.addTagsInfo(dfElement, pageContent);
navBar.setUserFooter(docletWriter.getUserHeaderFooter(false));
Content footer = HtmlTree.FOOTER();
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
docletWriter.addBottom(footer);
htmlContent.add(new BodyContents()
.setHeader(headerContent)
.setHeader(docletWriter.getHeader(PageMode.DOC_FILE, element))
.addMainContent(pageContent)
.setFooter(footer));
.setFooter(docletWriter.getFooter()));
docletWriter.printHtmlDocument(Collections.emptyList(), null, localTagsContent, Collections.emptyList(), htmlContent);
}
@ -291,15 +277,17 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
}
private static class DocFileWriter extends HtmlDocletWriter {
private final PackageElement pkg;
/**
* Constructor to construct the HtmlDocletWriter object.
*
* @param configuration the configuration of this doclet.
* @param path the file to be generated.
* @param e the anchoring element.
* @param configuration the configuration of this doclet
* @param path the file to be generated
* @param e the anchoring element
* @param pkg the package containing the doc file
*/
public DocFileWriter(HtmlConfiguration configuration, DocPath path, Element e) {
public DocFileWriter(HtmlConfiguration configuration, DocPath path, Element e, PackageElement pkg) {
super(configuration, path);
switch (e.getKind()) {
case PACKAGE:
@ -308,6 +296,17 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
default:
throw new AssertionError("unsupported element: " + e.getKind());
}
this.pkg = pkg;
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(element),
contents.moduleLabel);
Content pkgLinkContent = getPackageLink(pkg, contents.packageLabel);
return super.getNavBar(pageMode, element)
.setNavLinkModule(mdleLinkContent)
.setNavLinkPackage(pkgLinkContent);
}
}
}

View File

@ -51,8 +51,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
*/
public class HelpWriter extends HtmlDocletWriter {
private final Navigation navBar;
private final String[][] SEARCH_EXAMPLES = {
{"j.l.obj", "\"java.lang.Object\""},
{"InpStr", "\"java.io.InputStream\""},
@ -67,7 +65,6 @@ public class HelpWriter extends HtmlDocletWriter {
public HelpWriter(HtmlConfiguration configuration,
DocPath filename) {
super(configuration, filename);
this.navBar = new Navigation(null, configuration, PageMode.HELP, path);
}
/**
@ -93,20 +90,12 @@ public class HelpWriter extends HtmlDocletWriter {
protected void generateHelpFile() throws DocFileIOException {
String title = resources.getText("doclet.Window_Help_title");
HtmlTree body = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
ContentBuilder helpFileContent = new ContentBuilder();
addHelpFileContents(helpFileContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
body.add(new BodyContents()
.setHeader(headerContent)
.setHeader(getHeader(PageMode.HELP))
.addMainContent(helpFileContent)
.setFooter(footer));
.setFooter(getFooter()));
printHtmlDocument(null, "help", body);
}

View File

@ -487,46 +487,61 @@ public class HtmlDocletWriter {
}
/**
* Get user specified header and the footer.
* Returns a {@code <header>} element, containing the user "top" text, if any,
* amd the main navigation bar.
*
* @param header if true print the user provided header else print the
* user provided footer.
* @param pageMode the pageMode used to configure the navigation bar
*
* @return the {@code <header>} element
*/
public Content getUserHeaderFooter(boolean header) {
String content;
if (header) {
content = replaceDocRootDir(options.header());
} else {
if (options.footer().length() != 0) {
content = replaceDocRootDir(options.footer());
} else {
content = replaceDocRootDir(options.header());
}
}
Content rawContent = new RawHtml(content);
return rawContent;
protected HtmlTree getHeader(Navigation.PageMode pageMode) {
return getHeader(pageMode, null);
}
/**
* Adds the user specified top.
* Returns a {@code <header>} element, containing the user "top" text, if any,
* amd the main navigation bar.
*
* @param htmlTree the content tree to which user specified top will be added
* @param pageMode the page mode used to configure the navigation bar
* @param element the element used to configure the navigation bar
*
* @return the {@code <header>} element
*/
public void addTop(Content htmlTree) {
Content top = new RawHtml(replaceDocRootDir(options.top()));
htmlTree.add(top);
protected HtmlTree getHeader(Navigation.PageMode pageMode, Element element) {
return HtmlTree.HEADER()
.add(new RawHtml(replaceDocRootDir(options.top())))
.add(getNavBar(pageMode, element).getContent());
}
/**
* Adds the user specified bottom.
* Returns a basic navigation bar for a kind of page and element.
*
* @param htmlTree the content tree to which user specified bottom will be added
* @apiNote the result may be further configured by overriding this method
*
* @param pageMode the page mode
* @param element the defining element for the navigation bar, or {@code null} if none
* @return the basic navigation bar
*/
public void addBottom(Content htmlTree) {
Content bottom = new RawHtml(replaceDocRootDir(options.bottom()));
Content small = HtmlTree.SMALL(bottom);
Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
htmlTree.add(p);
protected Navigation getNavBar(Navigation.PageMode pageMode, Element element) {
return new Navigation(element, configuration, pageMode, path)
.setUserHeader(new RawHtml(replaceDocRootDir(options.header())));
}
/**
* Returns a {@code <footer>} element containing the user's "bottom" text,
* or {@code null} if there is no such text.
*
* @return the {@code <footer>} element or {@code null}.
*/
public HtmlTree getFooter() {
String bottom = options.bottom();
return (bottom == null || bottom.isEmpty())
? null
: HtmlTree.FOOTER()
.add(new HtmlTree(TagName.HR))
.add(HtmlTree.P(HtmlStyle.legalCopy,
HtmlTree.SMALL(
new RawHtml(replaceDocRootDir(bottom)))));
}
/**

View File

@ -111,12 +111,6 @@ public class HtmlOptions extends BaseOptions {
*/
private String docTitle = "";
/**
* Argument for command-line option {@code -footer}.
*/
private String footer = "";
/**
* Argument for command-line option {@code -header}.
*/
@ -235,7 +229,7 @@ public class HtmlOptions extends BaseOptions {
new Option(resources, "-footer", 1) {
@Override
public boolean process(String opt, List<String> args) {
footer = args.get(0);
messages.warning("doclet.footer_specified");
return true;
}
},
@ -499,7 +493,6 @@ public class HtmlOptions extends BaseOptions {
// to be handled here.
Utils utils = config.utils;
utils.checkJavaScriptInOption("-header", header);
utils.checkJavaScriptInOption("-footer", footer);
utils.checkJavaScriptInOption("-top", top);
utils.checkJavaScriptInOption("-bottom", bottom);
utils.checkJavaScriptInOption("-doctitle", docTitle);
@ -593,13 +586,6 @@ public class HtmlOptions extends BaseOptions {
return docTitle;
}
/**
* Argument for command-line option {@code -footer}.
*/
String footer() {
return footer;
}
/**
* Argument for command-line option {@code -header}.
*/

View File

@ -123,28 +123,19 @@ public class IndexWriter extends HtmlDocletWriter {
? resources.getText("doclet.Window_Split_Index", displayFirstCharacters.get(0))
: resources.getText("doclet.Window_Single_Index");
HtmlTree body = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
Navigation navBar = new Navigation(null, configuration, PageMode.INDEX, path);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content mainContent = new ContentBuilder();
addLinksForIndexes(allFirstCharacters, mainContent);
for (Character ch : displayFirstCharacters) {
addContents(ch, mainIndex.getItems(ch), mainContent);
}
addLinksForIndexes(allFirstCharacters, mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
body.add(new BodyContents()
.setHeader(headerContent)
.setHeader(getHeader(PageMode.INDEX))
.addMainContent(HtmlTree.DIV(HtmlStyle.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.Index"))))
.addMainContent(mainContent)
.setFooter(footer));
.setFooter(getFooter()));
String description = splitIndex ? "index: " + displayFirstCharacters.get(0) : "index";
printHtmlDocument(null, description, body);

View File

@ -43,24 +43,12 @@ public class MarkerComments {
public static final Comment START_OF_TOP_NAVBAR =
new Comment("========= START OF TOP NAVBAR =======");
/**
* Marker to identify start of bottom navigation bar.
*/
public static final Comment START_OF_BOTTOM_NAVBAR =
new Comment("======= START OF BOTTOM NAVBAR ======");
/**
* Marker to identify end of top navigation bar.
*/
public static final Comment END_OF_TOP_NAVBAR =
new Comment("========= END OF TOP NAVBAR =========");
/**
* Marker to identify end of bottom navigation bar.
*/
public static final Comment END_OF_BOTTOM_NAVBAR =
new Comment("======== END OF BOTTOM NAVBAR =======");
/**
* Marker to identify start of module description.
*/

View File

@ -160,8 +160,6 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
private final Map<TypeElement, Content> providesTrees
= new TreeMap<>(comparators.makeAllClassesComparator());
private final Navigation navBar;
private final BodyContents bodyContents = new BodyContents();
/**
@ -174,7 +172,6 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
super(configuration, configuration.docPaths.moduleSummary(mdle));
this.mdle = mdle;
this.moduleMode = configuration.docEnv.getModuleMode();
this.navBar = new Navigation(mdle, configuration, PageMode.MODULE, path);
computeModulesData();
}
@ -186,15 +183,6 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
@Override
public Content getModuleHeader(String heading) {
HtmlTree bodyTree = getBody(getWindowTitle(mdle.getQualifiedName().toString()));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !options.noComment());
navBar.setDisplaySummaryModulesLink(display(requires) || display(indirectModules));
navBar.setDisplaySummaryPackagesLink(display(packages) || display(indirectPackages)
|| display(indirectOpenPackages));
navBar.setDisplaySummaryServicesLink(displayServices(uses, usesTrees) || displayServices(provides.keySet(), providesTrees));
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
HtmlTree div = new HtmlTree(TagName.DIV);
div.setStyle(HtmlStyle.header);
Content annotationContent = new HtmlTree(TagName.P);
@ -208,11 +196,21 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
Content moduleHead = new RawHtml(heading);
tHeading.add(moduleHead);
div.add(tHeading);
bodyContents.setHeader(headerContent)
bodyContents.setHeader(getHeader(PageMode.MODULE, mdle))
.addMainContent(div);
return bodyTree;
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
return super.getNavBar(pageMode, element)
.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !options.noComment())
.setDisplaySummaryModulesLink(display(requires) || display(indirectModules))
.setDisplaySummaryPackagesLink(display(packages) || display(indirectPackages)
|| display(indirectOpenPackages))
.setDisplaySummaryServicesLink(displayServices(uses, usesTrees) || displayServices(provides.keySet(), providesTrees));
}
/**
* Get the content header.
*/
@ -840,11 +838,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
@Override
public void addModuleFooter() {
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
}
@Override

View File

@ -80,7 +80,6 @@ public class Navigation {
private boolean displaySummaryPackagesLink;
private boolean displaySummaryServicesLink;
private Content userHeader;
private Content userFooter;
private final String rowListTitle;
private final Content searchLabel;
@ -104,27 +103,6 @@ public class Navigation {
USE;
}
enum Position {
BOTTOM(MarkerComments.START_OF_BOTTOM_NAVBAR, MarkerComments.END_OF_BOTTOM_NAVBAR),
TOP(MarkerComments.START_OF_TOP_NAVBAR, MarkerComments.END_OF_TOP_NAVBAR);
final Content startOfNav;
final Content endOfNav;
Position(Content startOfNav, Content endOfNav) {
this.startOfNav = startOfNav;
this.endOfNav = endOfNav;
}
Content startOfNav() {
return startOfNav;
}
Content endOfNav() {
return endOfNav;
}
}
/**
* Creates a {@code Navigation} object for a specific file, to be written in a specific HTML
* version.
@ -192,13 +170,8 @@ public class Navigation {
return this;
}
public Navigation setUserFooter(Content userFooter) {
this.userFooter = userFooter;
return this;
}
/**
* Add the links for the main navigation.
* Adds the links for the main navigation.
*
* @param tree the content tree to which the main navigation will added
*/
@ -356,7 +329,7 @@ public class Navigation {
}
/**
* Add the summary links to the sub-navigation.
* Adds the summary links to the sub-navigation.
*
* @param tree the content tree to which the sub-navigation will added
*/
@ -436,7 +409,7 @@ public class Navigation {
}
/**
* Add the navigation summary link.
* Adds the navigation summary link.
*
* @param members members to be linked
* @param vmt the visible member table
@ -461,7 +434,7 @@ public class Navigation {
}
/**
* Add the navigation Type summary link.
* Adds the navigation Type summary link.
*
* @param typeElement the Type being documented
* @param kind the kind of member being documented
@ -551,7 +524,7 @@ public class Navigation {
}
/**
* Add the navigation Type summary link.
* Adds the navigation Type summary link.
*
* @param label the label to be added
* @param kind the kind of member being documented
@ -598,7 +571,7 @@ public class Navigation {
}
/**
* Add the detail links to sub-navigation.
* Adds the detail links to sub-navigation.
*
* @param tree the content tree to which the links will be added
*/
@ -640,7 +613,7 @@ public class Navigation {
}
/**
* Add the navigation Type detail link.
* Adds the navigation Type detail link.
*
* @param kind the kind of member being documented
* @param link true if the members are listed and need to be linked
@ -689,7 +662,7 @@ public class Navigation {
}
/**
* Add the navigation Annotation Type detail link.
* Adds the navigation Annotation Type detail link.
*
* @param listContents the list of contents to which the annotation detail will be added.
*/
@ -723,7 +696,7 @@ public class Navigation {
}
/**
* Add the navigation Annotation Type detail link.
* Adds the navigation Annotation Type detail link.
*
* @param type the kind of member being documented
* @param link true if the member details need to be linked
@ -906,12 +879,11 @@ public class Navigation {
}
/**
* Get the navigation content.
* Returns the navigation content.
*
* @param posn the position for the navigation bar
* @return the navigation contents
* @return the navigation content
*/
public Content getContent(Position posn) {
public Content getContent() {
if (options.noNavbar()) {
return new ContentBuilder();
}
@ -919,37 +891,15 @@ public class Navigation {
HtmlTree navDiv = new HtmlTree(TagName.DIV);
Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links");
SectionName navListSection;
Content aboutContent;
boolean addSearch;
switch (posn) {
case TOP:
tree.add(Position.TOP.startOfNav());
navDiv.setStyle(HtmlStyle.topNav)
.setId(SectionName.NAVBAR_TOP.getName())
.add(HtmlTree.DIV(HtmlStyle.skipNav,
links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks,
skipNavLinks.toString(), "")));
navListSection = SectionName.NAVBAR_TOP_FIRSTROW;
aboutContent = userHeader;
addSearch = options.createIndex();
break;
case BOTTOM:
tree.add(Position.BOTTOM.startOfNav());
navDiv.setStyle(HtmlStyle.bottomNav)
.setId(SectionName.NAVBAR_BOTTOM.getName())
.add(HtmlTree.DIV(HtmlStyle.skipNav,
links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks,
skipNavLinks.toString(), "")));
navListSection = SectionName.NAVBAR_BOTTOM_FIRSTROW;
aboutContent = userFooter;
addSearch = false;
break;
default:
throw new Error();
}
tree.add(MarkerComments.START_OF_TOP_NAVBAR);
navDiv.setStyle(HtmlStyle.topNav)
.setId(SectionName.NAVBAR_TOP.getName())
.add(HtmlTree.DIV(HtmlStyle.skipNav,
links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks,
skipNavLinks.toString(), "")));
SectionName navListSection = SectionName.NAVBAR_TOP_FIRSTROW;
Content aboutContent = userHeader;
boolean addSearch = options.createIndex();
HtmlTree navList = new HtmlTree(TagName.UL)
.setId(navListSection.getName())
@ -979,18 +929,10 @@ public class Navigation {
}
tree.add(subDiv);
switch (posn) {
case TOP:
tree.add(Position.TOP.endOfNav());
tree.add(HtmlTree.SPAN(HtmlStyle.skipNav, EMPTY_COMMENT)
.setId(SectionName.SKIP_NAVBAR_TOP.getName()));
break;
tree.add(MarkerComments.END_OF_TOP_NAVBAR);
tree.add(HtmlTree.SPAN(HtmlStyle.skipNav, EMPTY_COMMENT)
.setId(SectionName.SKIP_NAVBAR_TOP.getName()));
case BOTTOM:
tree.add(Position.BOTTOM.endOfNav());
tree.add(HtmlTree.SPAN(HtmlStyle.skipNav, EMPTY_COMMENT)
.setId(SectionName.SKIP_NAVBAR_BOTTOM.getName()));
}
return tree;
}
}

View File

@ -25,6 +25,7 @@
package jdk.javadoc.internal.doclets.formats.html;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
@ -56,8 +57,6 @@ public class PackageTreeWriter extends AbstractTreeWriter {
*/
protected PackageElement packageElement;
private final Navigation navBar;
private final BodyContents bodyContents = new BodyContents();
/**
@ -70,7 +69,6 @@ public class PackageTreeWriter extends AbstractTreeWriter {
super(configuration, path,
new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration));
this.packageElement = packageElement;
this.navBar = new Navigation(packageElement, configuration, PageMode.TREE, path);
}
/**
@ -112,11 +110,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
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));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
bodyContents.setFooter(footer);
bodyContents.setFooter(getFooter());
body.add(bodyContents);
printHtmlDocument(null, getDescription("tree", packageElement), body);
}
@ -130,15 +124,16 @@ public class PackageTreeWriter extends AbstractTreeWriter {
String packageName = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
String title = packageName + " " + resources.getText("doclet.Window_Class_Hierarchy");
HtmlTree bodyTree = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
bodyContents.setHeader(getHeader(PageMode.TREE, packageElement));
return bodyTree;
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
contents.moduleLabel);
navBar.setNavLinkModule(linkContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
bodyContents.setHeader(headerContent);
return bodyTree;
return super.getNavBar(pageMode, element)
.setNavLinkModule(linkContent);
}
/**

View File

@ -30,6 +30,7 @@ import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
@ -61,7 +62,6 @@ public class PackageUseWriter extends SubWriterHolderWriter {
final PackageElement packageElement;
final SortedMap<String, Set<TypeElement>> usingPackageToUsedClasses = new TreeMap<>();
final String packageUseTableSummary;
private final Navigation navBar;
/**
* Constructor.
@ -99,7 +99,6 @@ public class PackageUseWriter extends SubWriterHolderWriter {
packageUseTableSummary = resources.getText("doclet.Use_Table_Summary",
resources.getText("doclet.packages"));
this.navBar = new Navigation(packageElement, configuration, PageMode.USE, path);
}
/**
@ -131,11 +130,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
addPackageUse(mainContent);
}
bodyContents.addMainContent(mainContent);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
bodyContents.setFooter(footer);
bodyContents.setFooter(getFooter());
body.add(bodyContents);
printHtmlDocument(null,
getDescription("use", packageElement),
@ -236,13 +231,6 @@ public class PackageUseWriter extends SubWriterHolderWriter {
String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
String title = resources.getText("doclet.Window_ClassUse_Header", packageText, name);
HtmlTree bodyTree = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
contents.moduleLabel);
navBar.setNavLinkModule(linkContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
ContentBuilder headingContent = new ContentBuilder();
headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
headingContent.add(new HtmlTree(TagName.BR));
@ -250,8 +238,16 @@ public class PackageUseWriter extends SubWriterHolderWriter {
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent)
bodyContents.setHeader(getHeader(PageMode.USE, packageElement))
.addMainContent(div);
return bodyTree;
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(element),
contents.moduleLabel);
return super.getNavBar(pageMode, element)
.setNavLinkModule(linkContent);
}
}

View File

@ -28,6 +28,7 @@ package jdk.javadoc.internal.doclets.formats.html;
import java.util.List;
import java.util.SortedSet;
import javax.lang.model.element.Element;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
@ -74,8 +75,6 @@ public class PackageWriterImpl extends HtmlDocletWriter
*/
protected HtmlTree sectionTree = HtmlTree.SECTION(HtmlStyle.packageDescription, new ContentBuilder());
private final Navigation navBar;
private final BodyContents bodyContents = new BodyContents();
/**
@ -94,19 +93,11 @@ public class PackageWriterImpl extends HtmlDocletWriter
configuration.docPaths.forPackage(packageElement)
.resolve(DocPaths.PACKAGE_SUMMARY));
this.packageElement = packageElement;
this.navBar = new Navigation(packageElement, configuration, PageMode.PACKAGE, path);
}
@Override
public Content getPackageHeader(String heading) {
HtmlTree bodyTree = getBody(getWindowTitle(utils.getPackageName(packageElement)));
Content headerContent = new ContentBuilder();
addTop(headerContent);
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
contents.moduleLabel);
navBar.setNavLinkModule(linkContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
HtmlTree div = new HtmlTree(TagName.DIV);
div.setStyle(HtmlStyle.header);
if (configuration.showModules) {
@ -127,7 +118,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
Content packageHead = new StringContent(heading);
tHeading.add(packageHead);
div.add(tHeading);
bodyContents.setHeader(headerContent)
bodyContents.setHeader(getHeader(PageMode.PACKAGE, packageElement))
.addMainContent(div);
return bodyTree;
}
@ -137,6 +128,14 @@ public class PackageWriterImpl extends HtmlDocletWriter
return new ContentBuilder();
}
@Override
protected Navigation getNavBar(PageMode pageMode, Element element) {
Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
contents.moduleLabel);
return super.getNavBar(pageMode, element)
.setNavLinkModule(linkContent);
}
/**
* Add the package deprecation information to the documentation tree.
*
@ -261,11 +260,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
@Override
public void addPackageFooter() {
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
}
@Override

View File

@ -55,15 +55,12 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
Set<TypeElement> visibleClasses;
private final Navigation navBar;
/**
* @param configuration the configuration data for the doclet
*/
public SerializedFormWriterImpl(HtmlConfiguration configuration) {
super(configuration, DocPaths.SERIALIZED_FORM);
visibleClasses = configuration.getIncludedTypeElements();
this.navBar = new Navigation(null, configuration, PageMode.SERIALIZED_FORM, path);
configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.SERIALIZED_FORM);
}
@ -76,15 +73,11 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
@Override
public Content getHeader(String header) {
HtmlTree bodyTree = getBody(getWindowTitle(header));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content h1Content = new StringContent(header);
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, h1Content);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent)
bodyContents.setHeader(getHeader(PageMode.SERIALIZED_FORM))
.addMainContent(div);
return bodyTree;
}
@ -241,11 +234,7 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
*/
@Override
public void addFooter() {
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(htmlTree);
bodyContents.setFooter(htmlTree);
bodyContents.setFooter(getFooter());
}
@Override

View File

@ -63,8 +63,6 @@ import static java.util.stream.Collectors.toList;
*/
public class SystemPropertiesWriter extends HtmlDocletWriter {
private final Navigation navBar;
/**
* Cached contents of {@code <title>...</title>} tags of the HTML pages.
*/
@ -78,7 +76,6 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
*/
public SystemPropertiesWriter(HtmlConfiguration configuration, DocPath filename) {
super(configuration, filename);
this.navBar = new Navigation(null, configuration, PageMode.SYSTEM_PROPERTIES, path);
}
public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
@ -108,23 +105,15 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
protected void buildSystemPropertiesPage() throws DocFileIOException {
String title = resources.getText("doclet.systemProperties");
HtmlTree body = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content mainContent = new ContentBuilder();
addSystemProperties(mainContent);
Content footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.add(navBar.getContent(Navigation.Position.BOTTOM));
addBottom(footer);
body.add(new BodyContents()
.setHeader(headerContent)
.setHeader(getHeader(PageMode.SYSTEM_PROPERTIES))
.addMainContent(HtmlTree.DIV(HtmlStyle.header,
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
contents.getContent("doclet.systemProperties"))))
.addMainContent(mainContent)
.setFooter(footer));
.setFooter(getFooter()));
printHtmlDocument(null, "system properties", body);
if (configuration.mainIndex != null) {

View File

@ -66,8 +66,6 @@ public class TreeWriter extends AbstractTreeWriter {
*/
private final boolean classesOnly;
private final Navigation navBar;
protected BodyContents bodyContents;
/**
@ -81,7 +79,6 @@ public class TreeWriter extends AbstractTreeWriter {
super(configuration, filename, classtree);
packages = configuration.packages;
classesOnly = packages.isEmpty();
this.navBar = new Navigation(null, configuration, PageMode.TREE, path);
this.bodyContents = new BodyContents();
}
@ -118,13 +115,9 @@ public class TreeWriter extends AbstractTreeWriter {
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(Navigation.Position.BOTTOM));
addBottom(footerTree);
body.add(bodyContents
.addMainContent(mainContent)
.setFooter(footerTree));
.setFooter(getFooter()));
printHtmlDocument(null, "class tree", body);
}
@ -175,11 +168,7 @@ public class TreeWriter extends AbstractTreeWriter {
protected HtmlTree getTreeHeader() {
String title = resources.getText("doclet.Window_Class_Hierarchy");
HtmlTree bodyTree = getBody(getWindowTitle(title));
Content headerContent = new ContentBuilder();
addTop(headerContent);
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
bodyContents.setHeader(headerContent);
bodyContents.setHeader(getHeader(PageMode.TREE));
return bodyTree;
}

View File

@ -31,6 +31,7 @@ import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Content for the {@code <body>} element.
@ -47,20 +48,20 @@ import java.util.List;
public class BodyContents extends Content {
private List<Content> mainContents = new ArrayList<>();
private Content header = HtmlTree.EMPTY;
private Content footer = HtmlTree.EMPTY;
private HtmlTree header = null;
private HtmlTree footer = null;
public BodyContents addMainContent(Content content) {
mainContents.add(content);
return this;
}
public BodyContents setHeader(Content header) {
this.header = header;
public BodyContents setHeader(HtmlTree header) {
this.header = Objects.requireNonNull(header);
return this;
}
public BodyContents setFooter(Content footer) {
public BodyContents setFooter(HtmlTree footer) {
this.footer = footer;
return this;
}
@ -88,13 +89,14 @@ public class BodyContents extends Content {
* @return the HTML
*/
private Content toContent() {
HtmlTree flexHeader = HtmlTree.HEADER()
.setStyle(HtmlStyle.flexHeader)
.add(header);
if (header == null)
throw new NullPointerException();
HtmlTree flexHeader = header.addStyle(HtmlStyle.flexHeader);
HtmlTree flexContent = HtmlTree.DIV(HtmlStyle.flexContent)
.add(HtmlTree.MAIN().add(mainContents))
.add(footer);
.add(footer == null ? HtmlTree.EMPTY : footer);
return HtmlTree.DIV(HtmlStyle.flexBox)
.add(flexHeader)

View File

@ -97,11 +97,6 @@ public enum HtmlStyle {
*/
topNav,
/**
* The class for the overall {@code div} element containing the {@code footer} element for the page.
*/
bottomNav,
/**
* The class for the element containing the information (such as the product name and version)
* provided by the {@code -header} or {@code -footer} command line option.

View File

@ -491,7 +491,12 @@ doclet.usage.xdoclint-package.description=\
of the given package. Prefix the package specifier with - to\n\
disable checks for the specified packages.
# L10N: do not localize the option names --no-frames
# L10N: do not localize the option name --no-frames
doclet.NoFrames_specified=\
The --no-frames option is no longer required and may be removed\n\
in a future release.
# L10N: do not localize the option name -footer
doclet.footer_specified=\
The -footer option is no longer supported and will be ignored.\n\
It may be removed in a future release.

View File

@ -152,19 +152,6 @@ button {
overflow:hidden;
font-size:12px;
}
.bottom-nav {
margin-top:10px;
background-color:#4D7A97;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
font-size:12px;
}
.sub-nav {
background-color:#dee3e9;
float:left;
@ -207,12 +194,12 @@ ul.sub-nav-list li {
float:left;
padding-top:10px;
}
.top-nav a:link, .top-nav a:active, .top-nav a:visited, .bottom-nav a:link, .bottom-nav a:active, .bottom-nav a:visited {
.top-nav a:link, .top-nav a:active, .top-nav a:visited {
color:#FFFFFF;
text-decoration:none;
text-transform:uppercase;
}
.top-nav a:hover, .bottom-nav a:hover {
.top-nav a:hover {
text-decoration:none;
color:#bb7a2a;
text-transform:uppercase;

View File

@ -56,14 +56,6 @@ public class AccessSkipNav extends JavadocTester {
"""
<span class="skip-nav" id="skip.navbar.top">
<!-- -->
</span>""",
// Bottom navbar <a href>
"""
<a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a>""",
// Bottom navbar <span id>
"""
<span class="skip-nav" id="skip.navbar.bottom">
<!-- -->
</span>""");
}
}

View File

@ -71,18 +71,7 @@ public class TestCopyFiles extends JavadocTester {
In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>.""",
"<dt>Since:</",
"forever",
// check bottom navbar
"""
<a href="../../module-summary.html">Module</a>""",
"""
<a href="../package-summary.html">Package</a>""",
"""
<a href="../../../overview-tree.html">Tree</a>""",
"""
<a href="../../../deprecated-list.html">Deprecated</a>""",
"""
<a href="../../../index-all.html">Index</a>""",
"phi-FOOTER-phi",
// check footer
"phi-BOTTOM-phi"
);
}
@ -119,18 +108,7 @@ public class TestCopyFiles extends JavadocTester {
In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>.""",
"<dt>Since:</",
"forever",
// check bottom navbar
"""
<a href="../../module-summary.html">Module</a>""",
"""
<a href="../package-summary.html">Package</a>""",
"""
<a href="../../../overview-tree.html">Tree</a>""",
"""
<a href="../../../deprecated-list.html">Deprecated</a>""",
"""
<a href="../../../index-all.html">Index</a>""",
"phi-FOOTER-phi",
// check footer
"phi-BOTTOM-phi"
);
@ -151,18 +129,7 @@ public class TestCopyFiles extends JavadocTester {
<a href="../../../../../index-all.html">Index</a>""",
"phi-HEADER-phi",
"SubSubReadme.html at third level of doc-file directory.",
// check bottom navbar
"""
<a href="../../../../module-summary.html">Module</a>""",
"""
<a href="../../../package-summary.html">Package</a>""",
"""
<a href="../../../../../overview-tree.html">Tree</a>""",
"""
<a href="../../../../../deprecated-list.html">Deprecated</a>""",
"""
<a href="../../../../../index-all.html">Index</a>""",
"phi-FOOTER-phi",
// check footer
"phi-BOTTOM-phi"
);
}

View File

@ -68,6 +68,7 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
javadoc("-d", outDir.toString(),
"-doctitle", "Document Title",
"-header", "Test Header",
"-bottom", "bottom text",
"--module-source-path", srcDir.toString(),
"--module", "m1,m2");
@ -82,8 +83,10 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
<div class="header">
<h1 class="title">Document Title</h1>""",
"""
<footer role="contentinfo">
<nav role="navigation">""");
<footer role="contentinfo"> """,
"""
bottom text"""
);
}
@Test
@ -95,6 +98,7 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
javadoc("-d", outDir.toString(),
"-doctitle", "Document Title",
"-header", "Test Header",
"-bottom", "bottom text",
"-sourcepath", srcDir.toString(),
"pkg1", "pkg2");
@ -109,8 +113,9 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
<div class="header">
<h1 class="title">Document Title</h1>""",
"""
<footer role="contentinfo">
<nav role="navigation">""");
<footer role="contentinfo">""",
"""
bottom text""");
}
@Test
@ -131,6 +136,7 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
Path outDir = base.resolve("out");
javadoc("-d", outDir.toString(),
"-bottom", "bottom text",
"-sourcepath", srcDir.toString(),
"pkg1", "pkg2");
@ -144,8 +150,9 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
"""
<main role="main">A sample doc file""",
"""
<footer role="contentinfo">
<nav role="navigation">"""
<footer role="contentinfo">""",
"""
bottom text"""
);
}

View File

@ -46,6 +46,7 @@ public class TestHtmlVersion extends JavadocTester {
javadoc("-d", "out-1",
"-private",
"-linksource",
"-bottom", "bottom text",
"-sourcepath", testSrc,
"-use",
"pkg", "pkg1", "pkg2", "pkg3");
@ -60,6 +61,7 @@ public class TestHtmlVersion extends JavadocTester {
javadoc("-d", "out-4",
"-private",
"-linksource",
"-bottom", "bottom text",
"-sourcepath", testSrc,
"-use",
"pkg3");
@ -83,9 +85,9 @@ public class TestHtmlVersion extends JavadocTester {
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for package-summary page
checkOutput("pkg/package-summary.html", true,
@ -107,9 +109,9 @@ public class TestHtmlVersion extends JavadocTester {
<section class="package-description" id="package.description">
<div class="block">Test package.</div>""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// No package description
checkOutput("pkg1/package-summary.html", true,
"""
@ -147,9 +149,9 @@ public class TestHtmlVersion extends JavadocTester {
<section class="hierarchy">
<h2 title="Enum Hierarchy">Enum Hierarchy</h2>""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""" );
// Test for package-use page
checkOutput("pkg1/package-use.html", true,
@ -168,9 +170,9 @@ public class TestHtmlVersion extends JavadocTester {
<main role="main">
<div class="header">""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for constant-values page
checkOutput("constant-values.html", true,
@ -197,9 +199,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2 title="pkg">pkg.*</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for deprecated-list page
checkOutput("deprecated-list.html", true,
@ -218,9 +220,9 @@ public class TestHtmlVersion extends JavadocTester {
<main role="main">
<div class="header">""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for serialized-form page
checkOutput("serialized-form.html", true,
@ -241,9 +243,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2 title="Package">Package&nbsp;pkg</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for overview-tree page
checkOutput("overview-tree.html", true,
@ -277,9 +279,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2 title="Enum Hierarchy">Enum Hierarchy</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for index-all page
checkOutput("index-all.html", true,
@ -297,9 +299,9 @@ public class TestHtmlVersion extends JavadocTester {
<div class="flex-content">
<main role="main">""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for src-html page
checkOutput("src-html/pkg/AnotherClass.html", true,
@ -335,9 +337,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Class or Interface</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for a regular class page and members (nested class, field, constructore and method)
checkOutput("pkg/AnotherClass.html", true,
@ -385,9 +387,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Method Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for enum page
checkOutput("pkg/AnotherClass.ModalExclusionType.html", true,
@ -426,9 +428,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Method Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for interface page
checkOutput("pkg2/Interface.html", true,
@ -458,9 +460,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Method Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for error page
checkOutput("pkg/TestError.html", true,
@ -485,9 +487,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Constructor Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for exception page
checkOutput("pkg/TestException.html", true,
@ -512,9 +514,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Constructor Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for annotation page
checkOutput("pkg2/TestAnnotationType.html", true,
@ -550,9 +552,9 @@ public class TestHtmlVersion extends JavadocTester {
<h2>Element Details</h2>
""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
// Test for class use page
checkOutput("pkg1/class-use/RegClass.html", true,
@ -579,9 +581,9 @@ public class TestHtmlVersion extends JavadocTester {
/span></div>
<div class="summary-table three-column-summary">""",
"""
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->""");
<footer role="contentinfo">""",
"""
bottom text""");
}
void html5NegatedOutput() {

View File

@ -44,19 +44,16 @@ public class TestOptions extends JavadocTester {
}
@Test
public void testHeaderFooter() {
public void testHeader() {
javadoc("-d", "out-1",
"-header", "Test header",
"-footer", "Test footer",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/package-summary.html", true,
"""
<div class="about-language">Test header</div>""",
"""
<div class="about-language">Test footer</div>""");
<div class="about-language">Test header</div>""");
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -103,7 +103,6 @@ public class TestScriptInComment {
MTH("package p; public class C { #COMMENT public void m() { } }"),
TOP("-top", "lorem #COMMENT ipsum", "package p; public class C { }"),
HDR("-header", "lorem #COMMENT ipsum", "package p; public class C { }"),
FTR("-footer", "lorem #COMMENT ipsum", "package p; public class C { }"),
BTM("-bottom", "lorem #COMMENT ipsum", "package p; public class C { }"),
DTTL("-doctitle", "lorem #COMMENT ipsum", "package p; public class C { }"),
PHDR("-packagesheader", "lorem #COMMENT ipsum", "package p; public class C { }");