8223378: CSS solution for navbar problem with <a> elements is not ideal
authorhannesw
Wed, 27 Nov 2019 13:08:16 +0100
changeset 59294 48b88b9c11eb
parent 59293 5af9fa90cd7b
child 59295 8b6cc0bb93d0
8223378: CSS solution for navbar problem with <a> elements is not ideal Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.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/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/HelpWriter.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/ModuleWriterImpl.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/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/SubWriterHolderWriter.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/BodyContents.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css
test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java
test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java
test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java
test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java
test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java
test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js
test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java
test/langtools/jdk/javadoc/doclet/testTopOption/TestTopOption.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -92,7 +92,7 @@
                                   IndexBuilder indexbuilder) {
         super(configuration, path);
         this.indexbuilder = indexbuilder;
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.INDEX, path);
+        this.navBar = new Navigation(null, configuration, PageMode.INDEX, path);
     }
 
     /**
@@ -419,7 +419,7 @@
      * @return a content tree for the marker anchor
      */
     public Content getMarkerAnchorForIndex(String anchorNameForIndex) {
-        return links.createAnchor(getNameForIndex(anchorNameForIndex), null);
+        return links.createAnchor(getNameForIndex(anchorNameForIndex));
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -25,6 +25,8 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -57,12 +59,12 @@
     public AbstractOverviewIndexWriter(HtmlConfiguration configuration,
                                       DocPath filename) {
         super(configuration, filename);
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.OVERVIEW, path);
+        this.navBar = new Navigation(null, configuration, PageMode.OVERVIEW, path);
     }
 
     /**
      * Adds the top text (from the -top option), the upper
-     * navigation bar, and then the title (from the"-title"
+     * navigation bar, and then the title (from the"-header"
      * option), at the top of page.
      *
      * @param header the documentation tree to which the navigation bar header will be added
@@ -126,16 +128,18 @@
             throws DocFileIOException {
         String windowOverview = resources.getText(title);
         Content body = getBody(getWindowTitle(windowOverview));
-        Content header = HtmlTree.HEADER();
+        Content header = new ContentBuilder();
         addNavigationBarHeader(header);
-        Content main = HtmlTree.MAIN();
+        Content main = new ContentBuilder();
         addOverviewHeader(main);
         addIndex(main);
         Content footer = HtmlTree.FOOTER();
         addNavigationBarFooter(footer);
-        body.add(header);
-        body.add(main);
-        body.add(footer);
+        body.add(new BodyContents()
+                .setHeader(header)
+                .addMainContent(main)
+                .setFooter(footer)
+                .toContent());
         printHtmlDocument(
                 configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle),
                 description, body);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -31,6 +31,7 @@
 import javax.lang.model.element.TypeElement;
 
 import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -56,13 +57,6 @@
     protected IndexBuilder indexbuilder;
 
     /**
-     * The HTML tree for main tag.
-     */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
-
-    private final Navigation navBar;
-
-    /**
      * Construct AllClassesIndexWriter object. Also initializes the indexbuilder variable in this
      * class.
      *
@@ -74,7 +68,6 @@
             DocPath filename, IndexBuilder indexbuilder) {
         super(configuration, filename);
         this.indexbuilder = indexbuilder;
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.ALLCLASSES, path);
     }
 
     /**
@@ -101,21 +94,25 @@
      */
     protected void buildAllClassesFile() throws DocFileIOException {
         String label = resources.getText("doclet.All_Classes");
-        HtmlTree bodyTree = getBody(getWindowTitle(label));
-        HtmlTree header = HtmlTree.HEADER();
+        Content header = new ContentBuilder();
         addTop(header);
+        Navigation navBar = new Navigation(null, configuration, PageMode.ALLCLASSES, path);
         navBar.setUserHeader(getUserHeaderFooter(true));
         header.add(navBar.getContent(true));
-        bodyTree.add(header);
         Content allClassesContent = new ContentBuilder();
         addContents(allClassesContent);
-        mainTree.add(allClassesContent);
-        bodyTree.add(mainTree);
+        Content mainContent = new ContentBuilder();
+        mainContent.add(allClassesContent);
         Content footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        bodyTree.add(footer);
+        HtmlTree bodyTree = getBody(getWindowTitle(label));
+        bodyTree.add(new BodyContents()
+                .setHeader(header)
+                .addMainContent(mainContent)
+                .setFooter(footer)
+                .toContent());
         printHtmlDocument(null, "class index", bodyTree);
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -26,6 +26,7 @@
 
 import javax.lang.model.element.PackageElement;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -46,13 +47,6 @@
 public class AllPackagesIndexWriter extends HtmlDocletWriter {
 
     /**
-     * The HTML tree for main tag.
-     */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
-
-    private final Navigation navBar;
-
-    /**
      * Construct AllPackagesIndexWriter object.
      *
      * @param configuration The current configuration
@@ -60,7 +54,6 @@
      */
     public AllPackagesIndexWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.ALLPACKAGES, path);
     }
 
     /**
@@ -83,12 +76,11 @@
      */
     protected void buildAllPackagesFile() throws DocFileIOException {
         String label = resources.getText("doclet.All_Packages");
-        HtmlTree bodyTree = getBody(getWindowTitle(label));
-        HtmlTree header = HtmlTree.HEADER();
-        addTop(header);
+        Content headerContent = new ContentBuilder();
+        Navigation navBar = new Navigation(null, configuration, PageMode.ALLPACKAGES, path);
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        header.add(navBar.getContent(true));
-        bodyTree.add(header);
+        headerContent.add(navBar.getContent(true));
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.allPackagesContainer);
         addPackages(div);
@@ -96,14 +88,17 @@
         Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
                 HtmlStyle.title, titleContent);
         Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
-        mainTree.add(headerDiv);
-        mainTree.add(div);
-        bodyTree.add(mainTree);
         Content footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        bodyTree.add(footer);
+        HtmlTree bodyTree = getBody(getWindowTitle(label));
+        bodyTree.add(new BodyContents()
+                .setHeader(headerContent)
+                .addMainContent(headerDiv)
+                .addMainContent(div)
+                .setFooter(footer)
+                .toContent());
         printHtmlDocument(null, "package index", bodyTree);
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -32,6 +32,7 @@
 import javax.lang.model.element.TypeElement;
 
 import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -78,7 +79,7 @@
         super(configuration, configuration.docPaths.forClass(annotationType));
         this.annotationType = annotationType;
         configuration.currentTypeElement = annotationType;
-        this.navBar = new Navigation(annotationType, configuration, fixedNavDiv, PageMode.CLASS, path);
+        this.navBar = new Navigation(annotationType, configuration, PageMode.CLASS, path);
     }
 
     /**
@@ -86,17 +87,15 @@
      */
     @Override
     public Content getHeader(String header) {
-        HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(annotationType)));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
                 contents.moduleLabel);
         navBar.setNavLinkModule(linkContent);
         navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
-        bodyTree.add(MarkerComments.START_OF_CLASS_DATA);
+        headerContent.add(navBar.getContent(true));
+
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.header);
         if (configuration.showModules) {
@@ -118,13 +117,14 @@
         }
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                 LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
-        Content headerContent = new StringContent(header);
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                HtmlStyle.title, headerContent);
+                HtmlStyle.title, new StringContent(header));
         heading.add(getTypeParameterLinks(linkInfo));
         div.add(heading);
-        mainTree.add(div);
-        return bodyTree;
+        bodyContents.setHeader(headerContent)
+                .addMainContent(MarkerComments.START_OF_CLASS_DATA)
+                .addMainContent(div);
+        return getBody(getWindowTitle(utils.getSimpleName(annotationType)));
     }
 
     /**
@@ -139,13 +139,13 @@
      * {@inheritDoc}
      */
     @Override
