8196200: Implement a navigation builder in javadoc
authorbpatel
Mon, 09 Apr 2018 09:45:51 -0700
changeset 49551 0d4786e42471
parent 49550 dce997f9a93e
child 49552 05883543ee2a
8196200: Implement a navigation builder in javadoc Reviewed-by: jjg, ksrini
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java
test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java
test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -42,6 +42,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -72,6 +74,8 @@
      */
     protected IndexBuilder indexbuilder;
 
+    protected Navigation navBar;
+
     /**
      * This constructor will be used by {@link SplitIndexWriter}. Initializes
      * path to this file and relative path from this file.
@@ -85,17 +89,7 @@
                                   IndexBuilder indexbuilder) {
         super(configuration, path);
         this.indexbuilder = indexbuilder;
-    }
-
-    /**
-     * Get the index label for navigation bar.
-     *
-     * @return a content tree for the tree label
-     */
-    @Override
-    protected Content getNavLinkIndex() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.indexLabel);
-        return li;
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.INDEX, path);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -45,6 +45,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -215,23 +216,6 @@
     protected abstract Content getDeprecatedLink(Element member);
 
     /**
-     * Get the navigation summary link.
-     *
-     * @param typeElement the TypeElement to be documented
-     * @param link true if its a link else the label to be printed
-     * @return a content tree for the navigation summary link.
-     */
-    protected abstract Content getNavSummaryLink(TypeElement typeElement, boolean link);
-
-    /**
-     * Add the navigation detail link.
-     *
-     * @param link true if its a link else the label to be printed
-     * @param liNav the content tree to which the navigation detail link will be added
-     */
-    protected abstract void addNavDetailLink(boolean link, Content liNav);
-
-    /**
      * Add the member name to the content tree.
      *
      * @param name the member name to be added to the content tree.
@@ -474,41 +458,6 @@
         }
     }
 
-    /**
-     * Add the navigation detail link.
-     *
-     * @param members the members to be linked
-     * @param liNav the content tree to which the navigation detail link will be added
-     */
-    protected void addNavDetailLink(SortedSet<Element> members, Content liNav) {
-        addNavDetailLink(!members.isEmpty(), liNav);
-    }
-
-    /**
-     * Add the navigation summary link.
-     *
-     * @param members members to be linked
-     * @param visibleMemberMap the visible inherited members map
-     * @param liNav the content tree to which the navigation summary link will be added
-     */
-    protected void addNavSummaryLink(SortedSet<? extends Element> members,
-            VisibleMemberMap visibleMemberMap, Content liNav) {
-        if (!members.isEmpty()) {
-            liNav.addContent(getNavSummaryLink(null, true));
-            return;
-        }
-
-        TypeElement superClass = utils.getSuperClass(typeElement);
-        while (superClass != null) {
-            if (visibleMemberMap.hasMembers(superClass)) {
-                liNav.addContent(getNavSummaryLink(superClass, true));
-                return;
-            }
-            superClass = utils.getSuperClass(superClass);
-        }
-        liNav.addContent(getNavSummaryLink(null, false));
-    }
-
     protected void serialWarning(Element e, String key, String a1, String a2) {
         if (configuration.serialwarn) {
             configuration.messages.warning(e, key, a1, a2);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,6 +37,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@@ -61,6 +63,8 @@
      */
     protected SortedMap<ModuleElement, Set<PackageElement>> modules;
 
+    protected Navigation navBar;
+
     /**
      * Constructor. Also initializes the modules variable.
      *
@@ -71,6 +75,7 @@
                                       DocPath filename) {
         super(configuration, filename);
         modules = configuration.modulePackages;
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.OVERVIEW, path);
     }
 
     /**
@@ -252,18 +257,6 @@
     }
 
     /**
-     * Returns highlighted "Overview", in the navigation bar as this is the
-     * overview page.
-     *
-     * @return a Content object to be added to the documentation tree
-     */
-    @Override
-    protected Content getNavLinkContents() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel);
-        return li;
-    }
-
-    /**
      * Do nothing. This will be overridden in ModuleIndexFrameWriter.
      *
      * @param div the document tree to which the all classes link will be added
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -33,6 +33,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@@ -58,6 +60,8 @@
      */
     protected SortedSet<PackageElement> packages;
 
+    protected Navigation navBar;
+
     /**
      * Constructor. Also initializes the packages variable.
      *
@@ -68,6 +72,7 @@
                                       DocPath filename) {
         super(configuration, filename);
         packages = configuration.packages;
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.OVERVIEW, path);
     }
 
     /**
@@ -174,18 +179,6 @@
     }
 
     /**
-     * Returns highlighted "Overview", in the navigation bar as this is the
-     * overview page.
-     *
-     * @return a Content object to be added to the documentation tree
-     */
-    @Override
-    protected Content getNavLinkContents() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel);
-        return li;
-    }
-
-    /**
      * Do nothing. This will be overridden.
      *
      * @param div the document tree to which the all classes link will be added
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -184,14 +184,4 @@
     protected void addPartialInfo(TypeElement typeElement, Content contentTree) {
         addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, typeElement, contentTree);
     }
-
-    /**
-     * Get the tree label for the navigation bar.
-     *
-     * @return a content tree for the tree label
-     */
-    protected Content getNavLinkTree() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.treeLabel);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,7 +37,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -285,31 +285,6 @@
                 member, utils.getFullyQualifiedName(member));
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            return links.createLink(
-                    SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
-                    contents.navField);
-        } else {
-            return contents.navField;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
-                    contents.navField));
-        } else {
-            liNav.addContent(contents.navField);
-        }
-    }
     private TypeMirror getType(Element member) {
         if (utils.isConstructor(member))
             return null;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -35,7 +35,7 @@
 
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -152,18 +152,4 @@
         memberTree.addContent(links.createAnchor(
                 SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY));
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            return links.createLink(
-                    SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
-                    contents.navAnnotationTypeOptionalMember);
-        } else {
-            return contents.navAnnotationTypeOptionalMember;
-        }
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,7 +37,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -300,32 +300,6 @@
         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            return links.createLink(
-                    SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
-                    contents.navAnnotationTypeRequiredMember);
-        } else {
-            return contents.navAnnotationTypeRequiredMember;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
-                    contents.navAnnotationTypeMember));
-        } else {
-            liNav.addContent(contents.navAnnotationTypeMember);
-        }
-    }
-
     private TypeMirror getType(Element member) {
         return utils.isExecutableElement(member)
                 ? utils.getReturnType((ExecutableElement) member)
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -30,21 +30,20 @@
 import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.TypeMirror;
 
 import com.sun.source.doctree.DocTree;
 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;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
 
 /**
@@ -69,6 +68,8 @@
 
     protected TypeElement annotationType;
 
+    private final Navigation navBar;
+
     /**
      * @param configuration the configuration
      * @param annotationType the annotation type being documented.
@@ -78,55 +79,7 @@
         super(configuration, configuration.docPaths.forClass(annotationType));
         this.annotationType = annotationType;
         configuration.currentTypeElement = annotationType;
-    }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get this package link.
-     *
-     * @return a content tree for the package link
-     */
-    @Override
-    protected Content getNavLinkPackage() {
-        Content linkContent = links.createLink(DocPaths.PACKAGE_SUMMARY,
-                contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the class link.
-     *
-     * @return a content tree for the class link
-     */
-    @Override
-    protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel);
-        return li;
-    }
-
-    /**
-     * Get the class use link.
-     *
-     * @return a content tree for the class use link
-     */
-    @Override
-    protected Content getNavLinkClassUse() {
-        Content linkContent = links.createLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
+        this.navBar = new Navigation(annotationType, configuration, fixedNavDiv, PageMode.CLASS, path);
     }
 
     /**
@@ -139,7 +92,12 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
+                contents.moduleLabel);
+        navBar.setNavLinkModule(linkContent);
+        navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -195,7 +153,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : contentTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             contentTree.addContent(htmlTree);
@@ -299,123 +258,6 @@
      * {@inheritDoc}
      */
     @Override
-    protected Content getNavLinkTree() {
-        Content treeLinkContent = links.createLink(DocPaths.PACKAGE_TREE,
-                contents.treeLabel, "", "");
-        Content li = HtmlTree.LI(treeLinkContent);
-        return li;
-    }
-
-    /**
-     * Add summary details to the navigation bar.
-     *
-     * @param subDiv the content tree to which the summary detail links will be added
-     */
-    @Override
-    protected void addSummaryDetailLinks(Content subDiv) {
-        Content div = HtmlTree.DIV(getNavSummaryLinks());
-        div.addContent(getNavDetailLinks());
-        subDiv.addContent(div);
-    }
-
-    /**
-     * Get summary links for navigation bar.
-     *
-     * @return the content tree for the navigation summary links
-     */
-    protected Content getNavSummaryLinks() {
-        Content li = HtmlTree.LI(contents.summaryLabel);
-        li.addContent(Contents.SPACE);
-        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
-        MemberSummaryBuilder memberSummaryBuilder =
-                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
-        Content liNavField = new HtmlTree(HtmlTag.LI);
-        addNavSummaryLink(memberSummaryBuilder,
-                "doclet.navField",
-                VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, liNavField);
-        addNavGap(liNavField);
-        ulNav.addContent(liNavField);
-        Content liNavReq = new HtmlTree(HtmlTag.LI);
-        addNavSummaryLink(memberSummaryBuilder,
-                "doclet.navAnnotationTypeRequiredMember",
-                VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
-        addNavGap(liNavReq);
-        ulNav.addContent(liNavReq);
-        Content liNavOpt = new HtmlTree(HtmlTag.LI);
-        addNavSummaryLink(memberSummaryBuilder,
-                "doclet.navAnnotationTypeOptionalMember",
-                VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
-        ulNav.addContent(liNavOpt);
-        return ulNav;
-    }
-
-    /**
-     * Add the navigation summary link.
-     *
-     * @param builder builder for the member to be documented
-     * @param label the label for the navigation
-     * @param type type to be documented
-     * @param liNav the content tree to which the navigation summary link will be added
-     */
-    protected void addNavSummaryLink(MemberSummaryBuilder builder,
-            String label, VisibleMemberMap.Kind type, Content liNav) {
-        AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
-                getMemberSummaryWriter(type));
-        if (writer == null) {
-            liNav.addContent(contents.getContent(label));
-        } else {
-            liNav.addContent(writer.getNavSummaryLink(null,
-                    ! builder.getVisibleMemberMap(type).noVisibleMembers()));
-        }
-    }
-
-    /**
-     * Get detail links for the navigation bar.
-     *
-     * @return the content tree for the detail links
-     */
-    protected Content getNavDetailLinks() {
-        Content li = HtmlTree.LI(contents.detailLabel);
-        li.addContent(Contents.SPACE);
-        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
-        MemberSummaryBuilder memberSummaryBuilder =
-                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
-        AbstractMemberWriter writerField =
-                ((AbstractMemberWriter) memberSummaryBuilder.
-                getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
-        AbstractMemberWriter writerOptional =
-                ((AbstractMemberWriter) memberSummaryBuilder.
-                getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
-        AbstractMemberWriter writerRequired =
-                ((AbstractMemberWriter) memberSummaryBuilder.
-                getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
-        Content liNavField = new HtmlTree(HtmlTag.LI);
-        if (writerField != null) {
-            writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField);
-        } else {
-            liNavField.addContent(contents.navField);
-        }
-        addNavGap(liNavField);
-        ulNav.addContent(liNavField);
-        if (writerOptional != null){
-            Content liNavOpt = new HtmlTree(HtmlTag.LI);
-            writerOptional.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavOpt);
-            ulNav.addContent(liNavOpt);
-        } else if (writerRequired != null){
-            Content liNavReq = new HtmlTree(HtmlTag.LI);
-            writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq);
-            ulNav.addContent(liNavReq);
-        } else {
-            Content liNav = HtmlTree.LI(contents.navAnnotationTypeMember);
-            ulNav.addContent(liNav);
-        }
-        return ulNav;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public TypeElement getAnnotationTypeElement() {
         return annotationType;
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -47,7 +47,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
@@ -106,6 +107,7 @@
     final String methodUseTableSummary;
     final String constructorUseTableSummary;
     final String packageUseTableSummary;
+    private final Navigation navBar;
 
     /**
      * The HTML tree for main tag.
@@ -178,6 +180,7 @@
                 resources.getText("doclet.constructors"));
         packageUseTableSummary = MessageFormat.format(useTableSummary,
                 resources.getText("doclet.packages"));
+        this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.USE, path);
     }
 
     /**
@@ -264,7 +267,8 @@
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
@@ -476,7 +480,15 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        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(configuration.getText("doclet.Class")));
+        navBar.setNavLinkClass(classLinkContent);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -494,65 +506,4 @@
         }
         return bodyTree;
     }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get this package link.
-     *
-     * @return a content tree for the package link
-     */
-    protected Content getNavLinkPackage() {
-        Content linkContent =
-                links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get class page link.
-     *
-     * @return a content tree for the class page link
-     */
-    protected Content getNavLinkClass() {
-        Content linkContent = getLink(new LinkInfoImpl(
-                configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
-                .label(configuration.getText("doclet.Class")));
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the use link.
-     *
-     * @return a content tree for the use link
-     */
-    protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
-        return li;
-    }
-
-    /**
-     * Get the tree link.
-     *
-     * @return a content tree for the tree link
-     */
-    protected Content getNavLinkTree() {
-        Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
-                ? links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
-                : links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -40,6 +40,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -48,11 +50,9 @@
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
-import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
 
 /**
  * Generate the Class Information Page.
@@ -78,6 +78,8 @@
 
     protected final ClassTree classtree;
 
+    private final Navigation navBar;
+
     /**
      * @param configuration the configuration data for the doclet
      * @param typeElement the class being documented.
@@ -89,55 +91,7 @@
         this.typeElement = typeElement;
         configuration.currentTypeElement = typeElement;
         this.classtree = classTree;
-    }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get this package link.
-     *
-     * @return a content tree for the package link
-     */
-    @Override
-    protected Content getNavLinkPackage() {
-        Content linkContent = links.createLink(DocPaths.PACKAGE_SUMMARY,
-                contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the class link.
-     *
-     * @return a content tree for the class link
-     */
-    @Override
-    protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel);
-        return li;
-    }
-
-    /**
-     * Get the class use link.
-     *
-     * @return a content tree for the class use link
-     */
-    @Override
-    protected Content getNavLinkClassUse() {
-        Content linkContent = links.createLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
+        this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.CLASS, path);
     }
 
     /**
@@ -150,7 +104,12 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
+                contents.moduleLabel);
+        navBar.setNavLinkModule(linkContent);
+        navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -210,7 +169,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : contentTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             contentTree.addContent(htmlTree);
@@ -609,100 +569,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavLinkTree() {
-        Content treeLinkContent = links.createLink(DocPaths.PACKAGE_TREE,
-                contents.treeLabel, "", "");
-        Content li = HtmlTree.LI(treeLinkContent);
-        return li;
-    }
-
-    /**
-     * Add summary details to the navigation bar.
-     *
-     * @param subDiv the content tree to which the summary detail links will be added
-     */
-    @Override
-    protected void addSummaryDetailLinks(Content subDiv) {
-        Content div = HtmlTree.DIV(getNavSummaryLinks());
-        div.addContent(getNavDetailLinks());
-        subDiv.addContent(div);
-    }
-
-    /**
-     * Get summary links for navigation bar.
-     *
-     * @return the content tree for the navigation summary links
-     */
-    protected Content getNavSummaryLinks() {
-        Content li = HtmlTree.LI(contents.summaryLabel);
-        li.addContent(Contents.SPACE);
-        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
-        MemberSummaryBuilder memberSummaryBuilder =
-                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
-        for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
-            Content liNav = new HtmlTree(HtmlTag.LI);
-            if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
-                continue;
-            }
-            if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
-                continue;
-            }
-            AbstractMemberWriter writer =
-                ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
-            if (writer == null) {
-                liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
-            } else {
-                writer.addNavSummaryLink(
-                        memberSummaryBuilder.members(kind),
-                        memberSummaryBuilder.getVisibleMemberMap(kind), liNav);
-            }
-            if (kind != Kind.METHODS) {
-                addNavGap(liNav);
-            }
-            ulNav.addContent(liNav);
-        }
-        return ulNav;
-    }
-
-    /**
-     * Get detail links for the navigation bar.
-     *
-     * @return the content tree for the detail links
-     */
-    protected Content getNavDetailLinks() {
-        Content li = HtmlTree.LI(contents.detailLabel);
-        li.addContent(Contents.SPACE);
-        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
-        MemberSummaryBuilder memberSummaryBuilder =
-                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
-        for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
-            Content liNav = new HtmlTree(HtmlTag.LI);
-            AbstractMemberWriter writer =
-                    ((AbstractMemberWriter) memberSummaryBuilder.
-                    getMemberSummaryWriter(kind));
-            if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
-                continue;
-            }
-            if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
-                continue;
-            }
-            if (writer == null) {
-                liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
-            } else {
-                writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav);
-            }
-            if (kind != Kind.METHODS) {
-                addNavGap(liNav);
-            }
-            ulNav.addContent(liNav);
-        }
-        return ulNav;
-    }
-
-    /**
      * Return the TypeElement being documented.
      *
      * @return the TypeElement being documented.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -40,7 +40,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -86,6 +87,8 @@
      */
     private HtmlTree summaryTree;
 
+    private final Navigation navBar;
+
     /**
      * Construct a ConstantsSummaryWriter.
      * @param configuration the configuration used in this run
@@ -98,6 +101,7 @@
                 configuration.getText("doclet.Constants_Summary"));
         constantsTableHeader = new TableHeader(
                 contents.modifierAndTypeLabel, contents.constantFieldLabel, contents.valueLabel);
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.CONSTANTVALUES, path);
     }
 
     /**
@@ -111,7 +115,8 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -341,7 +346,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : contentTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             contentTree.addContent(htmlTree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -38,7 +38,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -298,33 +298,6 @@
      * {@inheritDoc}
      */
     @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            return links.createLink(SectionName.CONSTRUCTOR_SUMMARY,
-                    contents.navConstructor);
-        } else {
-            return contents.navConstructor;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.CONSTRUCTOR_DETAIL,
-                    contents.navConstructor));
-        } else {
-            liNav.addContent(contents.navConstructor);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     protected void addSummaryType(Element member, Content tdSummaryType) {
         if (foundNonPubConstructor) {
             Content code = new HtmlTree(HtmlTag.CODE);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -42,6 +42,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
@@ -209,6 +211,8 @@
 
     private HtmlConfiguration configuration;
 
+    private final Navigation navBar;
+
     /**
      * Constructor.
      *
@@ -219,6 +223,7 @@
     public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         this.configuration = configuration;
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.DEPRECATED, path);
         NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
         writerMap = new EnumMap<>(DeprElementKind.class);
         for (DeprElementKind kind : DeprElementKind.values()) {
@@ -307,7 +312,8 @@
         htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
@@ -378,7 +384,8 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -386,17 +393,6 @@
     }
 
     /**
-     * Get the deprecated label.
-     *
-     * @return a content tree for the deprecated label
-     */
-    @Override
-    protected Content getNavLinkDeprecated() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel);
-        return li;
-    }
-
-    /**
      * Add deprecated information to the documentation tree
      *
      * @param deprList list of deprecated API elements
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -27,16 +27,15 @@
 
 import com.sun.source.doctree.AttributeTree;
 import com.sun.source.doctree.AttributeTree.ValueKind;
-import com.sun.source.doctree.DocRootTree;
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.EndElementTree;
-import com.sun.source.doctree.LinkTree;
 import com.sun.source.doctree.StartElementTree;
 import com.sun.source.doctree.TextTree;
 import com.sun.source.util.SimpleDocTreeVisitor;
 import com.sun.tools.doclint.HtmlTag;
 import com.sun.tools.doclint.HtmlTag.Attr;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocFileElement;
 import jdk.javadoc.internal.doclets.toolkit.DocFilesHandler;
@@ -51,15 +50,19 @@
 import javax.lang.model.element.PackageElement;
 import javax.tools.FileObject;
 import javax.tools.JavaFileManager.Location;
+
 import java.util.Collections;
 import java.util.List;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
+
 public class DocFilesHandlerImpl implements DocFilesHandler {
 
     public final Element element;
     public final Location location;
     public final DocPath  source;
     public final HtmlConfiguration configuration;
+    private Navigation navBar;
 
     /**
      * Constructor to construct the DocFilesWriter object.
@@ -171,14 +174,24 @@
         String title = getWindowTitle(docletWriter, dfElement).trim();
         HtmlTree htmlContent = docletWriter.getBody(true, title);
         docletWriter.addTop(htmlContent);
-        docletWriter.addNavLinks(true, htmlContent);
+        PackageElement pkg = (PackageElement) element;
+        this.navBar = new Navigation(pkg, configuration, docletWriter.fixedNavDiv,
+                PageMode.DOCFILE, docletWriter.path);
+        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));
+        htmlContent.addContent(navBar.getContent(true));
         List<? extends DocTree> fullBody = utils.getFullBody(dfElement);
         Content bodyContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false);
 
         docletWriter.addTagsInfo(dfElement, bodyContent);
         htmlContent.addContent(bodyContent);
 
-        docletWriter.addNavLinks(false, htmlContent);
+        navBar.setUserFooter(docletWriter.getUserHeaderFooter(false));
+        htmlContent.addContent(navBar.getContent(false));
         docletWriter.addBottom(htmlContent);
         docletWriter.printHtmlDocument(Collections.emptyList(), false, htmlContent);
         return true;
@@ -301,31 +314,5 @@
                     throw new AssertionError("unsupported element: " + e.getKind());
             }
         }
-
-        /**
-         * Get the module link.
-         *
-         * @return a content tree for the module link
-         */
-        @Override
-        protected Content getNavLinkModule() {
-            Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(pkg),
-                    contents.moduleLabel);
-            Content li = HtmlTree.LI(linkContent);
-            return li;
-        }
-
-        /**
-         * Get this package link.
-         *
-         * @return a content tree for the package link
-         */
-        @Override
-        protected Content getNavLinkPackage() {
-            Content linkContent = getPackageLink(pkg,
-                    contents.packageLabel);
-            Content li = HtmlTree.LI(linkContent);
-            return li;
-        }
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,7 +37,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
@@ -273,37 +273,4 @@
         String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            if (typeElement == null) {
-                return links.createLink(SectionName.ENUM_CONSTANT_SUMMARY,
-                        contents.navEnum);
-            } else {
-                return links.createLink(
-                        SectionName.ENUM_CONSTANTS_INHERITANCE,
-                        configuration.getClassName(typeElement), contents.navEnum);
-            }
-        } else {
-            return contents.navEnum;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.ENUM_CONSTANT_DETAIL,
-                    contents.navEnum));
-        } else {
-            liNav.addContent(contents.navEnum);
-        }
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -39,7 +39,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
@@ -302,38 +302,4 @@
         String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            if (typeElement == null) {
-                return links.createLink(
-                        SectionName.FIELD_SUMMARY,
-                        contents.navField);
-            } else {
-                return links.createLink(
-                        SectionName.FIELDS_INHERITANCE,
-                        configuration.getClassName(typeElement), contents.navField);
-            }
-        } else {
-            return contents.navField;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.FIELD_DETAIL,
-                    contents.navField));
-        } else {
-            liNav.addContent(contents.navField);
-        }
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -29,6 +29,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@@ -51,6 +53,8 @@
 
     HtmlTree mainTree = HtmlTree.MAIN();
 