-    public void addFooter(Content contentTree) {
-        contentTree.add(MarkerComments.END_OF_CLASS_DATA);
+    public void addFooter() {
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        contentTree.add(htmlTree);
+        bodyContents.addMainContent(MarkerComments.END_OF_CLASS_DATA)
+                    .setFooter(htmlTree);
     }
 
     /**
@@ -156,6 +156,7 @@
         String description = getDescription("declaration", annotationType);
         PackageElement pkg = utils.containingPackage(this.annotationType);
         List<DocPath> localStylesheets = getLocalStylesheets(pkg);
+        contentTree.add(bodyContents.toContent());
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
                 description, localStylesheets, contentTree);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -100,11 +100,6 @@
     private final Navigation navBar;
 
     /**
-     * The HTML tree for main tag.
-     */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
-
-    /**
      * Constructor.
      *
      * @param filename the file to be generated.
@@ -154,7 +149,7 @@
         constrSubWriter = new ConstructorWriterImpl(this);
         fieldSubWriter = new FieldWriterImpl(this);
         classSubWriter = new NestedClassWriterImpl(this);
-        this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.USE, path);
+        this.navBar = new Navigation(typeElement, configuration, PageMode.USE, path);
     }
 
     /**
@@ -232,13 +227,13 @@
             div.add(contents.getContent("doclet.ClassUse_No.usage.of.0",
                     utils.getFullyQualifiedName(typeElement)));
         }
-        mainTree.add(div);
-        body.add(mainTree);
+        bodyContents.addMainContent(div);
         HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        body.add(footer);
+        bodyContents.setFooter(footer);
+        body.add(bodyContents.toContent());
         String description = getDescription("use", typeElement);
         printHtmlDocument(null, description, body);
     }
@@ -432,8 +427,8 @@
         String title = resources.getText("doclet.Window_ClassUse_Header",
                 cltype, clname);
         HtmlTree bodyTree = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
                 contents.moduleLabel);
         navBar.setNavLinkModule(mdleLinkContent);
@@ -442,16 +437,15 @@
                 .label(resources.getText("doclet.Class")));
         navBar.setNavLinkClass(classLinkContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
-        ContentBuilder headContent = new ContentBuilder();
-        headContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
-        headContent.add(new HtmlTree(HtmlTag.BR));
-        headContent.add(clname);
+        headerContent.add(navBar.getContent(true));
+        ContentBuilder headingContent = new ContentBuilder();
+        headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
+        headingContent.add(new HtmlTree(HtmlTag.BR));
+        headingContent.add(clname);
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
-                true, HtmlStyle.title, headContent);
+                true, HtmlStyle.title, headingContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent).addMainContent(div);
         return bodyTree;
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -105,7 +105,7 @@
         this.typeElement = typeElement;
         configuration.currentTypeElement = typeElement;
         this.classtree = classTree;
-        this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.CLASS, path);
+        this.navBar = new Navigation(typeElement, configuration, PageMode.CLASS, path);
     }
 
     /**
@@ -114,16 +114,14 @@
     @Override
     public Content getHeader(String header) {
         HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(typeElement)));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
                 contents.moduleLabel);
         navBar.setNavLinkModule(linkContent);
         navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
-        bodyTree.add(MarkerComments.START_OF_CLASS_DATA);
+        headerContent.add(navBar.getContent(true));
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.header);
         if (configuration.showModules) {
@@ -149,12 +147,13 @@
                 LinkInfoImpl.Kind.CLASS_HEADER, typeElement);
         //Let's not link to ourselves in the header.
         linkInfo.linkToSelf = false;
-        Content headerContent = new StringContent(header);
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                HtmlStyle.title, headerContent);
+                HtmlStyle.title, new StringContent(header));
         heading.add(getTypeParameterLinks(linkInfo));
         div.add(heading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent)
+                .addMainContent(MarkerComments.START_OF_CLASS_DATA)
+                .addMainContent(div);
         return bodyTree;
     }
 
@@ -170,13 +169,13 @@
      * {@inheritDoc}
      */
     @Override
-    public void addFooter(Content contentTree) {
-        contentTree.add(MarkerComments.END_OF_CLASS_DATA);
+    public void addFooter() {
+        bodyContents.addMainContent(MarkerComments.END_OF_CLASS_DATA);
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        contentTree.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
     }
 
     /**
@@ -187,6 +186,7 @@
         String description = getDescription("declaration", typeElement);
         PackageElement pkg = utils.containingPackage(typeElement);
         List<DocPath> localStylesheets = getLocalStylesheets(pkg);
+        contentTree.add(bodyContents.toContent());
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement),
                 description, localStylesheets, contentTree);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -33,6 +33,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
@@ -76,17 +77,14 @@
     private final TableHeader constantsTableHeader;
 
     /**
-     * The HTML tree for main tag.
-     */
-    private final HtmlTree mainTree = HtmlTree.MAIN();
-
-    /**
      * The HTML tree for constant values summary.
      */
     private HtmlTree summaryTree;
 
     private final Navigation navBar;
 
+    private final BodyContents bodyContents = new BodyContents();
+
     /**
      * Construct a ConstantsSummaryWriter.
      * @param configuration the configuration used in this run
@@ -97,7 +95,7 @@
         this.configuration = configuration;
         constantsTableHeader = new TableHeader(
                 contents.modifierAndTypeLabel, contents.constantFieldLabel, contents.valueLabel);
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.CONSTANTVALUES, path);
+        this.navBar = new Navigation(null, configuration, PageMode.CONSTANTVALUES, path);
     }
 
     /**
@@ -107,11 +105,11 @@
     public Content getHeader() {
         String label = resources.getText("doclet.Constants_Summary");
         HtmlTree bodyTree = getBody(getWindowTitle(label));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
+        bodyContents.setHeader(headerContent);
         return bodyTree;
     }
 
@@ -150,7 +148,7 @@
      * {@inheritDoc}
      */
     @Override
-    public void addContentsList(Content contentTree, Content contentListTree) {
+    public void addContentsList(Content contentListTree) {
         Content titleContent = contents.constantsSummaryTitle;
         Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
                 HtmlStyle.title, titleContent);
@@ -161,7 +159,7 @@
         HtmlTree section = HtmlTree.SECTION(HtmlStyle.packages, heading);
         section.add(contentListTree);
         div.add(section);
-        mainTree.add(div);
+        bodyContents.addMainContent(div);
     }
 
     /**
@@ -303,24 +301,23 @@
      * {@inheritDoc}
      */
     @Override
-    public void addConstantSummaries(Content contentTree, Content summariesTree) {
+    public void addConstantSummaries(Content summariesTree) {
         if (summaryTree != null) {
             summariesTree.add(summaryTree);
         }
-        mainTree.add(summariesTree);
-        contentTree.add(mainTree);
+        bodyContents.addMainContent(summariesTree);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void addFooter(Content contentTree) {
+    public void addFooter() {
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        contentTree.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
     }
 
     /**
@@ -328,6 +325,7 @@
      */
     @Override
     public void printDocument(Content contentTree) throws DocFileIOException {
+        contentTree.add(bodyContents.toContent());
         printHtmlDocument(null, "summary of constants", contentTree);
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -222,7 +222,7 @@
     public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         this.configuration = configuration;
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.DEPRECATED, path);
+        this.navBar = new Navigation(null, configuration, PageMode.DEPRECATED, path);
         NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
         writerMap = new EnumMap<>(DeprElementKind.class);
         for (DeprElementKind kind : DeprElementKind.values()) {
@@ -283,8 +283,7 @@
     protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
             throws DocFileIOException {
         HtmlTree body = getHeader();
-        HtmlTree htmlTree = HtmlTree.MAIN();
-        htmlTree.add(getContentsList(deprapi));
+        bodyContents.addMainContent(getContentsList(deprapi));
         String memberTableSummary;
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.contentContainer);
@@ -300,14 +299,14 @@
                             getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
             }
         }
-        htmlTree.add(div);
-        body.add(htmlTree);
-        htmlTree = HtmlTree.FOOTER();
+        bodyContents.addMainContent(div);
+        HtmlTree htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        body.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
         String description = "deprecated elements";
+        body.add(bodyContents.toContent());
         printHtmlDocument(null, description, body);
     }
 
@@ -315,7 +314,7 @@
      * Add the index link.
      *
      * @param builder the deprecated list builder
-     * @param type the type of list being documented
+     * @param kind the kind of list being documented
      * @param contentTree the content tree to which the index link will be added
      */
     private void addIndexLink(DeprecatedAPIListBuilder builder,
@@ -353,7 +352,7 @@
      * Add the anchor.
      *
      * @param builder the deprecated list builder
-     * @param type the type of list being documented
+     * @param kind the kind of list being documented
      * @param htmlTree the content tree to which the anchor will be added
      */
     private void addAnchor(DeprecatedAPIListBuilder builder, DeprElementKind kind, Content htmlTree) {
@@ -370,11 +369,11 @@
     public HtmlTree getHeader() {
         String title = resources.getText("doclet.Window_Deprecated_List");
         HtmlTree bodyTree = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
+        bodyContents.setHeader(headerContent);
         return bodyTree;
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -31,6 +31,9 @@
 import com.sun.source.doctree.TextTree;
 import com.sun.source.util.DocTreeFactory;
 import com.sun.tools.doclint.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -180,32 +183,31 @@
 
         String title = getWindowTitle(docletWriter, dfElement).trim();
         HtmlTree htmlContent = docletWriter.getBody(title);
-        docletWriter.addTop(htmlContent);
         PackageElement pkg = dfElement.getPackageElement();
-        this.navBar = new Navigation(element, configuration, docletWriter.fixedNavDiv,
-                PageMode.DOCFILE, docletWriter.path);
+        this.navBar = new Navigation(element, configuration, PageMode.DOCFILE, docletWriter.path);
+        Content headerContent = new ContentBuilder();
+        docletWriter.addTop(headerContent);
         Content mdleLinkContent = docletWriter.getModuleLink(utils.elementUtils.getModuleOf(pkg),
                 docletWriter.contents.moduleLabel);
         navBar.setNavLinkModule(mdleLinkContent);
         Content pkgLinkContent = docletWriter.getPackageLink(pkg, docletWriter.contents.packageLabel);
         navBar.setNavLinkPackage(pkgLinkContent);
         navBar.setUserHeader(docletWriter.getUserHeaderFooter(true));
-        Content header = HtmlTree.HEADER();
-        header.add(navBar.getContent(true));
-        htmlContent.add(header);
+        headerContent.add(navBar.getContent(true));
 
         List<? extends DocTree> fullBody = utils.getFullBody(dfElement);
-        Content bodyContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false);
-        docletWriter.addTagsInfo(dfElement, bodyContent);
-        Content main = HtmlTree.MAIN();
-        main.add(bodyContent);
-        htmlContent.add(main);
+        Content pageContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false);
+        docletWriter.addTagsInfo(dfElement, pageContent);
 
         navBar.setUserFooter(docletWriter.getUserHeaderFooter(false));
         Content footer = HtmlTree.FOOTER();
         footer.add(navBar.getContent(false));
         docletWriter.addBottom(footer);
-        htmlContent.add(footer);
+        htmlContent.add(new BodyContents()
+                .setHeader(headerContent)
+                .addMainContent(HtmlTree.DIV(HtmlStyle.contentContainer, pageContent))
+                .setFooter(footer)
+                .toContent());
         docletWriter.printHtmlDocument(Collections.emptyList(), null, localTagsContent, Collections.emptyList(), htmlContent);
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -25,6 +25,8 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -50,8 +52,6 @@
  */
 public class HelpWriter extends HtmlDocletWriter {
 
-    HtmlTree mainTree = HtmlTree.MAIN();
-
     private final Navigation navBar;
 
     /**
@@ -62,7 +62,7 @@
     public HelpWriter(HtmlConfiguration configuration,
                       DocPath filename) {
         super(configuration, filename);
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.HELP, path);
+        this.navBar = new Navigation(null, configuration, PageMode.HELP, path);
     }
 
     /**
@@ -88,17 +88,21 @@
     protected void generateHelpFile() throws DocFileIOException {
         String title = resources.getText("doclet.Window_Help_title");
         HtmlTree body = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        body.add(htmlTree);
-        addHelpFileContents(body);
-        htmlTree = HtmlTree.FOOTER();
+        headerContent.add(navBar.getContent(true));
+        ContentBuilder helpFileContent = new ContentBuilder();
+        addHelpFileContents(helpFileContent);
+        HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
-        htmlTree.add(navBar.getContent(false));
-        addBottom(htmlTree);
-        body.add(htmlTree);
+        footer.add(navBar.getContent(false));
+        addBottom(footer);
+        body.add(new BodyContents()
+                .setHeader(headerContent)
+                .addMainContent(helpFileContent)
+                .setFooter(footer)
+                .toContent());
         printHtmlDocument(null, "help", body);
     }
 
@@ -118,7 +122,7 @@
         Content intro = HtmlTree.DIV(HtmlStyle.subTitle,
                 contents.getContent("doclet.help.intro"));
         div.add(intro);
-        mainTree.add(div);
+        contentTree.add(div);
         HtmlTree htmlTree;
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
         ul.setStyle(HtmlStyle.blockList);
@@ -332,7 +336,6 @@
         Content footnote = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase,
                 contents.getContent("doclet.help.footnote"));
         divContent.add(footnote);
-        mainTree.add(divContent);
-        contentTree.add(mainTree);
+        contentTree.add(divContent);
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -188,8 +188,6 @@
      */
     private boolean isContainerDocumented = false;
 
-    HtmlTree fixedNavDiv = new HtmlTree(HtmlTag.DIV);
-
     /**
      * The window title of this file.
      */
@@ -509,7 +507,7 @@
      */
     public void addTop(Content htmlTree) {
         Content top = new RawHtml(replaceDocRootDir(configuration.top));
-        fixedNavDiv.add(top);
+        htmlTree.add(top);
     }
 
     /**
@@ -2112,29 +2110,6 @@
     }
 
     /**
-     * Returns an HtmlTree for the SCRIPT tag.
-     *
-     * @return an HtmlTree for the SCRIPT tag
-     */
-    protected Script getWinTitleScript() {
-        Script script = new Script();
-        if (winTitle != null && winTitle.length() > 0) {
-            script.append("<!--\n" +
-                    "    try {\n" +
-                    "        if (location.href.indexOf('is-external=true') == -1) {\n" +
-                    "            parent.document.title=")
-                    .appendStringLiteral(winTitle)
-                    .append(";\n" +
-                    "        }\n" +
-                    "    }\n" +
-                    "    catch(err) {\n" +
-                    "    }\n" +
-                    "//-->\n");
-        }
-        return script;
-    }
-
-    /**
      * Returns an HtmlTree for the BODY tag.
      *
      * @param title title for the window
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -42,6 +42,7 @@
 
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
@@ -161,12 +162,9 @@
     private final Map<TypeElement, Content> providesTrees
             = new TreeMap<>(utils.makeAllClassesComparator());
 
-    /**
-     * The HTML tree for main tag.
-     */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
+    private final Navigation navBar;
 
-    private final Navigation navBar;
+    private final BodyContents bodyContents = new BodyContents();
 
     /**
      * Constructor to construct ModuleWriter object and to generate "moduleName-summary.html" file.
@@ -178,7 +176,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);
+        this.navBar = new Navigation(mdle, configuration, PageMode.MODULE, path);
         computeModulesData();
     }
 
@@ -190,16 +188,15 @@
     @Override
     public Content getModuleHeader(String heading) {
         HtmlTree bodyTree = getBody(getWindowTitle(mdle.getQualifiedName().toString()));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         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.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.header);
         Content annotationContent = new HtmlTree(HtmlTag.P);
@@ -213,7 +210,8 @@
         Content moduleHead = new RawHtml(heading);
         tHeading.add(moduleHead);
         div.add(tHeading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent)
+                .addMainContent(div);
         return bodyTree;
     }
 
@@ -877,21 +875,20 @@
      * {@inheritDoc}
      */
     @Override
-    public void addModuleContent(Content contentTree, Content moduleContentTree) {
-        mainTree.add(moduleContentTree);
-        contentTree.add(mainTree);
+    public void addModuleContent(Content moduleContentTree) {
+        bodyContents.addMainContent(moduleContentTree);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void addModuleFooter(Content contentTree) {
+    public void addModuleFooter() {
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        contentTree.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
     }
 
     /**
@@ -901,6 +898,7 @@
      */
     @Override
     public void printDocument(Content contentTree) throws DocFileIOException {
+        contentTree.add(bodyContents.toContent());
         printHtmlDocument(configuration.metakeywords.getMetaKeywordsForModule(mdle),
                 getDescription("declaration", mdle), getLocalStylesheets(mdle), contentTree);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -27,6 +27,8 @@
 
 import javax.lang.model.element.PackageElement;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -60,6 +62,8 @@
 
     private final Navigation navBar;
 
+    private final BodyContents bodyContents = new BodyContents();
+
     /**
      * Constructor.
      * @param configuration the configuration
@@ -70,7 +74,7 @@
         super(configuration, path,
               new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration));
         this.packageElement = packageElement;
-        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.TREE, path);
+        this.navBar = new Navigation(packageElement, configuration, PageMode.TREE, path);
     }
 
     /**
@@ -97,7 +101,7 @@
      */
     protected void generatePackageTreeFile() throws DocFileIOException {
         HtmlTree body = getPackageTreeHeader();
-        HtmlTree mainTree = HtmlTree.MAIN();
+        Content mainContent = new ContentBuilder();
         Content headContent = contents.getContent("doclet.Hierarchy_For_Package",
                 utils.getPackageName(packageElement));
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false,
@@ -106,20 +110,21 @@
         if (configuration.packages.size() > 1) {
             addLinkToMainTree(div);
         }
-        mainTree.add(div);
+        mainContent.add(div);
         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
         divTree.setStyle(HtmlStyle.contentContainer);
         addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
         addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
         addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
         addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
-        mainTree.add(divTree);
-        body.add(mainTree);
+        mainContent.add(divTree);
+        bodyContents.addMainContent(mainContent);
         HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        body.add(footer);
+        bodyContents.setFooter(footer);
+        body.add(bodyContents.toContent());
         printHtmlDocument(null, getDescription("tree", packageElement), body);
     }
 
@@ -132,14 +137,14 @@
         String packageName = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
         String title = packageName + " " + resources.getText("doclet.Window_Class_Hierarchy");
         HtmlTree bodyTree = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
                 contents.moduleLabel);
         navBar.setNavLinkModule(linkContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
+        bodyContents.setHeader(headerContent);
         return bodyTree;
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -64,7 +64,6 @@
 
     final PackageElement packageElement;
     final SortedMap<String, Set<TypeElement>> usingPackageToUsedClasses = new TreeMap<>();
-    protected HtmlTree mainTree = HtmlTree.MAIN();
     final String packageUseTableSummary;
     private final Navigation navBar;
 
@@ -104,7 +103,7 @@
 
         packageUseTableSummary = resources.getText("doclet.Use_Table_Summary",
                 resources.getText("doclet.packages"));
-        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.USE, path);
+        this.navBar = new Navigation(packageElement, configuration, PageMode.USE, path);
     }
 
     /**
@@ -136,13 +135,13 @@
         } else {
             addPackageUse(div);
         }
-        mainTree.add(div);
-        body.add(mainTree);
+        bodyContents.addMainContent(div);
         HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        body.add(footer);
+        bodyContents.setFooter(footer);
+        body.add(bodyContents.toContent());
         printHtmlDocument(null,
                 getDescription("use", packageElement),
                 body);
@@ -242,22 +241,22 @@
         String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
         String title = resources.getText("doclet.Window_ClassUse_Header", packageText, name);
         HtmlTree bodyTree = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
                 contents.moduleLabel);
         navBar.setNavLinkModule(linkContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
-        ContentBuilder headContent = new ContentBuilder();
-        headContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
-        headContent.add(new HtmlTree(HtmlTag.BR));
-        headContent.add(name);
+        headerContent.add(navBar.getContent(true));
+        ContentBuilder headingContent = new ContentBuilder();
+        headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
+        headingContent.add(new HtmlTree(HtmlTag.BR));
+        headingContent.add(name);
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                HtmlStyle.title, headContent);
+                HtmlStyle.title, headingContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent)
+                .addMainContent(div);
         return bodyTree;
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -33,6 +33,7 @@
 import javax.lang.model.element.TypeElement;
 
 import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
@@ -72,17 +73,14 @@
     protected PackageElement packageElement;
 
     /**
-     * The HTML tree for main tag.
-     */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
-
-    /**
      * The HTML tree for section tag.
      */
     protected HtmlTree sectionTree = HtmlTree.SECTION(HtmlStyle.packageDescription, new ContentBuilder());
 
     private final Navigation navBar;
 
+    private final BodyContents bodyContents = new BodyContents();
+
     /**
      * Constructor to construct PackageWriter object and to generate
      * "package-summary.html" file in the respective package directory.
@@ -99,7 +97,7 @@
                 configuration.docPaths.forPackage(packageElement)
                 .resolve(DocPaths.PACKAGE_SUMMARY));
         this.packageElement = packageElement;
-        this.navBar = new Navigation(packageElement, configuration, fixedNavDiv, PageMode.PACKAGE, path);
+        this.navBar = new Navigation(packageElement, configuration, PageMode.PACKAGE, path);
     }
 
     /**
@@ -108,14 +106,13 @@
     @Override
     public Content getPackageHeader(String heading) {
         HtmlTree bodyTree = getBody(getWindowTitle(utils.getPackageName(packageElement)));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
                 contents.moduleLabel);
         navBar.setNavLinkModule(linkContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.header);
         if (configuration.showModules) {
@@ -136,7 +133,8 @@
         Content packageHead = new StringContent(heading);
         tHeading.add(packageHead);
         div.add(tHeading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent)
+                .addMainContent(div);
         return bodyTree;
     }
 
@@ -295,21 +293,20 @@
      * {@inheritDoc}
      */
     @Override
-    public void addPackageContent(Content contentTree, Content packageContentTree) {
-        mainTree.add(packageContentTree);
-        contentTree.add(mainTree);
+    public void addPackageContent(Content packageContentTree) {
+        bodyContents.addMainContent(packageContentTree);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void addPackageFooter(Content contentTree) {
+    public void addPackageFooter() {
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        contentTree.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
     }
 
     /**
@@ -319,6 +316,7 @@
     public void printDocument(Content contentTree) throws DocFileIOException {
         String description = getDescription("declaration", packageElement);
         List<DocPath> localStylesheets = getLocalStylesheets(packageElement);
+        contentTree.add(bodyContents.toContent());
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement),
                 description, localStylesheets, contentTree);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Wed Nov 27 13:08:16 2019 +0100
@@ -29,6 +29,7 @@
 
 import javax.lang.model.element.TypeElement;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -56,11 +57,6 @@
 
     Set<TypeElement> visibleClasses;
 
-    /**
-     * HTML tree for main tag.
-     */
-    private HtmlTree mainTree = HtmlTree.MAIN();
-
     private final Navigation navBar;
 
     /**
@@ -69,7 +65,7 @@
     public SerializedFormWriterImpl(HtmlConfiguration configuration) {
         super(configuration, DocPaths.SERIALIZED_FORM);
         visibleClasses = configuration.getIncludedTypeElements();
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.SERIALIZEDFORM, path);
+        this.navBar = new Navigation(null, configuration, PageMode.SERIALIZEDFORM, path);
     }
 
     /**
@@ -80,16 +76,16 @@
      */
     public Content getHeader(String header) {
         HtmlTree bodyTree = getBody(getWindowTitle(header));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
         Content h1Content = new StringContent(header);
         Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
                 HtmlStyle.title, h1Content);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
-        mainTree.add(div);
+        bodyContents.setHeader(headerContent)
+                .addMainContent(div);
         return bodyTree;
     }
 
@@ -216,16 +212,14 @@
     }
 
     /**
-     * Get the serialized content tree section.
+     * Add the serialized content tree section.
      *
      * @param serializedTreeContent the serialized content tree to be added
-     * @return a div content tree
      */
-    public Content getSerializedContent(Content serializedTreeContent) {
+    public void addSerializedContent(Content serializedTreeContent) {
         HtmlTree divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
                 serializedTreeContent);
-        mainTree.add(divContent);
-        return mainTree;
+        bodyContents.addMainContent(divContent);
     }
 
     /**
@@ -238,15 +232,13 @@
 
     /**
      * Add the footer.
-     *
-     * @param serializedTree the serialized tree to be added
      */
-    public void addFooter(Content serializedTree) {
+    public void addFooter() {
         Content htmlTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         htmlTree.add(navBar.getContent(false));
         addBottom(htmlTree);
-        serializedTree.add(htmlTree);
+        bodyContents.setFooter(htmlTree);
     }
 
     /**
@@ -254,6 +246,7 @@
      */
     @Override
     public void printDocument(Content serializedTree) throws DocFileIOException {
+        serializedTree.add(bodyContents.toContent());
         printHtmlDocument(null, "serialized forms", serializedTree);
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -28,6 +28,8 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -95,15 +97,10 @@
     protected void generateIndexFile() throws DocFileIOException {
         String title = resources.getText("doclet.Window_Single_Index");
         HtmlTree body = getBody(getWindowTitle(title));
-        HtmlTree header = HtmlTree.HEADER();
-        addTop(header);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        header.add(navBar.getContent(true));
-        body.add(header);
-        HtmlTree main = HtmlTree.MAIN();
-        main.add(HtmlTree.DIV(HtmlStyle.header,
-                HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
-                        contents.getContent("doclet.Index"))));
+        headerContent.add(navBar.getContent(true));
         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
         divTree.setStyle(HtmlStyle.contentContainer);
         elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
@@ -120,13 +117,18 @@
             }
         }
         addLinksForIndexes(divTree);
-        main.add(divTree);
-        body.add(main);
         HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        body.add(footer);
+        body.add(new BodyContents()
+                .setHeader(headerContent)
+                .addMainContent(HtmlTree.DIV(HtmlStyle.header,
+                        HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
+                                contents.getContent("doclet.Index"))))
+                .addMainContent(divTree)
+                .setFooter(footer)
+                .toContent());
         createSearchIndexFiles();
         printHtmlDocument(null, "index", body);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -32,6 +32,8 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -122,12 +124,11 @@
         String title = resources.getText("doclet.Window_Split_Index",
                 unicode.toString());
         HtmlTree body = getBody(getWindowTitle(title));
-        HtmlTree header = HtmlTree.HEADER();
-        addTop(header);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        header.add(navBar.getContent(true));
-        body.add(header);
-        HtmlTree main = HtmlTree.MAIN();
+        headerContent.add(navBar.getContent(true));
+        Content main = new ContentBuilder();
         main.add(HtmlTree.DIV(HtmlStyle.header,
                 HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
                         contents.getContent("doclet.Index"))));
@@ -144,12 +145,15 @@
         }
         addLinksForIndexes(divTree);
         main.add(divTree);
-        body.add(main);
         HtmlTree footer = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
         footer.add(navBar.getContent(false));
         addBottom(footer);
-        body.add(footer);
+        body.add(new BodyContents()
+                .setHeader(headerContent)
+                .addMainContent(main)
+                .setFooter(footer)
+                .toContent());
         String description = "index: " + unicode;
         printHtmlDocument(null, description, body);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -31,6 +31,7 @@
 import javax.lang.model.element.TypeElement;
 
 import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
 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;
@@ -60,9 +61,9 @@
 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
 
     /**
-     * The HTML tree for main tag.
+     * The HTML builder for the body contents.
      */
-    protected HtmlTree mainTree = HtmlTree.MAIN();
+    protected BodyContents bodyContents = new BodyContents();
 
     public SubWriterHolderWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
@@ -191,22 +192,19 @@
     /**
      * Add the class content tree.
      *
-     * @param contentTree content tree to which the class content will be added
      * @param classContentTree class content tree which will be added to the content tree
      */
-    public void addClassContentTree(Content contentTree, Content classContentTree) {
-        mainTree.add(classContentTree);
-        contentTree.add(mainTree);
+    public void addClassContentTree(Content classContentTree) {
+        bodyContents.addMainContent(classContentTree);
     }
 
     /**
      * Add the annotation content tree.
      *
-     * @param contentTree content tree to which the annotation content will be added
      * @param annotationContentTree annotation content tree which will be added to the content tree
      */
-    public void addAnnotationContentTree(Content contentTree, Content annotationContentTree) {
-        addClassContentTree(contentTree, annotationContentTree);
+    public void addAnnotationContentTree(Content annotationContentTree) {
+        addClassContentTree(annotationContentTree);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -29,6 +29,8 @@
 
 import javax.lang.model.element.PackageElement;
 
+import jdk.javadoc.internal.doclets.formats.html.markup.BodyContents;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -70,6 +72,8 @@
 
     private final Navigation navBar;
 
+    protected BodyContents bodyContents;
+
     /**
      * Constructor to construct TreeWriter object.
      *
@@ -81,7 +85,8 @@
         super(configuration, filename, classtree);
         packages = configuration.packages;
         classesOnly = packages.isEmpty();
-        this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.TREE, path);
+        this.navBar = new Navigation(null, configuration, PageMode.TREE, path);
+        this.bodyContents = new BodyContents();
     }
 
     /**
@@ -111,21 +116,23 @@
                 HtmlStyle.title, headContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
         addPackageTreeLinks(div);
-        HtmlTree htmlTree = HtmlTree.MAIN();
-        htmlTree.add(div);
+        Content mainContent = new ContentBuilder();
+        mainContent.add(div);
         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
         divTree.setStyle(HtmlStyle.contentContainer);
         addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
         addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
         addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
         addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
-        htmlTree.add(divTree);
-        body.add(htmlTree);
-        htmlTree = HtmlTree.FOOTER();
+        mainContent.add(divTree);
+        HtmlTree footerTree = HtmlTree.FOOTER();
         navBar.setUserFooter(getUserHeaderFooter(false));
-        htmlTree.add(navBar.getContent(false));
-        addBottom(htmlTree);
-        body.add(htmlTree);
+        footerTree.add(navBar.getContent(false));
+        addBottom(footerTree);
+        body.add(bodyContents
+                .addMainContent(mainContent)
+                .setFooter(footerTree)
+                .toContent());
         printHtmlDocument(null, "class tree", body);
     }
 
@@ -176,11 +183,11 @@
     protected HtmlTree getTreeHeader() {
         String title = resources.getText("doclet.Window_Class_Hierarchy");
         HtmlTree bodyTree = getBody(getWindowTitle(title));
-        HtmlTree htmlTree = HtmlTree.HEADER();
-        addTop(htmlTree);
+        Content headerContent = new ContentBuilder();
+        addTop(headerContent);
         navBar.setUserHeader(getUserHeaderFooter(true));
-        htmlTree.add(navBar.getContent(true));
-        bodyTree.add(htmlTree);
+        headerContent.add(navBar.getContent(true));
+        bodyContents.setHeader(headerContent);
         return bodyTree;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/BodyContents.java	Wed Nov 27 13:08:16 2019 +0100
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A builder for the contents of the BODY element.
+ *
+ *  <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 BodyContents {
+
+    private List<Content> mainContents = new ArrayList<>();
+    private Content header = HtmlTree.EMPTY;
+    private Content footer = HtmlTree.EMPTY;
+
+    public BodyContents addMainContent(Content content) {
+        mainContents.add(content);
+        return this;
+    }
+
+    public BodyContents setHeader(Content header) {
+        this.header = header;
+        return this;
+    }
+
+    public BodyContents setFooter(Content footer) {
+        this.footer = footer;
+        return this;
+    }
+
+    /**
+     * Returns the HTML for the contents of the BODY element.
+     *
+     * @return the HTML
+     */
+    public Content toContent() {
+        HtmlTree mainTree = HtmlTree.MAIN();
+        mainContents.forEach(mainTree::add);
+        HtmlTree flexHeader = HtmlTree.HEADER().setStyle(HtmlStyle.flexHeader);
+        flexHeader.add(header);
+        HtmlTree flexBox = HtmlTree.DIV(HtmlStyle.flexBox, flexHeader);
+        HtmlTree flexContent = HtmlTree.DIV(HtmlStyle.flexContent, mainTree);
+        flexContent.add(footer);
+        flexBox.add(flexContent);
+        return flexBox;
+    }
+}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java	Wed Nov 27 13:08:16 2019 +0100
@@ -73,7 +73,9 @@
     externalLink,
     fieldDetails,
     fieldSummary,
-    fixedNav,
+    flexBox,
+    flexHeader,
+    flexContent,
     header,
     helpSection,
     hierarchy,
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Wed Nov 27 13:08:16 2019 +0100
@@ -584,21 +584,6 @@
     }
 
     /**
-     * Generates a MAIN tag with role attribute, style attribute and some content.
-     *
-     * @param styleClass style of the MAIN tag
-     * @param body content of the MAIN tag
-     * @return an HtmlTree object for the MAIN tag
-     */
-    public static HtmlTree MAIN(HtmlStyle styleClass, Content body) {
-        HtmlTree htmltree = HtmlTree.MAIN(body);
-        if (styleClass != null) {
-            htmltree.setStyle(styleClass);
-        }
-        return htmltree;
-    }
-
-    /**
      * Generates a META tag with the http-equiv, content and charset attributes.
      *
      * @param httpEquiv http equiv attribute for the META tag
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	Wed Nov 27 13:08:16 2019 +0100
@@ -70,7 +70,6 @@
     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;
@@ -85,9 +84,6 @@
     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 {
         ALLCLASSES,
@@ -133,15 +129,12 @@
      *
      * @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) {
+    public Navigation(Element element, HtmlConfiguration configuration, PageMode page, DocPath path) {
         this.configuration = configuration;
         this.element = element;
-        this.fixedNavDiv = fixedNavDiv;
         this.contents = configuration.contents;
         this.documentedPage = page;
         this.path = path;
@@ -941,10 +934,6 @@
         tree.add(searchDiv);
     }
 
-    private void addFixedNavScript(Content tree) {
-        tree.add(FIXED_NAV_SCRIPT.asContent());
-    }
-
     /**
      * Get the navigation content.
      *
@@ -952,69 +941,58 @@
      * @return the navigation contents
      */
     public Content getContent(boolean top) {
-        Content contentTree = new ContentBuilder();
-        if (!configuration.nonavbar) {
-            Deque<Content> queue;
-            Content tree = HtmlTree.NAV();
-            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
-            if (top) {
-                queue = topBottomNavContents.get(Position.TOP);
-                fixedNavDiv.add(Position.TOP.startOfNav());
-                navDiv.setStyle(HtmlStyle.topNav);
-            } else {
-                queue = topBottomNavContents.get(Position.BOTTOM);
-                tree.add(Position.BOTTOM.startOfNav());
-                navDiv.setStyle(HtmlStyle.bottomNav);
-            }
-            navDiv.add(queue.poll());
-            HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll());
-            navDiv.add(skipLinkDiv);
-            navDiv.add(queue.poll());
-            HtmlTree navList = new HtmlTree(HtmlTag.UL);
-            navList.setStyle(HtmlStyle.navList);
-            navList.put(HtmlAttr.TITLE, rowListTitle);
-            fixedNavDiv.setStyle(HtmlStyle.fixedNav);
-            addMainNavLinks(navList);
-            navDiv.add(navList);
-            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, top ? userHeader : userFooter);
-            navDiv.add(aboutDiv);
-            if (top) {
-                fixedNavDiv.add(navDiv);
-            } else {
-                tree.add(navDiv);
-            }
-            HtmlTree subDiv = new HtmlTree(HtmlTag.DIV);
-            subDiv.setStyle(HtmlStyle.subNav);
-            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.add(ulNavSummary);
-            // Add the detail links if present.
-            HtmlTree ulNavDetail = new HtmlTree(HtmlTag.UL);
-            ulNavDetail.setStyle(HtmlStyle.subNavList);
-            addDetailLinks(ulNavDetail);
-            div.add(ulNavDetail);
-            subDiv.add(div);
-            if (top && configuration.createindex) {
-                addSearch(subDiv);
-            }
-            if (top) {
-                fixedNavDiv.add(subDiv);
-                fixedNavDiv.add(queue.poll());
-                fixedNavDiv.add(Position.TOP.endOfNav());
-                tree.add(fixedNavDiv);
-                HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Entity.NO_BREAK_SPACE);
-                tree.add(paddingDiv);
-                addFixedNavScript(tree);
-            } else {
-                tree.add(subDiv);
-                tree.add(queue.poll());
-                tree.add(Position.BOTTOM.endOfNav());
-            }
-            return tree;
+        if (configuration.nonavbar) {
+            return new ContentBuilder();
+        }
+        Deque<Content> queue;
+        Content tree = HtmlTree.NAV();
+        HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
+        if (top) {
+            queue = topBottomNavContents.get(Position.TOP);
+            tree.add(Position.TOP.startOfNav());
+            navDiv.setStyle(HtmlStyle.topNav);
+        } else {
+            queue = topBottomNavContents.get(Position.BOTTOM);
+            tree.add(Position.BOTTOM.startOfNav());
+            navDiv.setStyle(HtmlStyle.bottomNav);
         }
-        return contentTree;
+        navDiv.add(queue.poll());
+        HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll());
+        navDiv.add(skipLinkDiv);
+        navDiv.add(queue.poll());
+        HtmlTree navList = new HtmlTree(HtmlTag.UL);
+        navList.setStyle(HtmlStyle.navList);
+        navList.put(HtmlAttr.TITLE, rowListTitle);
+        addMainNavLinks(navList);
+        navDiv.add(navList);
+        Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, top ? userHeader : userFooter);
+        navDiv.add(aboutDiv);
+        tree.add(navDiv);
+        HtmlTree subDiv = new HtmlTree(HtmlTag.DIV);
+        subDiv.setStyle(HtmlStyle.subNav);
+        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.add(ulNavSummary);
+        // Add the detail links if present.
+        HtmlTree ulNavDetail = new HtmlTree(HtmlTag.UL);
+        ulNavDetail.setStyle(HtmlStyle.subNavList);
+        addDetailLinks(ulNavDetail);
+        div.add(ulNavDetail);
+        subDiv.add(div);
+        if (top && configuration.createindex) {
+            addSearch(subDiv);
+        }
+        tree.add(subDiv);
+        if (top) {
+            tree.add(Position.TOP.endOfNav());
+            tree.add(HtmlTree.DIV(HtmlStyle.skipNav, queue.poll()));
+        } else {
+            tree.add(queue.poll());
+            tree.add(Position.BOTTOM.endOfNav());
+        }
+        return tree;
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -112,10 +112,9 @@
     /**
      * Add the annotation content tree to the documentation content tree.
      *
-     * @param contentTree content tree to which the annotation content will be added
      * @param annotationContentTree annotation content tree which will be added to the content tree
      */
-    public void addAnnotationContentTree(Content contentTree, Content annotationContentTree);
+    public void addAnnotationContentTree(Content annotationContentTree);
 
     /**
      * Get the member tree.
@@ -143,10 +142,8 @@
 
     /**
      * Add the footer of the page.
-     *
-     * @param contentTree content tree to which the footer will be added
      */
-    public void addFooter(Content contentTree);
+    public void addFooter();
 
     /**
      * Print the document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -177,17 +177,14 @@
     /**
      * Add the class content tree.
      *
-     * @param contentTree content tree to which the class content will be added
      * @param classContentTree class content tree which will be added to the content tree
      */
-    public void addClassContentTree(Content contentTree, Content classContentTree);
+    public void addClassContentTree(Content classContentTree);
 
     /**
      * Add the footer of the page.
-     *
-     * @param contentTree content tree to which the footer will be added
      */
-    public void addFooter(Content contentTree);
+    public void addFooter();
 
     /**
      * Print the document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -75,10 +75,9 @@
     /**
      * Add the content list to the documentation tree.
      *
-     * @param contentTree the tree to which the contents list will be added
      * @param contentListTree the content that will be added to the list
      */
-    public abstract void addContentsList(Content contentTree, Content contentListTree);
+    public abstract void addContentsList(Content contentListTree);
 
     /**
      * Get the constant summaries for the document.
@@ -129,17 +128,14 @@
     /**
      * Add the summaries list to the content tree.
      *
-     * @param contentTree the tree to which the summaries list will be added
      * @param summariesTree the summaries content tree that will be added to the list
      */
-    public abstract void addConstantSummaries(Content contentTree, Content summariesTree);
+    public abstract void addConstantSummaries(Content summariesTree);
 
     /**
      * Adds the footer for the summary documentation.
-     *
-     * @param contentTree content tree to which the footer will be added
      */
-    public abstract void addFooter(Content contentTree);
+    public abstract void addFooter();
 
     /**
      * Print the constants summary document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -111,17 +111,14 @@
     /**
      * Adds the module content tree to the documentation tree.
      *
-     * @param contentTree the tree to which the module content tree will be added
      * @param moduleContentTree the content tree that will be added
      */
-    public abstract void addModuleContent(Content contentTree, Content moduleContentTree);
+    public abstract void addModuleContent(Content moduleContentTree);
 
     /**
      * Adds the footer to the documentation tree.
-     *
-     * @param contentTree the tree to which the footer will be added
      */
-    public abstract void addModuleFooter(Content contentTree);
+    public abstract void addModuleFooter();
 
     /**
      * Print the module summary document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -143,17 +143,14 @@
      * Adds the tag information from the "packages.html" or "package-info.java" file to the
      * documentation tree.
      *
-     * @param contentTree the content tree to which the package content tree will be added
      * @param packageContentTree the package content tree to be added
      */
-    public abstract void addPackageContent(Content contentTree, Content packageContentTree);
+    public abstract void addPackageContent(Content packageContentTree);
 
     /**
      * Adds the footer to the documentation tree.
-     *
-     * @param contentTree the tree to which the footer will be added
      */
-    public abstract void addPackageFooter(Content contentTree);
+    public abstract void addPackageFooter();
 
     /**
      * Print the package summary document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java	Wed Nov 27 13:08:16 2019 +0100
@@ -140,19 +140,16 @@
     public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement);
 
     /**
-     * Get the serialized content.
+     * Add the serialized content to the body content.
      *
      * @param serializedTreeContent content for serialized data
-     * @return a content tree for serialized information
      */
-    public Content getSerializedContent(Content serializedTreeContent);
+    public void addSerializedContent(Content serializedTreeContent);
 
     /**
      * Add the footer.
-     *
-     * @param serializedTree the serialized tree to be added
      */
-    public void addFooter(Content serializedTree);
+    public void addFooter();
 
     /**
      * Print the serialized form document.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -59,11 +59,6 @@
     private final AnnotationTypeWriter writer;
 
     /**
-     * The content tree for the annotation documentation.
-     */
-    private Content contentTree;
-
-    /**
      * Construct a new ClassBuilder.
      *
      * @param context           the build context.
@@ -97,17 +92,16 @@
      */
     @Override
     public void build() throws DocletException {
-        buildAnnotationTypeDoc(contentTree);
+        buildAnnotationTypeDoc();
     }
 
     /**
      * Build the annotation type documentation.
      *
-     * @param contentTree the content tree to which the documentation will be added
      * @throws DocletException if there is a problem building the documentation
      */
-    protected void buildAnnotationTypeDoc(Content contentTree) throws DocletException {
-        contentTree = writer.getHeader(resources.getText("doclet.AnnotationType") +
+    protected void buildAnnotationTypeDoc() throws DocletException {
+        Content contentTree = writer.getHeader(resources.getText("doclet.AnnotationType") +
                " " + utils.getSimpleName(annotationType));
         Content annotationContentTree = writer.getAnnotationContentHeader();
 
@@ -115,8 +109,8 @@
         buildMemberSummary(annotationContentTree);
         buildAnnotationTypeMemberDetails(annotationContentTree);
 
-        writer.addAnnotationContentTree(contentTree, annotationContentTree);
-        writer.addFooter(contentTree);
+        writer.addAnnotationContentTree(annotationContentTree);
+        writer.addFooter();
         writer.printDocument(contentTree);
         copyDocFiles();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -69,11 +69,6 @@
      */
     private final boolean isEnum;
 
-    /**
-     * The content tree for the class documentation.
-     */
-    private Content contentTree;
-
     private final Utils utils;
 
     /**
@@ -118,16 +113,15 @@
      */
     @Override
     public void build() throws DocletException {
-        buildClassDoc(contentTree);
+        buildClassDoc();
     }
 
      /**
       * Handles the {@literal <TypeElement>} tag.
       *
-      * @param contentTree the content tree to which the documentation will be added
       * @throws DocletException if there is a problem while building the documentation
       */
-     protected void buildClassDoc(Content contentTree) throws DocletException {
+     protected void buildClassDoc() throws DocletException {
         String key;
         if (isInterface) {
             key = "doclet.Interface";
@@ -136,7 +130,7 @@
         } else {
             key = "doclet.Class";
         }
-        contentTree = writer.getHeader(resources.getText(key) + " "
+        Content contentTree = writer.getHeader(resources.getText(key) + " "
                 + utils.getSimpleName(typeElement));
         Content classContentTree = writer.getClassContentHeader();
 
@@ -145,8 +139,8 @@
         buildMemberSummary(classContentTree);
         buildMemberDetails(classContentTree);
 
-        writer.addClassContentTree(contentTree, classContentTree);
-        writer.addFooter(contentTree);
+        writer.addClassContentTree(classContentTree);
+        writer.addFooter();
         writer.printDocument(contentTree);
         copyDocFiles();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -84,11 +84,6 @@
     private TypeElement currentClass;
 
     /**
-     * The content tree for the constant summary documentation.
-     */
-    private Content contentTree;
-
-    /**
      * True if first package is listed.
      */
     private boolean first = true;
@@ -129,31 +124,28 @@
             //Doclet does not support this output.
             return;
         }
-        buildConstantSummary(contentTree);
+        buildConstantSummary();
     }
 
     /**
      * Build the constant summary.
      *
-     * @param contentTree the content tree to which the documentation will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildConstantSummary(Content contentTree) throws DocletException {
-        contentTree = writer.getHeader();
+    protected void buildConstantSummary() throws DocletException {
+        Content contentTree = writer.getHeader();
 
-        buildContents(contentTree);
-        buildConstantSummaries(contentTree);
+        buildContents();
+        buildConstantSummaries();
 
-        writer.addFooter(contentTree);
+        writer.addFooter();
         writer.printDocument(contentTree);
     }
 
     /**
      * Build the list of packages.
-     *
-     * @param contentTree the content tree to which the content list will be added
      */
-    protected void buildContents(Content contentTree) {
+    protected void buildContents() {
         Content contentListTree = writer.getContentsHeader();
         printedPackageHeaders.clear();
         for (PackageElement pkg : configuration.packages) {
@@ -161,16 +153,15 @@
                 writer.addLinkToPackageContent(pkg, printedPackageHeaders, contentListTree);
             }
         }
-        writer.addContentsList(contentTree, contentListTree);
+        writer.addContentsList(contentListTree);
     }
 
     /**
      * Build the summary for each documented package.
      *
-     * @param contentTree the tree to which the summaries will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildConstantSummaries(Content contentTree) throws DocletException {
+    protected void buildConstantSummaries() throws DocletException {
         printedPackageHeaders.clear();
         Content summariesTree = writer.getConstantSummaries();
         for (PackageElement aPackage : configuration.packages) {
@@ -184,7 +175,7 @@
                 first = false;
             }
         }
-        writer.addConstantSummaries(contentTree, summariesTree);
+        writer.addConstantSummaries(summariesTree);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -56,11 +56,6 @@
     private final ModuleSummaryWriter moduleWriter;
 
     /**
-     * The content that will be added to the module summary documentation tree.
-     */
-    private Content contentTree;
-
-    /**
      * Construct a new ModuleSummaryBuilder.
      *
      * @param context  the build context.
@@ -101,21 +96,20 @@
             //Doclet does not support this output.
             return;
         }
-        buildModuleDoc(contentTree);
+        buildModuleDoc();
     }
 
     /**
      * Build the module documentation.
      *
-     * @param contentTree the content tree to which the documentation will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildModuleDoc(Content contentTree) throws DocletException {
-        contentTree = moduleWriter.getModuleHeader(mdle.getQualifiedName().toString());
+    protected void buildModuleDoc() throws DocletException {
+        Content contentTree = moduleWriter.getModuleHeader(mdle.getQualifiedName().toString());
 
-        buildContent(contentTree);
+        buildContent();
 
-        moduleWriter.addModuleFooter(contentTree);
+        moduleWriter.addModuleFooter();
         moduleWriter.printDocument(contentTree);
         DocFilesHandler docFilesHandler = configuration.getWriterFactory().getDocFilesHandler(mdle);
         docFilesHandler.copyDocFiles();
@@ -124,18 +118,16 @@
     /**
      * Build the content for the module doc.
      *
-     * @param contentTree the content tree to which the module contents
-     *                    will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildContent(Content contentTree) throws DocletException {
+    protected void buildContent() throws DocletException {
         Content moduleContentTree = moduleWriter.getContentHeader();
 
         buildModuleDescription(moduleContentTree);
         buildModuleTags(moduleContentTree);
         buildSummary(moduleContentTree);
 
-        moduleWriter.addModuleContent(contentTree, moduleContentTree);
+        moduleWriter.addModuleContent(moduleContentTree);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -61,11 +61,6 @@
     private final PackageSummaryWriter packageWriter;
 
     /**
-     * The content that will be added to the package summary documentation tree.
-     */
-    private Content contentTree;
-
-    /**
      * Construct a new PackageSummaryBuilder.
      *
      * @param context  the build context.
@@ -107,21 +102,20 @@
             //Doclet does not support this output.
             return;
         }
-        buildPackageDoc(contentTree);
+        buildPackageDoc();
     }
 
     /**
      * Build the package documentation.
      *
-     * @param contentTree the content tree to which the documentation will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildPackageDoc(Content contentTree) throws DocletException {
-        contentTree = packageWriter.getPackageHeader(utils.getPackageName(packageElement));
+    protected void buildPackageDoc() throws DocletException {
+        Content contentTree = packageWriter.getPackageHeader(utils.getPackageName(packageElement));
 
-        buildContent(contentTree);
+        buildContent();
 
-        packageWriter.addPackageFooter(contentTree);
+        packageWriter.addPackageFooter();
         packageWriter.printDocument(contentTree);
         DocFilesHandler docFilesHandler = configuration
                 .getWriterFactory()
@@ -132,18 +126,16 @@
     /**
      * Build the content for the package.
      *
-     * @param contentTree the content tree to which the package contents
-     *                    will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildContent(Content contentTree) throws DocletException {
+    protected void buildContent() throws DocletException {
         Content packageContentTree = packageWriter.getContentHeader();
 
         buildPackageDescription(packageContentTree);
         buildPackageTags(packageContentTree);
         buildSummary(packageContentTree);
 
-        packageWriter.addPackageContent(contentTree, packageContentTree);
+        packageWriter.addPackageContent(packageContentTree);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java	Wed Nov 27 13:08:16 2019 +0100
@@ -96,12 +96,6 @@
     protected Element currentMember;
 
     /**
-     * The content that will be added to the serialized form documentation tree.
-     */
-    private Content contentTree;
-
-
-    /**
      * Construct a new SerializedFormBuilder.
      * @param context  the build context.
      */
@@ -137,32 +131,30 @@
             //Doclet does not support this output.
             return;
         }
-        buildSerializedForm(contentTree);
+        buildSerializedForm();
     }
 
     /**
      * Build the serialized form.
      *
-     * @param serializedTree content tree to which the documentation will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildSerializedForm(Content serializedTree) throws DocletException {
-        serializedTree = writer.getHeader(resources.getText(
+    protected void buildSerializedForm() throws DocletException {
+        Content contentTree = writer.getHeader(resources.getText(
                 "doclet.Serialized_Form"));
 
-        buildSerializedFormSummaries(serializedTree);
+        buildSerializedFormSummaries();
 
-        writer.addFooter(serializedTree);
-        writer.printDocument(serializedTree);
+        writer.addFooter();
+        writer.printDocument(contentTree);
     }
 
     /**
      * Build the serialized form summaries.
      *
-     * @param serializedTree content tree to which the documentation will be added
      * @throws DocletException if there is a problem while building the documentation
      */
-    protected void buildSerializedFormSummaries(Content serializedTree)
+    protected void buildSerializedFormSummaries()
             throws DocletException {
         Content serializedSummariesTree = writer.getSerializedSummariesHeader();
         for (PackageElement pkg : configuration.packages) {
@@ -170,8 +162,7 @@
 
             buildPackageSerializedForm(serializedSummariesTree);
         }
-        serializedTree.add(writer.getSerializedContent(
-                serializedSummariesTree));
+        writer.addSerializedContent(serializedSummariesTree);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Wed Nov 27 13:08:16 2019 +0100
@@ -102,9 +102,6 @@
     if (!tagSearchIndex) {
         createElem(doc, tag, 'tag-search-index.js');
     }
-    $(window).resize(function() {
-        $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
-    });
 }
 
 function createElem(doc, tag, path) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Nov 27 12:18:40 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Nov 27 13:08:16 2019 +0100
@@ -40,13 +40,6 @@
 a[name] {
     color:#353833;
 }
-a[name]:before, a[name]:target, a[id]:before, a[id]:target {
-    content:"";
-    display:inline-block;
-    position:relative;
-    padding-top:129px;
-    margin-top:-129px;
-}
 pre {
     font-family:'DejaVu Sans Mono', monospace;
     font-size:14px;
@@ -131,14 +124,19 @@
 /*
  * Styles for navigation bar.
  */
-.navPadding {
-    padding-top: 107px;
+.flexBox {
+    position:fixed;
+    display:flex;
+    flex-direction:column;
+    height: 100%;
+    width: 100%;
 }
-.fixedNav {
-    position:fixed;
-    width:100%;
-    z-index:999;
-    background-color:#ffffff;
+.flexHeader {
+    flex: 0 0 auto;
+}
+.flexContent {
+    flex: 1 1 auto;
+    overflow-y: auto;
 }
 .topNav {
     background-color:#4D7A97;
@@ -632,7 +630,7 @@
     background-size:12px;
     border:0 none;
     width:16px;
-    height:17px;
+    height:16px;
     position:relative;
     left:-4px;
     top:-4px;
@@ -649,8 +647,8 @@
     font-style:italic;
     font-size:12px;
 }
-.searchTagResult:before, .searchTagResult:target {
-    color:red;
+.searchTagResult:target {
+    background-color:yellow;
 }
 .moduleGraph span {
     display:none;
--- a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Wed Nov 27 13:08:16 2019 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8210047 8199892 8215599
+ * @bug 8210047 8199892 8215599 8223378
  * @summary some pages contains content outside of landmark region
  * @library /tools/lib ../../lib
  * @modules
@@ -74,7 +74,7 @@
         checkExit(Exit.OK);
 
         checkOrder("index.html",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">\n"
@@ -98,7 +98,7 @@
         checkExit(Exit.OK);
 
         checkOrder("index.html",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">\n"
@@ -130,9 +130,10 @@
         checkExit(Exit.OK);
 
         checkOrder("pkg1/doc-files/s.html",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n",
-                "<main role=\"main\">A sample doc file",
+                "<main role=\"main\">\n"
+                + "<div class=\"contentContainer\">A sample doc file",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">"
                 );
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Wed Nov 27 13:08:16 2019 +0100
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819 8183037 8182765 8196202
- *      8202624 8210047 8184205 8221871 8223733
+ *      8202624 8210047 8184205 8221871 8223733 8223378
  * @summary Test the version of HTML generated by the javadoc tool.
  * @author bpatel
  * @library ../../lib
@@ -78,9 +78,8 @@
                 "<div class=\"overviewSummary\">\n"
                 + "<table>\n"
                 + "<caption>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -94,9 +93,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<div class=\"typeSummary\">\n<table>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -124,9 +122,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<li class=\"circle\">",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -150,9 +147,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<div class=\"useSummary\">\n<table>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -168,9 +164,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<div class=\"constantsSummary\">\n<table>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -190,9 +185,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<div class=\"deprecatedSummary\">\n<table>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -207,9 +201,8 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -227,9 +220,8 @@
                 + "<!--   -->\n"
                 + "</a>",
                 "<li class=\"circle\">",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -252,11 +244,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "</header>\n"
+                + "<div class=\"flexContent\">\n"
                 + "<main role=\"main\">",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -275,9 +267,8 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -298,11 +289,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"nestedClassSummary\"><a id=\"nested.class.summary\">\n"
                 + "<!--   -->\n"
@@ -349,11 +340,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"constantsSummary\"><a id=\"enum.constant.summary\">\n"
                 + "<!--   -->\n"
@@ -388,11 +379,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"methodSummary\"><a id=\"method.summary\">\n"
                 + "<!--   -->\n"
@@ -416,11 +407,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"constructorSummary\"><a id=\"constructor.summary\">\n"
                 + "<!--   -->\n"
@@ -442,11 +433,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"constructorSummary\"><a id=\"constructor.summary\">\n"
                 + "<!--   -->\n"
@@ -468,11 +459,11 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
+                + "<!-- ======== START OF CLASS DATA ======== -->\n"
                 + "<div class=\"header\">",
                 "<section class=\"memberSummary\"><a id=\"annotation.type.required.element.summary\">\n"
                 + "<!--   -->\n"
@@ -500,9 +491,8 @@
                 "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<header role=\"banner\">\n"
+                "<header role=\"banner\" class=\"flexHeader\">\n"
                 + "<nav role=\"navigation\">\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
@@ -528,7 +518,6 @@
                 "<table summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption>",
                 "</noscript>\n"
-                + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->");
 
         // Negated test for package-summary page
@@ -574,11 +563,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">",
                 "<div class=\"constantsSummary\">\n"
                 + "<table summary=\"Constant Field Values table, listing constant fields, and values\">");
@@ -592,11 +576,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">\n"
                 + "<h1 title=\"Deprecated API\" class=\"title\">Deprecated API</h1>\n"
                 + "<h2 title=\"Contents\">Contents</h2>",
@@ -620,11 +599,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">",
                 "<li class=\"blockList\">\n"
                 + "<h2 title=\"Package\">Package&nbsp;pkg</h2>");
@@ -638,11 +612,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">",
                 "<div class=\"contentContainer\">\n"
                 + "<h2 title=\"Class Hierarchy\">Class Hierarchy</h2>",
@@ -660,11 +629,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"contentContainer\">");
 
         // Negated test for src-html page
@@ -682,11 +646,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">",
                 "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
@@ -703,8 +662,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- ======== NESTED CLASS SUMMARY ======== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"nested.class.summary\">\n"
@@ -763,8 +720,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- =========== ENUM CONSTANT SUMMARY =========== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"enum.constant.summary\">\n"
@@ -801,8 +756,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- ========== METHOD SUMMARY =========== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"method.summary\">\n"
@@ -825,8 +778,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- ======== CONSTRUCTOR SUMMARY ======== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"constructor.summary\">\n"
@@ -847,8 +798,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- ======== CONSTRUCTOR SUMMARY ======== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"constructor.summary\">\n"
@@ -869,8 +818,6 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<!-- ======== START OF CLASS DATA ======== -->\n"
-                + "<div class=\"header\">",
                 "<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a name=\"annotation.type.required.element.summary\">\n"
@@ -903,11 +850,6 @@
                 + "</a>",
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
                 + "<div class=\"header\">",
                 "<div class=\"useSummary\">\n"
                 + "<table summary=\"Use table, listing packages, and an explanation\">",
--- a/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java	Wed Nov 27 13:08:16 2019 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4665566 4855876 7025314 8012375 8015997 8016328 8024756 8148985 8151921 8151743 8196202
+ * @bug      4665566 4855876 7025314 8012375 8015997 8016328 8024756 8148985 8151921 8151743 8196202 8223378
  * @summary  Verify that the output has the right javascript.
  * @author   jamieh
  * @library  ../../lib
@@ -48,18 +48,18 @@
                 "pkg", testSrc("TestJavascript.java"));
         checkExit(Exit.OK);
 
-        checkOutput("pkg/C.html", true,
+        checkOutput("pkg/C.html", false,
                 "<script type=\"text/javascript\"><!--\n"
                 + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
                 + "//-->\n"
                 + "</script>");
 
-        checkOutput("index.html", true,
+        checkOutput("index.html", false,
                 "<script type=\"text/javascript\"><!--\n"
                 + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
                 + "//-->\n");
 
-        checkOutput("script.js", true,
+        checkOutput("script.js", false,
                 "$(window).resize(function() {\n"
                 + "        $('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
                 + "    });");
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Nov 27 13:08:16 2019 +0100
@@ -27,7 +27,7 @@
  *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
  *      8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464
         8164407 8192007 8182765 8196200 8196201 8196202 8196202 8205593 8202462
-        8184205 8219060
+        8184205 8219060 8223378
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../../lib
@@ -533,6 +533,7 @@
         checkOutput("index.html", found,
                 "</nav>\n"
                 + "</header>\n"
+                + "<div class=\"flexContent\">\n"
                 + "<main role=\"main\">\n"
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
@@ -744,9 +745,9 @@
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
                 + "</tr>\n"
                 + "</thead>",
-                "</script>\n"
-                + "</nav>\n"
+                "</nav>\n"
                 + "</header>\n"
+                + "<div class=\"flexContent\">\n"
                 + "<main role=\"main\">\n"
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
--- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Wed Nov 27 13:08:16 2019 +0100
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug      4131628 4664607 7025314 8023700 7198273 8025633 8026567 8081854 8150188 8151743 8196027 8182765
- *           8196200 8196202
+ *           8196200 8196202 8223378
  * @summary  Make sure the Next/Prev Class links iterate through all types.
  *           Make sure the navagation is 2 columns, not 3.
  * @author   jamieh
@@ -85,26 +85,23 @@
         // Remaining tests check for additional padding to offset the fixed navigation bar.
         checkOutput("pkg/A.html", true,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
-                + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>\n"
                 + "</header>\n"
+                + "<div class=\"flexContent\">\n"
+                + "<main role=\"main\">\n"
                 + "<!-- ======== START OF CLASS DATA ======== -->");
 
         checkOutput("pkg/package-summary.html", true,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
-                + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>\n"
                 + "</header>\n"
+                + "<div class=\"flexContent\">\n"
                 + "<main role=\"main\">\n"
                 + "<div class=\"header\">");
     }
@@ -121,24 +118,20 @@
 
         checkOutput("pkg/A.html", true,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
-                + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>\n"
                 + "</header>\n"
+                + "<div class=\"flexContent\">\n"
+                + "<main role=\"main\">\n"
                 + "<!-- ======== START OF CLASS DATA ======== -->");
 
         checkOutput("pkg/package-summary.html", true,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
-                + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>");
     }
 
@@ -155,11 +148,9 @@
         checkOutput("pkg/A.html", false,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>\n"
                 + "</header>\n"
                 + "<!-- ======== START OF CLASS DATA ======== -->");
@@ -167,11 +158,9 @@
         checkOutput("pkg/package-summary.html", false,
                 "<!-- ========= END OF TOP NAVBAR ========= -->\n"
                 + "</div>\n"
-                + "<div class=\"navPadding\">&nbsp;</div>\n"
-                + "<script type=\"text/javascript\"><!--\n"
-                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
-                + "//-->\n"
-                + "</script>\n"
+                + "<div class=\"skipNav\"><a id=\"skip.navbar.top\">\n"
+                + "<!--   -->\n"
+                + "</a></div>\n"
                 + "</nav>");
     }
 
--- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Wed Nov 27 13:08:16 2019 +0100
@@ -25,7 +25,7 @@
  * @test
  * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
  *      8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202
- *      8184205 8214468 8222548
+ *      8184205 8214468 8222548 8223378
  * @summary Test the search feature of javadoc.
  * @author bpatel
  * @library ../../lib
@@ -385,7 +385,7 @@
                 + "<input type=\"text\" id=\"search\" value=\"search\" disabled=\"disabled\">\n"
                 + "<input type=\"reset\" id=\"reset\" value=\"reset\" disabled=\"disabled\">\n");
         checkOutput(fileName, true,
-                "<div class=\"fixedNav\">");
+                "<div class=\"flexBox\">");
     }
 
     void checkSingleIndex(boolean expectedOutput, boolean html5) {
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js	Wed Nov 27 13:08:16 2019 +0100
@@ -52,29 +52,29 @@
         f();
     } else {
         return {
-            val: function() { 
-                return this; 
+            val: function() {
+                return this;
             },
-            prop: function() { 
-                return this; 
+            prop: function() {
+                return this;
             },
-            addClass: function() { 
-                return this; 
-            },    
-            removeClass: function() { 
-                return this; 
+            addClass: function() {
+                return this;
+            },
+            removeClass: function() {
+                return this;
             },
-            on: function() { 
-                return this; 
+            on: function() {
+                return this;
             },
-            focus: function() { 
-                return this; 
+            focus: function() {
+                return this;
             },
-            blur: function() { 
-                return this; 
+            blur: function() {
+                return this;
             },
-            click: function() { 
-                return this; 
+            click: function() {
+                return this;
             },
             catcomplete: function(o) {
                 o.close = function() {};
@@ -90,11 +90,11 @@
                     return resultList;
                 };
                 for (var i = 0; i < clargs.length; i++) {
-                    search(clargs[i]);  
+                    search(clargs[i]);
                 }
             },
             "0": {
-                setSelectionRange: function() { 
+                setSelectionRange: function() {
                     return this;
                 }
             }
--- a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Wed Nov 27 13:08:16 2019 +0100
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug      4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417
- *           8175218 8176452 8181215 8182263 8183511 8169819 8183037 8185369 8182765 8196201 8184205
+ *           8175218 8176452 8181215 8182263 8183511 8169819 8183037 8185369 8182765 8196201 8184205 8223378
  * @summary  Run tests on doclet stylesheet.
  * @author   jamieh
  * @library  ../../lib
@@ -143,18 +143,8 @@
                 + "    padding:0px 0px 12px 10px;\n"
                 + "}",
                 "@import url('resources/fonts/dejavu.css');",
-                ".navPadding {\n"
-                + "    padding-top: 107px;\n"
-                + "}",
-                "a[name]:before, a[name]:target, a[id]:before, a[id]:target {\n"
-                + "    content:\"\";\n"
-                + "    display:inline-block;\n"
-                + "    position:relative;\n"
-                + "    padding-top:129px;\n"
-                + "    margin-top:-129px;\n"
-                + "}",
-                ".searchTagResult:before, .searchTagResult:target {\n"
-                + "    color:red;\n"
+                ".searchTagResult:target {\n"
+                + "    background-color:yellow;\n"
                 + "}",
                 "a[href]:hover, a[href]:focus {\n"
                 + "    text-decoration:none;\n"
@@ -190,7 +180,7 @@
                 + "    background-size:12px;\n"
                 + "    border:0 none;\n"
                 + "    width:16px;\n"
-                + "    height:17px;\n"
+                + "    height:16px;\n"
                 + "    position:relative;\n"
                 + "    left:-4px;\n"
                 + "    top:-4px;\n"
--- a/test/langtools/jdk/javadoc/doclet/testTopOption/TestTopOption.java	Wed Nov 27 12:18:40 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testTopOption/TestTopOption.java	Wed Nov 27 13:08:16 2019 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      6227616 8043186 8196202
+ * @bug      6227616 8043186 8196202 8223378
  * @summary  Test the new -top option.
  * @author   jamieh
  * @library  ../../lib
@@ -87,6 +87,30 @@
                 "help-doc.html");
     }
 
+    @Test
+    public void testNoNavbar() {
+        javadoc("-overview", testSrc("overview.html"),
+                "-use",
+                "-top", "TOP TEXT",
+                "-nonavbar",
+                "-d", "out-3",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkTopText(
+                "pkg/AnnotationType.html",
+                "pkg/class-use/AnnotationType.html",
+                "pkg/Cl.html",
+                "pkg/class-use/Cl.html",
+                "pkg/package-summary.html",
+                "pkg/package-use.html",
+                "index.html",
+                "overview-tree.html",
+                "constant-values.html",
+                "help-doc.html");
+    }
+
     void checkTopText(String... files) {
         for (String file : files) {
             checkOutput(file, true, "TOP TEXT");