+    private final Navigation navBar;
+
     /**
      * Constructor to construct HelpWriter object.
      * @param configuration the configuration
@@ -59,6 +63,7 @@
     public HelpWriter(HtmlConfiguration configuration,
                       DocPath filename) {
         super(configuration, filename);
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.HELP, path);
     }
 
     /**
@@ -88,7 +93,8 @@
                 ? HtmlTree.HEADER()
                 : body;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             body.addContent(htmlTree);
         }
@@ -96,7 +102,8 @@
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             htmlTree = HtmlTree.FOOTER();
         }
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
@@ -428,15 +435,4 @@
             contentTree.addContent(divContent);
         }
     }
-
-    /**
-     * Get the help label.
-     *
-     * @return a content tree for the help label
-     */
-    @Override
-    protected Content getNavLinkHelp() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.helpLabel);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Mon Apr 09 09:45:51 2018 -0700
@@ -247,11 +247,11 @@
 
     protected Set<Character> tagSearchIndexKeys;
 
-    protected final Contents contents;
+    public final Contents contents;
 
     protected final Messages messages;
 
-    protected DocPaths docPaths;
+    public DocPaths docPaths;
 
     /**
      * Creates an object to hold the configuration for a doclet.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -69,13 +69,13 @@
 
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.Script;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
@@ -491,261 +491,6 @@
     }
 
     /**
-     * Adds the navigation bar for the Html page at the top and and the bottom.
-     *
-     * @param header If true print navigation bar at the top of the page else
-     * @param htmlTree the HtmlTree to which the nav links will be added
-     */
-    protected void addNavLinks(boolean header, Content htmlTree) {
-        if (!configuration.nonavbar) {
-            Content tree = (configuration.allowTag(HtmlTag.NAV))
-                    ? HtmlTree.NAV()
-                    : htmlTree;
-            String allClassesId = "allclasses_";
-            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
-            fixedNavDiv.setStyle(HtmlStyle.fixedNav);
-            Content skipNavLinks = configuration.getContent("doclet.Skip_navigation_links");
-            if (header) {
-                fixedNavDiv.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
-                navDiv.setStyle(HtmlStyle.topNav);
-                allClassesId += "navbar_top";
-                Content a = links.createAnchor(SectionName.NAVBAR_TOP);
-                //WCAG - Hyperlinks should contain text or an image with alt text - for AT tools
-                navDiv.addContent(a);
-                Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav,
-                        links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks,
-                        skipNavLinks.toString(), ""));
-                navDiv.addContent(skipLinkContent);
-            } else {
-                tree.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
-                navDiv.setStyle(HtmlStyle.bottomNav);
-                allClassesId += "navbar_bottom";
-                Content a = links.createAnchor(SectionName.NAVBAR_BOTTOM);
-                navDiv.addContent(a);
-                Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav,
-                        links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks,
-                        skipNavLinks.toString(), ""));
-                navDiv.addContent(skipLinkContent);
-            }
-            if (header) {
-                navDiv.addContent(links.createAnchor(SectionName.NAVBAR_TOP_FIRSTROW));
-            } else {
-                navDiv.addContent(links.createAnchor(SectionName.NAVBAR_BOTTOM_FIRSTROW));
-            }
-            HtmlTree navList = new HtmlTree(HtmlTag.UL);
-            navList.setStyle(HtmlStyle.navList);
-            navList.addAttr(HtmlAttr.TITLE,
-                            configuration.getText("doclet.Navigation"));
-            if (configuration.createoverview) {
-                navList.addContent(getNavLinkContents());
-            }
-            if (configuration.showModules) {
-                if (configuration.modules.size() == 1) {
-                    navList.addContent(getNavLinkModule(configuration.modules.first()));
-                } else if (!configuration.modules.isEmpty()) {
-                    navList.addContent(getNavLinkModule());
-                }
-            }
-            if (configuration.packages.size() == 1) {
-                navList.addContent(getNavLinkPackage(configuration.packages.first()));
-            } else if (!configuration.packages.isEmpty()) {
-                navList.addContent(getNavLinkPackage());
-            }
-            navList.addContent(getNavLinkClass());
-            if(configuration.classuse) {
-                navList.addContent(getNavLinkClassUse());
-            }
-            if(configuration.createtree) {
-                navList.addContent(getNavLinkTree());
-            }
-            if(!(configuration.nodeprecated ||
-                     configuration.nodeprecatedlist)) {
-                navList.addContent(getNavLinkDeprecated());
-            }
-            if(configuration.createindex) {
-                navList.addContent(getNavLinkIndex());
-            }
-            if (!configuration.nohelp) {
-                navList.addContent(getNavLinkHelp());
-            }
-            navDiv.addContent(navList);
-            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
-            navDiv.addContent(aboutDiv);
-            if (header) {
-                fixedNavDiv.addContent(navDiv);
-            } else {
-                tree.addContent(navDiv);
-            }
-            HtmlTree subDiv = new HtmlTree(HtmlTag.DIV);
-            subDiv.setStyle(HtmlStyle.subNav);
-            if (configuration.frames) {
-                Content ulFrames = HtmlTree.UL(HtmlStyle.navList,
-                    getNavShowLists(), getNavHideLists(filename));
-                subDiv.addContent(ulFrames);
-            }
-            HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
-            ulAllClasses.addAttr(HtmlAttr.ID, allClassesId);
-            subDiv.addContent(ulAllClasses);
-            if (header && configuration.createindex) {
-                String searchValueId = "search";
-                String reset = "reset";
-                HtmlTree inputText = HtmlTree.INPUT("text", searchValueId, searchValueId);
-                HtmlTree inputReset = HtmlTree.INPUT(reset, reset, reset);
-                Content searchTxt = configuration.getContent("doclet.search");
-                HtmlTree liInput = HtmlTree.LI(HtmlTree.LABEL(searchValueId, searchTxt));
-                liInput.addContent(inputText);
-                liInput.addContent(inputReset);
-                HtmlTree ulSearch = HtmlTree.UL(HtmlStyle.navListSearch, liInput);
-                subDiv.addContent(ulSearch);
-            }
-            subDiv.addContent(getAllClassesLinkScript(allClassesId));
-            addSummaryDetailLinks(subDiv);
-            if (header) {
-                subDiv.addContent(links.createAnchor(SectionName.SKIP_NAVBAR_TOP));
-                fixedNavDiv.addContent(subDiv);
-                fixedNavDiv.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
-                tree.addContent(fixedNavDiv);
-                HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE);
-                tree.addContent(paddingDiv);
-                Script script = new Script(
-                        "<!--\n"
-                        + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                        + "//-->\n");
-                tree.addContent(script.asContent());
-            } else {
-                subDiv.addContent(links.createAnchor(SectionName.SKIP_NAVBAR_BOTTOM));
-                tree.addContent(subDiv);
-                tree.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
-            }
-            if (configuration.allowTag(HtmlTag.NAV)) {
-                htmlTree.addContent(tree);
-            }
-        }
-    }
-
-    /**
-     * Do nothing. This is the default method.
-     */
-    protected void addSummaryDetailLinks(Content navDiv) {
-    }
-
-    /**
-     * Get link to the "overview-summary.html" page.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkContents() {
-        Content linkContent = links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)),
-                contents.overviewLabel, "", "");
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get link to the module summary page for the module passed.
-     *
-     * @param mdle Module to which link will be generated
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkModule(ModuleElement mdle) {
-        Content linkContent = getModuleLink(mdle, contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the word "Module", to indicate that link is not available here.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkModule() {
-        Content li = HtmlTree.LI(contents.moduleLabel);
-        return li;
-    }
-
-    /**
-     * Get link to the "package-summary.html" page for the package passed.
-     *
-     * @param pkg Package to which link will be generated
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkPackage(PackageElement pkg) {
-        Content linkContent = getPackageLink(pkg, contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the word "Package" , to indicate that link is not available here.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkPackage() {
-        Content li = HtmlTree.LI(contents.packageLabel);
-        return li;
-    }
-
-    /**
-     * Get the word "Use", to indicate that link is not available.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(contents.useLabel);
-        return li;
-    }
-
-    /**
-     * Get "FRAMES" link, to switch to the frame version of the output.
-     *
-     * @param link File to be linked, "index.html"
-     * @return a content tree for the link
-     */
-    protected Content getNavShowLists(DocPath link) {
-        DocLink dl = new DocLink(link, path.getPath(), null);
-        Content framesContent = links.createLink(dl, contents.framesLabel, "", "_top");
-        Content li = HtmlTree.LI(framesContent);
-        return li;
-    }
-
-    /**
-     * Get "FRAMES" link, to switch to the frame version of the output.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavShowLists() {
-        return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX));
-    }
-
-    /**
-     * Get "NO FRAMES" link, to switch to the non-frame version of the output.
-     *
-     * @param link File to be linked
-     * @return a content tree for the link
-     */
-    protected Content getNavHideLists(DocPath link) {
-        Content noFramesContent = links.createLink(link, contents.noFramesLabel, "", "_top");
-        Content li = HtmlTree.LI(noFramesContent);
-        return li;
-    }
-
-    /**
-     * Get "Tree" link in the navigation bar. If there is only one package
-     * specified on the command line, then the "Tree" link will be to the
-     * only "package-tree.html" file otherwise it will be to the
-     * "overview-tree.html" file.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkTree() {
-        List<PackageElement> packages = new ArrayList<>(configuration.getSpecifiedPackageElements());
-        DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty()
-                ? pathString(packages.get(0), DocPaths.PACKAGE_TREE)
-                : pathToRoot.resolve(DocPaths.OVERVIEW_TREE);
-        return HtmlTree.LI(links.createLink(docPath, contents.treeLabel, "", ""));
-    }
-
-    /**
      * Get the overview tree link for the main tree.
      *
      * @param label the label for the link
@@ -759,91 +504,6 @@
     }
 
     /**
-     * Get the word "Class", to indicate that class link is not available.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(contents.classLabel);
-        return li;
-    }
-
-    /**
-     * Get "Deprecated" API link in the navigation bar.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkDeprecated() {
-        Content linkContent = links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
-                contents.deprecatedLabel, "", "");
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get link for generated index. If the user has used "-splitindex"
-     * command line option, then link to file "index-files/index-1.html" is
-     * generated otherwise link to file "index-all.html" is generated.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkClassIndex() {
-        Content allClassesContent = links.createLink(pathToRoot.resolve(
-                DocPaths.AllClasses(configuration.frames)),
-                contents.allClassesLabel, "", "");
-        Content li = HtmlTree.LI(allClassesContent);
-        return li;
-    }
-
-    /**
-     * Get link for generated class index.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkIndex() {
-        Content linkContent = links.createLink(pathToRoot.resolve(
-                (configuration.splitindex
-                    ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
-                    : DocPaths.INDEX_ALL)),
-            contents.indexLabel, "", "");
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get help file link. If user has provided a help file, then generate a
-     * link to the user given file, which is already copied to current or
-     * destination directory.
-     *
-     * @return a content tree for the link
-     */
-    protected Content getNavLinkHelp() {
-        String helpfile = configuration.helpfile;
-        DocPath helpfilenm;
-        if (helpfile.isEmpty()) {
-            helpfilenm = DocPaths.HELP_DOC;
-        } else {
-            DocFile file = DocFile.createFileForInput(configuration, helpfile);
-            helpfilenm = DocPath.create(file.getName());
-        }
-        Content linkContent = links.createLink(pathToRoot.resolve(helpfilenm),
-                contents.helpLabel, "", "");
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Add gap between navigation bar elements.
-     *
-     * @param liNav the content tree to which the gap will be added
-     */
-    protected void addNavGap(Content liNav) {
-        liNav.addContent(Contents.SPACE);
-        liNav.addContent("|");
-        liNav.addContent(Contents.SPACE);
-    }
-
-    /**
      * Get table caption.
      *
      * @param title the content for the caption
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -40,7 +40,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -424,37 +424,4 @@
             htmltree.addContent(Contents.SPACE);
         }
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            if (typeElement == null) {
-                return links.createLink(
-                        SectionName.METHOD_SUMMARY,
-                        contents.navMethod);
-            } else {
-                return links.createLink(
-                        SectionName.METHODS_INHERITANCE,
-                        configuration.getClassName(typeElement), contents.navMethod);
-            }
-        } else {
-            return contents.navMethod;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.METHOD_DETAIL, contents.navMethod));
-        } else {
-            liNav.addContent(contents.navMethod);
-        }
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -227,7 +227,8 @@
                 ? HtmlTree.HEADER()
                 : body;
         addTop(tree);
-        addNavLinks(true, tree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        tree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             body.addContent(tree);
         }
@@ -244,7 +245,8 @@
         Content htmltree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, htmltree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmltree.addContent(navBar.getContent(false));
         addBottom(htmltree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmltree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -50,13 +50,14 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.ModuleSummaryWriter;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
 /**
  * Class to generate file for each module contents in the right-hand frame. This will list all the
@@ -171,6 +172,8 @@
      */
     protected HtmlTree sectionTree = HtmlTree.SECTION();
 
+    private final Navigation navBar;
+
     /**
      * Constructor to construct ModuleWriter object and to generate "moduleName-summary.html" file.
      *
@@ -181,6 +184,7 @@
         super(configuration, configuration.docPaths.moduleSummary(mdle));
         this.mdle = mdle;
         this.moduleMode = configuration.docEnv.getModuleMode();
+        this.navBar = new Navigation(mdle, configuration, fixedNavDiv, PageMode.MODULE, path);
         computeModulesData();
     }
 
@@ -196,7 +200,13 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !configuration.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));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -914,47 +924,6 @@
     }
 
     /**
-     * Add summary details to the navigation bar.
-     *
-     * @param subDiv the content tree to which the summary detail links will be added
-     */
-    @Override
-    protected void addSummaryDetailLinks(Content subDiv) {
-        Content div = HtmlTree.DIV(getNavSummaryLinks());
-        subDiv.addContent(div);
-    }
-
-    /**
-     * Get summary links for navigation bar.
-     *
-     * @return the content tree for the navigation summary links
-     */
-    protected Content getNavSummaryLinks() {
-        Content li = HtmlTree.LI(contents.moduleSubNavLabel);
-        li.addContent(Contents.SPACE);
-        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
-        Content liNav = new HtmlTree(HtmlTag.LI);
-        liNav.addContent(!utils.getFullBody(mdle).isEmpty() && !configuration.nocomment
-                ? links.createLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription)
-                : contents.navModuleDescription);
-        addNavGap(liNav);
-        liNav.addContent((display(requires) || display(indirectModules))
-                ? links.createLink(SectionName.MODULES, contents.navModules)
-                : contents.navModules);
-        addNavGap(liNav);
-        liNav.addContent((display(packages)
-                || display(indirectPackages) || display(indirectOpenPackages))
-                ? links.createLink(SectionName.PACKAGES, contents.navPackages)
-                : contents.navPackages);
-        addNavGap(liNav);
-        liNav.addContent((displayServices(uses, usesTrees) || displayServices(provides.keySet(), providesTrees))
-                ? links.createLink(SectionName.SERVICES, contents.navServices)
-                : contents.navServices);
-        ulNav.addContent(liNav);
-        return ulNav;
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -975,7 +944,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : contentTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             contentTree.addContent(htmlTree);
@@ -1017,15 +987,4 @@
             li.addContent(deprDiv);
         }
     }
-
-    /**
-     * Get this module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.moduleLabel);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,7 +37,7 @@
 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.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -205,31 +205,4 @@
     protected Content getDeprecatedLink(Element member) {
         return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER, member);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            if (typeElement == null) {
-                return links.createLink(
-                        SectionName.NESTED_CLASS_SUMMARY,
-                        contents.navNested);
-            } else {
-                return links.createLink(
-                        SectionName.NESTED_CLASSES_INHERITANCE,
-                        utils.getFullyQualifiedName(typeElement), contents.navNested);
-            }
-        } else {
-            return contents.navNested;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -209,7 +209,8 @@
                 ? HtmlTree.HEADER()
                 : body;
         addTop(tree);
-        addNavLinks(true, tree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        tree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             body.addContent(tree);
         }
@@ -226,7 +227,8 @@
         Content tree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, tree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        tree.addContent(navBar.getContent(false));
         addBottom(tree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(tree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -31,6 +31,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@@ -57,6 +59,8 @@
      */
     protected PackageElement packageElement;
 
+    private final Navigation navBar;
+
     /**
      * Constructor.
      * @param configuration the configuration
@@ -67,6 +71,7 @@
         super(configuration, path,
               new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration));
         this.packageElement = packageElement;
+        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.TREE, path);
     }
 
     /**
@@ -118,7 +123,8 @@
         HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, tree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        tree.addContent(navBar.getContent(false));
         addBottom(tree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(tree);
@@ -139,7 +145,11 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+                contents.moduleLabel);
+        navBar.setNavLinkModule(linkContent);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -160,30 +170,4 @@
         ul.addContent(getNavLinkMainTree(configuration.getText("doclet.All_Packages")));
         div.addContent(ul);
     }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get link to the package summary page for the package of this tree.
-     *
-     * @return a content tree for the package link
-     */
-    @Override
-    protected Content getNavLinkPackage() {
-        Content linkContent = links.createLink(DocPaths.PACKAGE_SUMMARY,
-                contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -38,7 +38,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
@@ -63,6 +64,7 @@
     final SortedMap<String, Set<TypeElement>> usingPackageToUsedClasses = new TreeMap<>();
     protected HtmlTree mainTree = HtmlTree.MAIN();
     final String packageUseTableSummary;
+    private final Navigation navBar;
 
     /**
      * Constructor.
@@ -100,6 +102,7 @@
 
         packageUseTableSummary = resources.getText("doclet.Use_Table_Summary",
                 resources.getText("doclet.packages"));
+        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.USE, path);
     }
 
     /**
@@ -140,7 +143,8 @@
         HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : body;
-        addNavLinks(false, tree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        tree.addContent(navBar.getContent(false));
         addBottom(tree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(tree);
@@ -249,7 +253,11 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+                contents.moduleLabel);
+        navBar.setNavLinkModule(linkContent);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -267,54 +275,4 @@
         }
         return bodyTree;
     }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get this package link.
-     *
-     * @return a content tree for the package link
-     */
-    @Override
-    protected Content getNavLinkPackage() {
-        Content linkContent = links.createLink(DocPaths.PACKAGE_SUMMARY,
-                contents.packageLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Get the use link.
-     *
-     * @return a content tree for the use link
-     */
-    @Override
-    protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
-        return li;
-    }
-
-    /**
-     * Get the tree link.
-     *
-     * @return a content tree for the tree link
-     */
-    @Override
-    protected Content getNavLinkTree() {
-        Content linkContent = links.createLink(DocPaths.PACKAGE_TREE,
-                contents.treeLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -40,12 +40,13 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
 /**
@@ -79,6 +80,8 @@
      */
     protected HtmlTree sectionTree = HtmlTree.SECTION();
 
+    private final Navigation navBar;
+
     /**
      * Constructor to construct PackageWriter object and to generate
      * "package-summary.html" file in the respective package directory.
@@ -95,6 +98,7 @@
                 configuration.docPaths.forPackage(packageElement)
                 .resolve(DocPaths.PACKAGE_SUMMARY));
         this.packageElement = packageElement;
+        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.PACKAGE, path);
     }
 
     /**
@@ -107,7 +111,11 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
+                contents.moduleLabel);
+        navBar.setNavLinkModule(linkContent);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -346,7 +354,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : contentTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             contentTree.addContent(htmlTree);
@@ -361,55 +370,4 @@
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement),
                 true, contentTree);
     }
-
-    /**
-     * Get "Use" link for this pacakge in the navigation bar.
-     *
-     * @return a content tree for the class use link
-     */
-    @Override
-    protected Content getNavLinkClassUse() {
-        Content useLink = links.createLink(DocPaths.PACKAGE_USE,
-                contents.useLabel, "", "");
-        Content li = HtmlTree.LI(useLink);
-        return li;
-    }
-
-    /**
-     * Get "Tree" link in the navigation bar. This will be link to the package
-     * tree file.
-     *
-     * @return a content tree for the tree link
-     */
-    @Override
-    protected Content getNavLinkTree() {
-        Content useLink = links.createLink(DocPaths.PACKAGE_TREE,
-                contents.treeLabel, "", "");
-        Content li = HtmlTree.LI(useLink);
-        return li;
-    }
-
-    /**
-     * Get the module link.
-     *
-     * @return a content tree for the module link
-     */
-    @Override
-    protected Content getNavLinkModule() {
-        Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                contents.moduleLabel);
-        Content li = HtmlTree.LI(linkContent);
-        return li;
-    }
-
-    /**
-     * Highlight "Package" in the navigation bar, as this is the package page.
-     *
-     * @return a content tree for the package link
-     */
-    @Override
-    protected Content getNavLinkPackage() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.packageLabel);
-        return li;
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -37,7 +37,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -324,38 +324,4 @@
         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member,
                 utils.getFullyQualifiedName(member));
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
-        if (link) {
-            if (typeElement == null) {
-                return links.createLink(
-                        SectionName.PROPERTY_SUMMARY,
-                        contents.navProperty);
-            } else {
-                return links.createLink(
-                        SectionName.PROPERTIES_INHERITANCE,
-                        configuration.getClassName(typeElement), contents.navProperty);
-            }
-        } else {
-            return contents.navProperty;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavDetailLink(boolean link, Content liNav) {
-        if (link) {
-            liNav.addContent(links.createLink(
-                    SectionName.PROPERTY_DETAIL,
-                    contents.navProperty));
-        } else {
-            liNav.addContent(contents.navProperty);
-        }
-    }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Mon Apr 09 09:45:51 2018 -0700
@@ -33,6 +33,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
@@ -59,12 +61,15 @@
      */
     private HtmlTree mainTree = HtmlTree.MAIN();
 
+    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, fixedNavDiv, PageMode.SERIALIZEDFORM, path);
     }
 
     /**
@@ -79,7 +84,8 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
@@ -261,7 +267,8 @@
         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
                 ? HtmlTree.FOOTER()
                 : serializedTree;
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             serializedTree.addContent(htmlTree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -97,7 +97,8 @@
                 ? HtmlTree.HEADER()
                 : body;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             body.addContent(htmlTree);
         }
@@ -123,7 +124,8 @@
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             htmlTree = HtmlTree.FOOTER();
         }
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -125,7 +125,8 @@
                 ? HtmlTree.HEADER()
                 : body;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             body.addContent(htmlTree);
         }
@@ -145,7 +146,8 @@
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             htmlTree = HtmlTree.FOOTER();
         }
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Mon Apr 09 09:45:51 2018 -0700
@@ -33,7 +33,8 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
+import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
@@ -68,6 +69,8 @@
      */
     private final boolean classesOnly;
 
+    private final Navigation navBar;
+
     /**
      * Constructor to construct TreeWriter object.
      *
@@ -79,6 +82,7 @@
         super(configuration, filename, classtree);
         packages = configuration.packages;
         classesOnly = packages.isEmpty();
+        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.TREE, path);
     }
 
     /**
@@ -127,7 +131,8 @@
         } else {
             htmlTree = body;
         }
-        addNavLinks(false, htmlTree);
+        navBar.setUserFooter(getUserHeaderFooter(false));
+        htmlTree.addContent(navBar.getContent(false));
         addBottom(htmlTree);
         if (configuration.allowTag(HtmlTag.FOOTER)) {
             body.addContent(htmlTree);
@@ -186,7 +191,8 @@
                 ? HtmlTree.HEADER()
                 : bodyTree;
         addTop(htmlTree);
-        addNavLinks(true, htmlTree);
+        navBar.setUserHeader(getUserHeaderFooter(true));
+        htmlTree.addContent(navBar.getContent(true));
         if (configuration.allowTag(HtmlTag.HEADER)) {
             bodyTree.addContent(htmlTree);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	Mon Apr 09 09:45:51 2018 -0700
@@ -0,0 +1,1089 @@
+/*
+ * 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.
+ */
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter;
+import jdk.javadoc.internal.doclets.formats.html.Contents;
+import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
+import jdk.javadoc.internal.doclets.formats.html.SectionName;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+/**
+ * Factory for navigation bar.
+ *
+ * <p>
+ * <b>This is NOT part of any supported API. If you write code that depends on this, you do so at
+ * your own risk. This code and its internal interfaces are subject to change or deletion without
+ * notice.</b>
+ */
+public class Navigation {
+
+    private final HtmlConfiguration configuration;
+    private final Element element;
+    private final Contents contents;
+    private final DocPath path;
+    private final DocPath pathToRoot;
+    private final Links links;
+    private final HtmlTree fixedNavDiv;
+    private final PageMode documentedPage;
+    private Content navLinkModule;
+    private Content navLinkPackage;
+    private Content navLinkClass;
+    private MemberSummaryBuilder memberSummaryBuilder;
+    private boolean displaySummaryModuleDescLink;
+    private boolean displaySummaryModulesLink;
+    private boolean displaySummaryPackagesLink;
+    private boolean displaySummaryServicesLink;
+    private final Map<Position, Deque<Content>> topBottomNavContents;
+    private Content userHeader;
+    private Content userFooter;
+    private final String rowListTitle;
+    private final Content searchLabel;
+    private static final Script FIXED_NAV_SCRIPT = new Script("<!--\n"
+            + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
+            + "//-->\n");
+
+    public enum PageMode {
+        CLASS,
+        CONSTANTVALUES,
+        DEPRECATED,
+        DOCFILE,
+        HELP,
+        INDEX,
+        MODULE,
+        OVERVIEW,
+        PACKAGE,
+        SERIALIZEDFORM,
+        TREE,
+        USE;
+    }
+
+    enum Position {
+        BOTTOM("allclasses_navbar_bottom", HtmlConstants.START_OF_BOTTOM_NAVBAR, HtmlConstants.END_OF_BOTTOM_NAVBAR),
+        TOP("allclasses_navbar_top", HtmlConstants.START_OF_TOP_NAVBAR, HtmlConstants.END_OF_TOP_NAVBAR);
+
+        final String allClassesLinkId;
+        final Content startOfNav;
+        final Content endOfNav;
+
+        Position(String allClassesLinkId, Content startOfNav, Content endOfNav) {
+            this.allClassesLinkId = allClassesLinkId;
+            this.startOfNav = startOfNav;
+            this.endOfNav = endOfNav;
+        }
+
+        String allClassesLinkId() {
+            return allClassesLinkId;
+        }
+
+        Content startOfNav() {
+            return startOfNav;
+        }
+
+        Content endOfNav() {
+            return endOfNav;
+        }
+
+        Script allClassesLinkScript() {
+            return new Script("<!--\n"
+                    + "  allClassesLink = document.getElementById(")
+                    .appendStringLiteral(allClassesLinkId)
+                    .append(");\n"
+                            + "  if(window==top) {\n"
+                            + "    allClassesLink.style.display = \"block\";\n"
+                            + "  }\n"
+                            + "  else {\n"
+                            + "    allClassesLink.style.display = \"none\";\n"
+                            + "  }\n"
+                            + "  //-->\n");
+        }
+    }
+
+    /**
+     * Creates a {@code Navigation} object for a specific file, to be written in a specific HTML
+     * version.
+     *
+     * @param element element being documented. null if its not an element documentation page
+     * @param configuration the configuration object
+     * @param fixedNavDiv the fixed navigation for the header navigation
+     * @param page the kind of page being documented
+     * @param path the DocPath object
+     */
+    public Navigation(Element element, HtmlConfiguration configuration, HtmlTree fixedNavDiv,
+            PageMode page, DocPath path) {
+        this.configuration = configuration;
+        this.element = element;
+        this.fixedNavDiv = fixedNavDiv;
+        this.contents = configuration.contents;
+        this.documentedPage = page;
+        this.path = path;
+        this.pathToRoot = path.parent().invert();
+        this.links = new Links(path, configuration.htmlVersion);
+        this.topBottomNavContents = new HashMap<>();
+        this.rowListTitle = configuration.getText("doclet.Navigation");
+        this.searchLabel = configuration.getContent("doclet.search");
+        populateNavContents(Position.TOP);
+        populateNavContents(Position.BOTTOM);
+    }
+
+    /**
+     * Populate the navigation contents for top and bottom navigation
+     *
+     * @param position the position of the navigation bar on the page
+     */
+    private void populateNavContents(Position position) {
+        Deque<Content> queue = new ArrayDeque<>();
+        Content skipNavLinks = configuration.getContent("doclet.Skip_navigation_links");
+        switch (position) {
+            case TOP:
+                queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP));
+                queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks,
+                        skipNavLinks.toString(), ""));
+                queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP_FIRSTROW));
+                queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_TOP));
+                topBottomNavContents.put(position, queue);
+                break;
+            case BOTTOM:
+                queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM));
+                queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks,
+                        skipNavLinks.toString(), ""));
+                queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM_FIRSTROW));
+                queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_BOTTOM));
+                topBottomNavContents.put(position, queue);
+                break;
+            default:
+                break;
+        }
+    }
+
+    public Navigation setNavLinkModule(Content navLinkModule) {
+        this.navLinkModule = navLinkModule;
+        return this;
+    }
+
+    public Navigation setNavLinkPackage(Content navLinkPackage) {
+        this.navLinkPackage = navLinkPackage;
+        return this;
+    }
+
+    public Navigation setNavLinkClass(Content navLinkClass) {
+        this.navLinkClass = navLinkClass;
+        return this;
+    }
+
+    public Navigation setMemberSummaryBuilder(MemberSummaryBuilder memberSummaryBuilder) {
+        this.memberSummaryBuilder = memberSummaryBuilder;
+        return this;
+    }
+
+    public Navigation setDisplaySummaryModuleDescLink(boolean displaySummaryModuleDescLink) {
+        this.displaySummaryModuleDescLink = displaySummaryModuleDescLink;
+        return this;
+    }
+
+    public Navigation setDisplaySummaryModulesLink(boolean displaySummaryModulesLink) {
+        this.displaySummaryModulesLink = displaySummaryModulesLink;
+        return this;
+    }
+
+    public Navigation setDisplaySummaryPackagesLink(boolean displaySummaryPackagesLink) {
+        this.displaySummaryPackagesLink = displaySummaryPackagesLink;
+        return this;
+    }
+
+    public Navigation setDisplaySummaryServicesLink(boolean displaySummaryServicesLink) {
+        this.displaySummaryServicesLink = displaySummaryServicesLink;
+        return this;
+    }
+
+    public Navigation setUserHeader(Content userHeader) {
+        this.userHeader = userHeader;
+        return this;
+    }
+
+    public Navigation setUserFooter(Content userFooter) {
+        this.userFooter = userFooter;
+        return this;
+    }
+
+    /**
+     * Add the links for the main navigation.
+     *
+     * @param tree the content tree to which the main navigation will added
+     */
+    private void addMainNavLinks(Content tree) {
+        switch (documentedPage) {
+            case OVERVIEW:
+                addActivePageLink(tree, contents.overviewLabel, configuration.createoverview);
+                addModuleLink(tree);
+                addPackageLink(tree);
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addTreeLink(tree);
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case MODULE:
+                addOverviewLink(tree);
+                addActivePageLink(tree, contents.moduleLabel, configuration.showModules);
+                addPackageLink(tree);
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addTreeLink(tree);
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case PACKAGE:
+                addOverviewLink(tree);
+                addModuleOfElementLink(tree);
+                addActivePageLink(tree, contents.packageLabel, true);
+                addPageLabel(tree, contents.classLabel, true);
+                if (configuration.classuse) {
+                    addContentToTree(tree, links.createLink(DocPaths.PACKAGE_USE,
+                            contents.useLabel, "", ""));
+                }
+                if (configuration.createtree) {
+                    addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
+                            contents.treeLabel, "", ""));
+                }
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case CLASS:
+                addOverviewLink(tree);
+                addModuleOfElementLink(tree);
+                addPackageSummaryLink(tree);
+                addActivePageLink(tree, contents.classLabel, true);
+                if (configuration.classuse) {
+                    addContentToTree(tree, links.createLink(DocPaths.CLASS_USE.resolve(path.basename()),
+                            contents.useLabel));
+                }
+                if (configuration.createtree) {
+                    addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
+                            contents.treeLabel, "", ""));
+                }
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case USE:
+                addOverviewLink(tree);
+                addModuleOfElementLink(tree);
+                if (element instanceof PackageElement) {
+                    addPackageSummaryLink(tree);
+                    addPageLabel(tree, contents.classLabel, true);
+                } else {
+                    addPackageOfElementLink(tree);
+                    addContentToTree(tree, navLinkClass);
+                }
+                addActivePageLink(tree, contents.useLabel, configuration.classuse);
+                if (element instanceof PackageElement) {
+                    addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel));
+                } else {
+                    addContentToTree(tree, configuration.utils.isEnclosingPackageIncluded((TypeElement) element)
+                            ? links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
+                            : links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel));
+                }
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case TREE:
+                addOverviewLink(tree);
+                if (element == null) {
+                    addPageLabel(tree, contents.moduleLabel, configuration.showModules);
+                    addPageLabel(tree, contents.packageLabel, true);
+                } else {
+                    addModuleOfElementLink(tree);
+                    addPackageSummaryLink(tree);
+                }
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addActivePageLink(tree, contents.treeLabel, configuration.createtree);
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case DEPRECATED:
+            case INDEX:
+            case HELP:
+                addOverviewLink(tree);
+                addModuleLink(tree);
+                addPackageLink(tree);
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addTreeLink(tree);
+                if (documentedPage == PageMode.DEPRECATED) {
+                    addActivePageLink(tree, contents.deprecatedLabel, !(configuration.nodeprecated
+                            || configuration.nodeprecatedlist));
+                } else {
+                    addDeprecatedLink(tree);
+                }
+                if (documentedPage == PageMode.INDEX) {
+                    addActivePageLink(tree, contents.indexLabel, configuration.createindex);
+                } else {
+                    addIndexLink(tree);
+                }
+                if (documentedPage == PageMode.HELP) {
+                    addActivePageLink(tree, contents.helpLabel, !configuration.nohelp);
+                } else {
+                    addHelpLink(tree);
+                }
+                break;
+            case CONSTANTVALUES:
+            case SERIALIZEDFORM:
+                addOverviewLink(tree);
+                addModuleLink(tree);
+                addPackageLink(tree);
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addTreeLink(tree);
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            case DOCFILE:
+                addOverviewLink(tree);
+                addModuleOfElementLink(tree);
+                addContentToTree(tree, navLinkPackage);
+                addPageLabel(tree, contents.classLabel, true);
+                addPageLabel(tree, contents.useLabel, configuration.classuse);
+                addTreeLink(tree);
+                addDeprecatedLink(tree);
+                addIndexLink(tree);
+                addHelpLink(tree);
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * Add the summary links to the sub-navigation.
+     *
+     * @param tree the content tree to which the sub-navigation will added
+     */
+    private void addSummaryLinks(Content tree) {
+        List<Content> listContents = new ArrayList<>();
+        switch (documentedPage) {
+            case CLASS:
+                if (element.getKind() == ElementKind.ANNOTATION_TYPE) {
+                    addAnnotationTypeSummaryLink("doclet.navField",
+                            VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, listContents);
+                    addAnnotationTypeSummaryLink("doclet.navAnnotationTypeRequiredMember",
+                            VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, listContents);
+                    addAnnotationTypeSummaryLink("doclet.navAnnotationTypeOptionalMember",
+                            VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, listContents);
+                } else {
+                    TypeElement typeElement = (TypeElement) element;
+                    for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
+                        if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !configuration.utils.isEnum(typeElement)) {
+                            continue;
+                        }
+                        if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && configuration.utils.isEnum(typeElement)) {
+                            continue;
+                        }
+                        AbstractMemberWriter writer
+                                = ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
+                        if (writer == null) {
+                            addContentToList(listContents,
+                                    contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+                        } else {
+                            addTypeSummaryLink(memberSummaryBuilder.members(kind),
+                                    memberSummaryBuilder.getVisibleMemberMap(kind), listContents);
+                        }
+                    }
+                }
+                if (!listContents.isEmpty()) {
+                    Content li = HtmlTree.LI(contents.summaryLabel);
+                    li.addContent(Contents.SPACE);
+                    tree.addContent(li);
+                    addListToNav(listContents, tree);
+                }
+                break;
+            case MODULE:
+                if (displaySummaryModuleDescLink) {
+                    addContentToList(listContents,
+                            links.createLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription));
+                } else {
+                    addContentToList(listContents, contents.navModuleDescription);
+                }
+                if (displaySummaryModulesLink) {
+                    addContentToList(listContents,
+                            links.createLink(SectionName.MODULES, contents.navModules));
+                } else {
+                    addContentToList(listContents, contents.navModules);
+                }
+                if (displaySummaryPackagesLink) {
+                    addContentToList(listContents,
+                            links.createLink(SectionName.PACKAGES, contents.navPackages));
+                } else {
+                    addContentToList(listContents, contents.navPackages);
+                }
+                if (displaySummaryServicesLink) {
+                    addContentToList(listContents,
+                            links.createLink(SectionName.SERVICES, contents.navServices));
+                } else {
+                    addContentToList(listContents, contents.navServices);
+                }
+                if (!listContents.isEmpty()) {
+                    Content li = HtmlTree.LI(contents.moduleSubNavLabel);
+                    li.addContent(Contents.SPACE);
+                    tree.addContent(li);
+                    addListToNav(listContents, tree);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * Add the navigation summary link.
+     *
+     * @param members members to be linked
+     * @param visibleMemberMap the visible inherited members map
+     * @param listContents the list of contents
+     */
+    private void addTypeSummaryLink(SortedSet<? extends Element> members,
+            VisibleMemberMap visibleMemberMap, List<Content> listContents) {
+        if (!members.isEmpty()) {
+            addTypeSummaryLink(null, visibleMemberMap.kind, true, listContents);
+            return;
+        }
+
+        SortedSet<TypeElement> visibleClasses = visibleMemberMap.getVisibleClasses();
+        for (TypeElement t : visibleClasses) {
+            if (!configuration.getVisibleMemberMap(t, visibleMemberMap.kind).getLeafMembers().isEmpty()) {
+                addTypeSummaryLink(null, visibleMemberMap.kind, true, listContents);
+                return;
+            }
+        }
+        addTypeSummaryLink(null, visibleMemberMap.kind, false, listContents);
+    }
+
+    /**
+     * Add the navigation Type summary link.
+     *
+     * @param typeElement the Type being documented
+     * @param kind the kind of member being documented
+     * @param link true if the members are listed and need to be linked
+     * @param listContents the list of contents to which the summary will be added
+     */
+    private void addTypeSummaryLink(TypeElement typeElement, VisibleMemberMap.Kind kind, boolean link,
+            List<Content> listContents) {
+        switch (kind) {
+            case CONSTRUCTORS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.CONSTRUCTOR_SUMMARY,
+                            contents.navConstructor));
+                } else {
+                    addContentToList(listContents, contents.navConstructor);
+                }
+                break;
+            case ENUM_CONSTANTS:
+                if (link) {
+                    if (typeElement == null) {
+                        addContentToList(listContents, links.createLink(SectionName.ENUM_CONSTANT_SUMMARY,
+                                contents.navEnum));
+                    } else {
+                        addContentToList(listContents, links.createLink(
+                                SectionName.ENUM_CONSTANTS_INHERITANCE,
+                                configuration.getClassName(typeElement), contents.navEnum));
+                    }
+                } else {
+                    addContentToList(listContents, contents.navEnum);
+                }
+                break;
+            case FIELDS:
+                if (link) {
+                    if (typeElement == null) {
+                        addContentToList(listContents,
+                                links.createLink(SectionName.FIELD_SUMMARY, contents.navField));
+                    } else {
+                        addContentToList(listContents, links.createLink(SectionName.FIELDS_INHERITANCE,
+                                configuration.getClassName(typeElement), contents.navField));
+                    }
+                } else {
+                    addContentToList(listContents, contents.navField);
+                }
+                break;
+            case METHODS:
+                if (link) {
+                    if (typeElement == null) {
+                        addContentToList(listContents,
+                                links.createLink(SectionName.METHOD_SUMMARY, contents.navMethod));
+                    } else {
+                        addContentToList(listContents, links.createLink(SectionName.METHODS_INHERITANCE,
+                                configuration.getClassName(typeElement), contents.navMethod));
+                    }
+                } else {
+                    addContentToList(listContents, contents.navMethod);
+                }
+                break;
+            case INNER_CLASSES:
+                if (link) {
+                    if (typeElement == null) {
+                        addContentToList(listContents,
+                                links.createLink(SectionName.NESTED_CLASS_SUMMARY, contents.navNested));
+                    } else {
+                        addContentToList(listContents, links.createLink(SectionName.NESTED_CLASSES_INHERITANCE,
+                                configuration.utils.getFullyQualifiedName(typeElement), contents.navNested));
+                    }
+                } else {
+                    addContentToList(listContents, contents.navNested);
+                }
+                break;
+            case PROPERTIES:
+                if (link) {
+                    if (typeElement == null) {
+                        addContentToList(listContents,
+                                links.createLink(SectionName.PROPERTY_SUMMARY, contents.navProperty));
+                    } else {
+                        addContentToList(listContents, links.createLink(SectionName.PROPERTIES_INHERITANCE,
+                                configuration.getClassName(typeElement), contents.navProperty));
+                    }
+                } else {
+                    addContentToList(listContents, contents.navProperty);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * Add the navigation Type summary link.
+     *
+     * @param label the label to be added
+     * @param type the kind of member being documented
+     * @param listContents the list of contents to which the summary will be added
+     */
+    private void addAnnotationTypeSummaryLink(String label, VisibleMemberMap.Kind type, List<Content> listContents) {
+        AbstractMemberWriter writer = ((AbstractMemberWriter) memberSummaryBuilder.
+                getMemberSummaryWriter(type));
+        if (writer == null) {
+            addContentToList(listContents, contents.getContent(label));
+        } else {
+            boolean link = !memberSummaryBuilder.getVisibleMemberMap(type).noVisibleMembers();
+            switch (type) {
+                case ANNOTATION_TYPE_FIELDS:
+                    if (link) {
+                        addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
+                                contents.navField));
+                    } else {
+                        addContentToList(listContents, contents.navField);
+                    }
+                    break;
+                case ANNOTATION_TYPE_MEMBER_REQUIRED:
+                    if (link) {
+                        addContentToList(listContents, links.createLink(
+                                SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
+                                contents.navAnnotationTypeRequiredMember));
+                    } else {
+                        addContentToList(listContents, contents.navAnnotationTypeRequiredMember);
+                    }
+                    break;
+                case ANNOTATION_TYPE_MEMBER_OPTIONAL:
+                    if (link) {
+                        addContentToList(listContents, links.createLink(
+                                SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
+                                contents.navAnnotationTypeOptionalMember));
+                    } else {
+                        addContentToList(listContents, contents.navAnnotationTypeOptionalMember);
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    /**
+     * Add the detail links to sub-navigation.
+     *
+     * @param tree the content tree to which the links will be added
+     */
+    private void addDetailLinks(Content tree) {
+        switch (documentedPage) {
+            case CLASS:
+                List<Content> listContents = new ArrayList<>();
+                if (element.getKind() == ElementKind.ANNOTATION_TYPE) {
+                    addAnnotationTypeDetailLink(listContents);
+                } else {
+                    TypeElement typeElement = (TypeElement) element;
+                    for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
+                        AbstractMemberWriter writer
+                                = ((AbstractMemberWriter) memberSummaryBuilder.
+                                        getMemberSummaryWriter(kind));
+                        if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !configuration.utils.isEnum(typeElement)) {
+                            continue;
+                        }
+                        if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && configuration.utils.isEnum(typeElement)) {
+                            continue;
+                        }
+                        if (writer == null) {
+                            addContentToList(listContents, contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+                        } else {
+                            addTypeDetailLink(kind, !memberSummaryBuilder.members(kind).isEmpty(), listContents);
+                        }
+                    }
+                }
+                if (!listContents.isEmpty()) {
+                    Content li = HtmlTree.LI(contents.detailLabel);
+                    li.addContent(Contents.SPACE);
+                    tree.addContent(li);
+                    addListToNav(listContents, tree);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * Add 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
+     * @param listContents the list of contents to which the detail will be added.
+     */
+    protected void addTypeDetailLink(VisibleMemberMap.Kind kind, boolean link, List<Content> listContents) {
+        switch (kind) {
+            case CONSTRUCTORS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.CONSTRUCTOR_DETAIL, contents.navConstructor));
+                } else {
+                    addContentToList(listContents, contents.navConstructor);
+                }
+                break;
+            case ENUM_CONSTANTS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.ENUM_CONSTANT_DETAIL, contents.navEnum));
+                } else {
+                    addContentToList(listContents, contents.navEnum);
+                }
+                break;
+            case FIELDS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.FIELD_DETAIL, contents.navField));
+                } else {
+                    addContentToList(listContents, contents.navField);
+                }
+                break;
+            case METHODS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.METHOD_DETAIL, contents.navMethod));
+                } else {
+                    addContentToList(listContents, contents.navMethod);
+                }
+                break;
+            case PROPERTIES:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.PROPERTY_DETAIL, contents.navProperty));
+                } else {
+                    addContentToList(listContents, contents.navProperty);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * Add the navigation Annotation Type detail link.
+     *
+     * @param listContents the list of contents to which the annotation detail will be added.
+     */
+    protected void addAnnotationTypeDetailLink(List<Content> listContents) {
+        TypeElement annotationType = (TypeElement) element;
+        AbstractMemberWriter writerField
+                = ((AbstractMemberWriter) memberSummaryBuilder.
+                        getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
+        AbstractMemberWriter writerOptional
+                = ((AbstractMemberWriter) memberSummaryBuilder.
+                        getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
+        AbstractMemberWriter writerRequired
+                = ((AbstractMemberWriter) memberSummaryBuilder.
+                        getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
+        if (writerField != null) {
+            addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS,
+                    !configuration.utils.getAnnotationFields(annotationType).isEmpty(),
+                    listContents);
+        } else {
+            addContentToList(listContents, contents.navField);
+        }
+        if (writerOptional != null) {
+            addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL,
+                    !annotationType.getAnnotationMirrors().isEmpty(), listContents);
+        } else if (writerRequired != null) {
+            addAnnotationTypeDetailLink(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED,
+                    !annotationType.getAnnotationMirrors().isEmpty(), listContents);
+        } else {
+            addContentToList(listContents, contents.navAnnotationTypeMember);
+        }
+    }
+
+    /**
+     * Add 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
+     * @param listContents the list of contents to which the annotation detail will be added.
+     */
+    protected void addAnnotationTypeDetailLink(VisibleMemberMap.Kind type, boolean link, List<Content> listContents) {
+        switch (type) {
+            case ANNOTATION_TYPE_FIELDS:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
+                            contents.navField));
+                } else {
+                    addContentToList(listContents, contents.navField);
+                }
+                break;
+            case ANNOTATION_TYPE_MEMBER_REQUIRED:
+            case ANNOTATION_TYPE_MEMBER_OPTIONAL:
+                if (link) {
+                    addContentToList(listContents, links.createLink(SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
+                            contents.navAnnotationTypeMember));
+                } else {
+                    addContentToList(listContents, contents.navAnnotationTypeMember);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    private void addContentToList(List<Content> listContents, Content tree) {
+        listContents.add(HtmlTree.LI(tree));
+    }
+
+    private void addContentToTree(Content tree, Content content) {
+        tree.addContent(HtmlTree.LI(content));
+    }
+
+    private void addListToNav(List<Content> listContents, Content tree) {
+        int count = 0;
+        for (Content liContent : listContents) {
+            if (count < listContents.size() - 1) {
+                liContent.addContent(Contents.SPACE);
+                liContent.addContent("|");
+                liContent.addContent(Contents.SPACE);
+            }
+            tree.addContent(liContent);
+            count++;
+        }
+    }
+
+    private void addActivePageLink(Content tree, Content label, boolean display) {
+        if (display) {
+            tree.addContent(HtmlTree.LI(HtmlStyle.navBarCell1Rev, label));
+        }
+    }
+
+    private void addPageLabel(Content tree, Content label, boolean display) {
+        if (display) {
+            tree.addContent(HtmlTree.LI(label));
+        }
+    }
+
+    private void addOverviewLink(Content tree) {
+        if (configuration.createoverview) {
+            tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)),
+                    contents.overviewLabel, "", "")));
+        }
+    }
+
+    private void addModuleLink(Content tree) {
+        if (configuration.showModules) {
+            if (configuration.modules.size() == 1) {
+                ModuleElement mdle = configuration.modules.first();
+                boolean included = configuration.utils.isIncluded(mdle);
+                tree.addContent(HtmlTree.LI((included)
+                        ? links.createLink(pathToRoot.resolve(configuration.docPaths.moduleSummary(mdle)), contents.moduleLabel, "", "")
+                        : contents.moduleLabel));
+            } else if (!configuration.modules.isEmpty()) {
+                addPageLabel(tree, contents.moduleLabel, true);
+            }
+        }
+    }
+
+    private void addModuleOfElementLink(Content tree) {
+        if (configuration.showModules) {
+            tree.addContent(HtmlTree.LI(navLinkModule));
+        }
+    }
+
+    private void addPackageLink(Content tree) {
+        if (configuration.packages.size() == 1) {
+            PackageElement packageElement = configuration.packages.first();
+            boolean included = packageElement != null && configuration.utils.isIncluded(packageElement);
+            if (!included) {
+                for (PackageElement p : configuration.packages) {
+                    if (p.equals(packageElement)) {
+                        included = true;
+                        break;
+                    }
+                }
+            }
+            if (included || packageElement == null) {
+                tree.addContent(HtmlTree.LI(links.createLink(
+                        pathToRoot.resolve(configuration.docPaths.forPackage(packageElement).resolve(DocPaths.PACKAGE_SUMMARY)),
+                        contents.packageLabel)));
+            } else {
+                DocLink crossPkgLink = configuration.extern.getExternalLink(
+                        configuration.utils.getPackageName(packageElement), pathToRoot,
+                        DocPaths.PACKAGE_SUMMARY.getPath());
+                if (crossPkgLink != null) {
+                    tree.addContent(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel)));
+                } else {
+                    tree.addContent(HtmlTree.LI(contents.packageLabel));
+                }
+            }
+        } else if (!configuration.packages.isEmpty()) {
+            addPageLabel(tree, contents.packageLabel, true);
+        }
+    }
+
+    private void addPackageOfElementLink(Content tree) {
+        tree.addContent(HtmlTree.LI(links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY),
+                contents.packageLabel)));
+    }
+
+    private void addPackageSummaryLink(Content tree) {
+        tree.addContent(HtmlTree.LI(links.createLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel)));
+    }
+
+    private void addTreeLink(Content tree) {
+        if (configuration.createtree) {
+            List<PackageElement> packages = new ArrayList<>(configuration.getSpecifiedPackageElements());
+            DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty()
+                    ? pathToRoot.resolve(configuration.docPaths.forPackage(packages.get(0)).resolve(DocPaths.PACKAGE_TREE))
+                    : pathToRoot.resolve(DocPaths.OVERVIEW_TREE);
+            tree.addContent(HtmlTree.LI(links.createLink(docPath, contents.treeLabel, "", "")));
+        }
+    }
+
+    private void addDeprecatedLink(Content tree) {
+        if (!(configuration.nodeprecated || configuration.nodeprecatedlist)) {
+            tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
+                    contents.deprecatedLabel, "", "")));
+        }
+    }
+
+    private void addIndexLink(Content tree) {
+        if (configuration.createindex) {
+            tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(
+                    (configuration.splitindex
+                            ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
+                            : DocPaths.INDEX_ALL)),
+                    contents.indexLabel, "", "")));
+        }
+    }
+
+    private void addHelpLink(Content tree) {
+        if (!configuration.nohelp) {
+            String helpfile = configuration.helpfile;
+            DocPath helpfilenm;
+            if (helpfile.isEmpty()) {
+                helpfilenm = DocPaths.HELP_DOC;
+            } else {
+                DocFile file = DocFile.createFileForInput(configuration, helpfile);
+                helpfilenm = DocPath.create(file.getName());
+            }
+            tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(helpfilenm),
+                    contents.helpLabel, "", "")));
+        }
+    }
+
+    /**
+     * Add "FRAMES" link, to switch to the frame version of the output.
+     *
+     * @param tree the content tree to which the link will be added
+     */
+    private void addNavShowLists(Content tree) {
+        DocLink dl = new DocLink(pathToRoot.resolve(DocPaths.INDEX), path.getPath(), null);
+        Content framesContent = links.createLink(dl, contents.framesLabel, "", "_top");
+        tree.addContent(HtmlTree.LI(framesContent));
+    }
+
+    /**
+     * Add "NO FRAMES" link, to switch to the non-frame version of the output.
+     *
+     * @param tree the content tree to which the link will be added
+     */
+    private void addNavHideLists(Content tree) {
+        Content noFramesContent = links.createLink(path.basename(), contents.noFramesLabel, "", "_top");
+        tree.addContent(HtmlTree.LI(noFramesContent));
+    }
+
+    private void addNavLinkClassIndex(Content tree) {
+        Content allClassesContent = links.createLink(pathToRoot.resolve(
+                DocPaths.AllClasses(configuration.frames)),
+                contents.allClassesLabel, "", "");
+        tree.addContent(HtmlTree.LI(allClassesContent));
+    }
+
+    private void addSearch(Content tree) {
+        String searchValueId = "search";
+        String reset = "reset";
+        HtmlTree inputText = HtmlTree.INPUT("text", searchValueId, searchValueId);
+        HtmlTree inputReset = HtmlTree.INPUT(reset, reset, reset);
+        HtmlTree liInput = HtmlTree.LI(HtmlTree.LABEL(searchValueId, searchLabel));
+        liInput.addContent(inputText);
+        liInput.addContent(inputReset);
+        HtmlTree ulSearch = HtmlTree.UL(HtmlStyle.navListSearch, liInput);
+        tree.addContent(ulSearch);
+    }
+
+    private void addAllClassesLinkScript(Content tree, boolean top) {
+        Content div = HtmlTree.DIV(top
+                ? Position.TOP.allClassesLinkScript().asContent()
+                : Position.BOTTOM.allClassesLinkScript().asContent());
+        Content div_noscript = HtmlTree.DIV(contents.noScriptMessage);
+        Content noScript = HtmlTree.NOSCRIPT(div_noscript);
+        div.addContent(noScript);
+        tree.addContent(div);
+    }
+
+    private void addFixedNavScript(Content tree) {
+        tree.addContent(FIXED_NAV_SCRIPT.asContent());
+    }
+
+    /**
+     * Get the navigation content.
+     *
+     * @param top true if the top navigation bar is to be printed
+     * @return the navigation contents
+     */
+    public Content getContent(boolean top) {
+        Content contentTree = new ContentBuilder();
+        if (!configuration.nonavbar) {
+            Deque<Content> queue;
+            Content tree = (configuration.htmlVersion == HtmlVersion.HTML5)
+                    ? HtmlTree.NAV()
+                    : contentTree;
+            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
+            if (top) {
+                queue = topBottomNavContents.get(Position.TOP);
+                fixedNavDiv.addContent(Position.TOP.startOfNav());
+                navDiv.setStyle(HtmlStyle.topNav);
+            } else {
+                queue = topBottomNavContents.get(Position.BOTTOM);
+                tree.addContent(Position.BOTTOM.startOfNav());
+                navDiv.setStyle(HtmlStyle.bottomNav);
+            }
+            navDiv.addContent(queue.poll());
+            HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll());
+            navDiv.addContent(skipLinkDiv);
+            navDiv.addContent(queue.poll());
+            HtmlTree navList = new HtmlTree(HtmlTag.UL);
+            navList.setStyle(HtmlStyle.navList);
+            navList.addAttr(HtmlAttr.TITLE, rowListTitle);
+            fixedNavDiv.setStyle(HtmlStyle.fixedNav);
+            addMainNavLinks(navList);
+            navDiv.addContent(navList);
+            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, top ? userHeader : userFooter);
+            navDiv.addContent(aboutDiv);
+            if (top) {
+                fixedNavDiv.addContent(navDiv);
+            } else {
+                tree.addContent(navDiv);
+            }
+            HtmlTree subDiv = new HtmlTree(HtmlTag.DIV);
+            subDiv.setStyle(HtmlStyle.subNav);
+            HtmlTree ulFrames = new HtmlTree(HtmlTag.UL);
+            ulFrames.setStyle(HtmlStyle.navList);
+            if (!configuration.nonavbar) {
+                if (configuration.frames) {
+                    addNavShowLists(ulFrames);
+                    addNavHideLists(ulFrames);
+                }
+            }
+            subDiv.addContent(ulFrames);
+            HtmlTree ulAllClasses = new HtmlTree(HtmlTag.UL);
+            ulAllClasses.setStyle(HtmlStyle.navList);
+            ulAllClasses.addAttr(HtmlAttr.ID, top
+                    ? Position.TOP.allClassesLinkId()
+                    : Position.BOTTOM.allClassesLinkId());
+            addNavLinkClassIndex(ulAllClasses);
+            subDiv.addContent(ulAllClasses);
+            if (top && configuration.createindex) {
+                addSearch(subDiv);
+            }
+            addAllClassesLinkScript(subDiv, top);
+            HtmlTree div = new HtmlTree(HtmlTag.DIV);
+            // Add the summary links if present.
+            HtmlTree ulNavSummary = new HtmlTree(HtmlTag.UL);
+            ulNavSummary.setStyle(HtmlStyle.subNavList);
+            addSummaryLinks(ulNavSummary);
+            div.addContent(ulNavSummary);
+            // Add the detail links if present.
+            HtmlTree ulNavDetail = new HtmlTree(HtmlTag.UL);
+            ulNavDetail.setStyle(HtmlStyle.subNavList);
+            addDetailLinks(ulNavDetail);
+            div.addContent(ulNavDetail);
+            subDiv.addContent(div);
+            subDiv.addContent(queue.poll());
+            if (top) {
+                fixedNavDiv.addContent(subDiv);
+                fixedNavDiv.addContent(Position.TOP.endOfNav());
+                tree.addContent(fixedNavDiv);
+                HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE);
+                tree.addContent(paddingDiv);
+                addFixedNavScript(tree);
+            } else {
+                tree.addContent(subDiv);
+                tree.addContent(Position.BOTTOM.endOfNav());
+            }
+            return tree;
+        }
+        return contentTree;
+    }
+}
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java	Mon Apr 09 09:45:51 2018 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8185151
+ * @bug 8185151 8196200
  * @summary test that navigation summary links are not linked when there are no dependencies
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -69,10 +69,10 @@
         checkExit(Exit.OK);
 
         checkOutput("m/module-summary.html", true,
-                "<a href=\"#module.description\">Description</a>&nbsp;|"
-                + "&nbsp;Modules&nbsp;|"
-                + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
-                + "&nbsp;<a href=\"#services.summary\">Services</a>");
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Modules&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#services.summary\">Services</a></li>");
 
     }
 
@@ -93,10 +93,10 @@
         checkExit(Exit.OK);
 
         checkOutput("m/module-summary.html", true,
-                "<a href=\"#module.description\">Description</a>&nbsp;|"
-                + "&nbsp;Modules&nbsp;|"
-                + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
-                + "&nbsp;<a href=\"#services.summary\">Services</a>");
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Modules&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#services.summary\">Services</a></li>");
 
     }
 
@@ -115,9 +115,10 @@
         checkExit(Exit.OK);
 
         checkOutput("m/module-summary.html", true,
-                "Description&nbsp;|&nbsp;Modules&nbsp;|"
-                + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
-                + "&nbsp;Services");
+                "<li>Description&nbsp;|&nbsp;</li>\n"
+                + "<li>Modules&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Services</li>");
     }
 
 }
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Mon Apr 09 09:45:51 2018 -0700
@@ -26,7 +26,7 @@
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
  *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
  *      8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464
-        8164407 8192007 8182765
+        8164407 8192007 8182765 8196200
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -940,9 +940,10 @@
         checkOutput("moduleA/module-summary.html", true,
                 "<ul class=\"subNavList\">\n"
                 + "<li>Module:&nbsp;</li>\n"
-                + "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a "
-                + "href=\"#modules.summary\">Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">"
-                + "Packages</a>&nbsp;|&nbsp;Services</li>\n"
+                + "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#modules.summary\">Modules</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Services</li>\n"
                 + "</ul>",
                 "<!-- ============ MODULES SUMMARY =========== -->\n"
                 + "<a id=\"modules.summary\">\n"
@@ -964,9 +965,10 @@
                 + "</td>\n"
                 + "</tr>");
         checkOutput("moduleB/module-summary.html", true,
-                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;Modules&nbsp;|&nbsp;"
-                + "<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">"
-                + "Services</a></li>",
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Modules&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#services.summary\">Services</a></li>",
                 "<!-- ============ PACKAGES SUMMARY =========== -->\n"
                 + "<a id=\"packages.summary\">\n"
                 + "<!--   -->\n"
@@ -1180,8 +1182,10 @@
                 + " Package Link: <a href=\"moduletags/testpkgmdltags/package-summary.html\"><code>testpkgmdltags</code></a>.<br></div>\n"
                 + "</td>");
         checkOutput("moduleA/module-summary.html", true,
-                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
-                + "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#modules.summary\">Modules</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Services</li>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleB/module-summary.html\">moduleB</a></th>\n"
                 + "<td class=\"colLast\"><a href=\"../moduleB/testpkgmdlB/package-summary.html\">testpkgmdlB</a></td>\n");
         checkOutput("moduleB/module-summary.html", true,
@@ -1189,8 +1193,10 @@
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">With a test description for uses.</div>\n</td>\n");
         checkOutput("moduletags/module-summary.html", true,
-                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">Modules"
-                + "</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#modules.summary\">Modules</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Services</li>",
                 "<table class=\"requiresSummary\">\n"
                 + "<caption><span>Indirect Requires</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<td class=\"colFirst\">transitive</td>\n"
@@ -1267,8 +1273,10 @@
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlA/package-summary.html\">testpkgmdlA</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
         checkOutput("moduleB/module-summary.html", found,
-                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;Modules&nbsp;|&nbsp;"
-                + "<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">Services</a></li>",
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li>Modules&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#services.summary\">Services</a></li>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>",
                 "<table class=\"packagesSummary\">\n"
@@ -1329,8 +1337,10 @@
                 + "<td class=\"colSecond\">None</td>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
         checkOutput("moduleB/module-summary.html", found,
-                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
-                + "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">Services</a></li>",
+                "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#modules.summary\">Modules</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;</li>\n"
+                + "<li><a href=\"#services.summary\">Services</a></li>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
                 + "<td class=\"colSecond\">None</td>\n"
                 + "<td class=\"colSecond\">All Modules</td>\n"
--- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Mon Apr 09 04:43:03 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Mon Apr 09 09:45:51 2018 -0700
@@ -24,24 +24,36 @@
 /*
  * @test
  * @bug      4131628 4664607 7025314 8023700 7198273 8025633 8026567 8081854 8150188 8151743 8196027 8182765
+ *           8196200
  * @summary  Make sure the Next/Prev Class links iterate through all types.
  *           Make sure the navagation is 2 columns, not 3.
  * @author   jamieh
- * @library  ../lib
+ * @library  /tools/lib ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
- * @build    JavadocTester
+ * @build    toolbox.ToolBox JavadocTester
  * @run main TestNavigation
  */
 
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.*;
+
 public class TestNavigation extends JavadocTester {
 
+    public final ToolBox tb;
     public static void main(String... args) throws Exception {
         TestNavigation tester = new TestNavigation();
-        tester.runTests();
+        tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
+    }
+
+    public TestNavigation() {
+        tb = new ToolBox();
     }
 
     @Test
-    void test() {
+    void test(Path ignore) {
         javadoc("-d", "out",
                 "-overview", testSrc("overview.html"),
                 "-sourcepath", testSrc,
@@ -96,7 +108,7 @@
     }
 
     @Test
-    void test_html4() {
+    void test_html4(Path ignore) {
         javadoc("-d", "out-html4",
                 "-html4",
                 "-overview", testSrc("overview.html"),
@@ -135,7 +147,7 @@
 
     // Test for checking additional padding to offset the fixed navigation bar in HTML5.
     @Test
-    void test1() {
+    void test1(Path ignore) {
         javadoc("-d", "out-1",
                 "-html5",
                 "-sourcepath", testSrc,
@@ -167,7 +179,7 @@
 
     // Test to make sure that no extra padding for nav bar gets generated if -nonavbar is specified for HTML4.
     @Test
-    void test2() {
+    void test2(Path ignore) {
         javadoc("-d", "out-2",
                 "-nonavbar",
                 "-sourcepath", testSrc,
@@ -197,7 +209,7 @@
 
     // Test to make sure that no extra padding for nav bar gets generated if -nonavbar is specified for HTML5.
     @Test
-    void test3() {
+    void test3(Path ignore) {
         javadoc("-d", "out-3",
                 "-html5",
                 "-nonavbar",
@@ -227,4 +239,89 @@
                 + "</script>\n"
                 + "</nav>");
     }
+
+    @Test
+    void test4(Path base) throws IOException {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "package pkg1; public class A {\n"
+                + "    /**\n"
+                + "     * Class with members.\n"
+                + "     */\n"
+                + "    public static class X {\n"
+                + "        /**\n"
+                + "         * A ctor\n"
+                + "         */\n"
+                + "        public X() {\n"
+                + "        }\n"
+                + "        /**\n"
+                + "         * A field\n"
+                + "         */\n"
+                + "        public int field;\n"
+                + "        /**\n"
+                + "         * A method\n"
+                + "         */\n"
+                + "        public void method() {\n"
+                + "        }\n"
+                + "        /**\n"
+                + "         * An inner class\n"
+                + "         */\n"
+                + "        public static class IC {\n"
+                + "        }\n"
+                + "    }\n"
+                + "    /**\n"
+                + "     * Class with all inherited members.\n"
+                + "     */\n"
+                + "    public static class Y extends X {\n"
+                + "    }\n"
+                + "}");
+
+        tb.writeJavaFiles(src,
+                "package pkg1; public class C {\n"
+                + "}");
+
+        tb.writeJavaFiles(src,
+                "package pkg1; public interface InterfaceWithNoMembers {\n"
+                + "}");
+
+        javadoc("-d", "out-4",
+                "-sourcepath", src.toString(),
+                "pkg1");
+        checkExit(Exit.OK);
+
+        checkOrder("pkg1/A.X.html",
+                "Summary",
+                "<li><a href=\"#nested.class.summary\">Nested</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#field.summary\">Field</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#constructor.summary\">Constr</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#method.summary\">Method</a></li>");
+
+        checkOrder("pkg1/A.Y.html",
+                "Summary",
+                "<li><a href=\"#nested.class.summary\">Nested</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#field.summary\">Field</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#constructor.summary\">Constr</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#method.summary\">Method</a></li>");
+
+        checkOrder("pkg1/A.X.IC.html",
+                "Summary",
+                "<li>Nested&nbsp;|&nbsp;</li>",
+                "<li>Field&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#constructor.summary\">Constr</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#method.summary\">Method</a></li>");
+
+        checkOrder("pkg1/C.html",
+                "Summary",
+                "<li>Nested&nbsp;|&nbsp;</li>",
+                "<li>Field&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#constructor.summary\">Constr</a>&nbsp;|&nbsp;</li>",
+                "<li><a href=\"#method.summary\">Method</a></li>");
+
+        checkOrder("pkg1/InterfaceWithNoMembers.html",
+                "Summary",
+                "<li>Nested&nbsp;|&nbsp;</li>",
+                "<li>Field&nbsp;|&nbsp;</li>",
+                "<li>Constr&nbsp;|&nbsp;</li>",
+                "<li>Method</li>");
+    }
 }