Skip to content

Commit 7957658

Browse files
psoujanyRealCLanger
authored andcommitted
8210047: some pages contain content outside of landmark region
Reviewed-by: clanger Backport-of: a17816f
1 parent bcdcc9f commit 7957658

File tree

12 files changed

+411
-224
lines changed

12 files changed

+411
-224
lines changed

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.lang.model.element.ModuleElement;
3434
import javax.lang.model.element.PackageElement;
3535

36+
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
3637
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
3738
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
3839
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -81,42 +82,42 @@ public AbstractModuleIndexWriter(HtmlConfiguration configuration,
8182
/**
8283
* Adds the navigation bar header to the documentation tree.
8384
*
84-
* @param body the document tree to which the navigation bar header will be added
85+
* @param header the document tree to which the navigation bar header will be added
8586
*/
86-
protected abstract void addNavigationBarHeader(Content body);
87+
protected abstract void addNavigationBarHeader(Content header);
8788

8889
/**
8990
* Adds the navigation bar footer to the documentation tree.
9091
*
91-
* @param body the document tree to which the navigation bar footer will be added
92+
* @param footer the document tree to which the navigation bar footer will be added
9293
*/
93-
protected abstract void addNavigationBarFooter(Content body);
94+
protected abstract void addNavigationBarFooter(Content footer);
9495

9596
/**
9697
* Adds the overview header to the documentation tree.
9798
*
98-
* @param body the document tree to which the overview header will be added
99+
* @param main the document tree to which the overview header will be added
99100
*/
100-
protected abstract void addOverviewHeader(Content body);
101+
protected abstract void addOverviewHeader(Content main);
101102

102103
/**
103104
* Adds the modules list to the documentation tree.
104105
*
105-
* @param body the document tree to which the modules list will be added
106+
* @param main the document tree to which the modules list will be added
106107
*/
107-
protected abstract void addModulesList(Content body);
108+
protected abstract void addModulesList(Content main);
108109

109110
/**
110111
* Adds the module packages list to the documentation tree.
111112
*
112113
* @param modules the set of modules
113114
* @param text caption for the table
114115
* @param tableSummary summary for the table
115-
* @param body the document tree to which the modules list will be added
116+
* @param main the document tree to which the modules list will be added
116117
* @param mdle the module being documented
117118
*/
118119
protected abstract void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
119-
String tableSummary, Content body, ModuleElement mdle);
120+
String tableSummary, Content main, ModuleElement mdle);
120121

121122
/**
122123
* Generate and prints the contents in the module index file. Call appropriate
@@ -130,11 +131,17 @@ protected abstract void addModulePackagesList(Map<ModuleElement, Set<PackageElem
130131
protected void buildModuleIndexFile(String title, boolean includeScript) throws DocFileIOException {
131132
String windowOverview = configuration.getText(title);
132133
Content body = getBody(includeScript, getWindowTitle(windowOverview));
133-
addNavigationBarHeader(body);
134-
addOverviewHeader(body);
135-
addIndex(body);
136-
addOverview(body);
137-
addNavigationBarFooter(body);
134+
Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
135+
addNavigationBarHeader(header);
136+
Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
137+
addOverviewHeader(main);
138+
addIndex(header, main);
139+
addOverview(main);
140+
Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
141+
addNavigationBarFooter(footer);
142+
body.addContent(header);
143+
body.addContent(main);
144+
body.addContent(footer);
138145
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
139146
configuration.doctitle), includeScript, body);
140147
}
@@ -153,45 +160,53 @@ protected void buildModulePackagesIndexFile(String title,
153160
boolean includeScript, ModuleElement mdle) throws DocFileIOException {
154161
String windowOverview = configuration.getText(title);
155162
Content body = getBody(includeScript, getWindowTitle(windowOverview));
156-
addNavigationBarHeader(body);
157-
addOverviewHeader(body);
158-
addModulePackagesIndex(body, mdle);
159-
addOverview(body);
160-
addNavigationBarFooter(body);
163+
Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
164+
addNavigationBarHeader(header);
165+
Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
166+
addOverviewHeader(main);
167+
addModulePackagesIndex(header, main, mdle);
168+
addOverview(main);
169+
Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
170+
addNavigationBarFooter(footer);
171+
body.addContent(header);
172+
body.addContent(main);
173+
body.addContent(footer);
161174
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
162175
configuration.doctitle), includeScript, body);
163176
}
164177

165178
/**
166179
* Default to no overview, override to add overview.
167180
*
168-
* @param body the document tree to which the overview will be added
181+
* @param main the document tree to which the overview will be added
169182
*/
170-
protected void addOverview(Content body) { }
183+
protected void addOverview(Content main) { }
171184

172185
/**
173186
* Adds the frame or non-frame module index to the documentation tree.
174187
*
175-
* @param body the document tree to which the index will be added
188+
* @param header the document tree to which the navigational links will be added
189+
* @param main the document tree to which the modules list will be added
176190
*/
177-
protected void addIndex(Content body) {
191+
protected void addIndex(Content header, Content main) {
178192
addIndexContents(configuration.modules, "doclet.Module_Summary",
179193
configuration.getText("doclet.Member_Table_Summary",
180194
configuration.getText("doclet.Module_Summary"),
181-
configuration.getText("doclet.modules")), body);
195+
configuration.getText("doclet.modules")), header, main);
182196
}
183197

184198
/**
185199
* Adds the frame or non-frame module packages index to the documentation tree.
186200
*
187-
* @param body the document tree to which the index will be added
201+
* @param header the document tree to which the navigational links will be added
202+
* @param main the document tree to which the module packages list will be added
188203
* @param mdle the module being documented
189204
*/
190-
protected void addModulePackagesIndex(Content body, ModuleElement mdle) {
205+
protected void addModulePackagesIndex(Content header, Content main, ModuleElement mdle) {
191206
addModulePackagesIndexContents("doclet.Module_Summary",
192207
configuration.getText("doclet.Member_Table_Summary",
193208
configuration.getText("doclet.Module_Summary"),
194-
configuration.getText("doclet.modules")), body, mdle);
209+
configuration.getText("doclet.modules")), header, main, mdle);
195210
}
196211

197212
/**
@@ -201,20 +216,19 @@ protected void addModulePackagesIndex(Content body, ModuleElement mdle) {
201216
* @param modules the modules to be documented
202217
* @param text string which will be used as the heading
203218
* @param tableSummary summary for the table
204-
* @param body the document tree to which the index contents will be added
219+
* @param header the document tree to which the navgational links will be added
220+
* @param main the document tree to which the modules list will be added
205221
*/
206222
protected void addIndexContents(Collection<ModuleElement> modules, String text,
207-
String tableSummary, Content body) {
208-
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
209-
? HtmlTree.NAV()
210-
: new HtmlTree(HtmlTag.DIV);
223+
String tableSummary, Content header, Content main) {
224+
HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
211225
htmlTree.setStyle(HtmlStyle.indexNav);
212226
HtmlTree ul = new HtmlTree(HtmlTag.UL);
213227
addAllClassesLink(ul);
214228
addAllPackagesLink(ul);
215229
htmlTree.addContent(ul);
216-
body.addContent(htmlTree);
217-
addModulesList(body);
230+
header.addContent(htmlTree);
231+
addModulesList(main);
218232
}
219233

220234
/**
@@ -223,22 +237,21 @@ protected void addIndexContents(Collection<ModuleElement> modules, String text,
223237
*
224238
* @param text string which will be used as the heading
225239
* @param tableSummary summary for the table
226-
* @param body the document tree to which the index contents will be added
240+
* @param header the document tree to which the navigational links will be added
241+
* @param main the document tree to which the module packages list will be added
227242
* @param mdle the module being documented
228243
*/
229244
protected void addModulePackagesIndexContents(String text,
230-
String tableSummary, Content body, ModuleElement mdle) {
231-
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
232-
? HtmlTree.NAV()
233-
: new HtmlTree(HtmlTag.DIV);
245+
String tableSummary, Content header, Content main, ModuleElement mdle) {
246+
HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
234247
htmlTree.setStyle(HtmlStyle.indexNav);
235248
HtmlTree ul = new HtmlTree(HtmlTag.UL);
236249
addAllClassesLink(ul);
237250
addAllPackagesLink(ul);
238251
addAllModulesLink(ul);
239252
htmlTree.addContent(ul);
240-
body.addContent(htmlTree);
241-
addModulePackagesList(modules, text, tableSummary, body, mdle);
253+
header.addContent(htmlTree);
254+
addModulePackagesList(modules, text, tableSummary, main, mdle);
242255
}
243256

244257
/**

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import javax.lang.model.element.PackageElement;
3131

32+
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
3233
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
3334
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
3435
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -78,9 +79,9 @@ public AbstractPackageIndexWriter(HtmlConfiguration configuration,
7879
/**
7980
* Adds the navigation bar header to the documentation tree.
8081
*
81-
* @param body the document tree to which the navigation bar header will be added
82+
* @param header the document tree to which the navigation bar header will be added
8283
*/
83-
protected abstract void addNavigationBarHeader(Content body);
84+
protected abstract void addNavigationBarHeader(Content header);
8485

8586
/**
8687
* Adds the navigation bar footer to the documentation tree.
@@ -92,16 +93,16 @@ public AbstractPackageIndexWriter(HtmlConfiguration configuration,
9293
/**
9394
* Adds the overview header to the documentation tree.
9495
*
95-
* @param body the document tree to which the overview header will be added
96+
* @param footer the document tree to which the overview header will be added
9697
*/
97-
protected abstract void addOverviewHeader(Content body);
98+
protected abstract void addOverviewHeader(Content footer);
9899

99100
/**
100101
* Adds the packages list to the documentation tree.
101102
*
102-
* @param body the document tree to which the packages list will be added
103+
* @param main the document tree to which the packages list will be added
103104
*/
104-
protected abstract void addPackagesList(Content body);
105+
protected abstract void addPackagesList(Content main);
105106

106107
/**
107108
* Generate and prints the contents in the package index file. Call appropriate
@@ -115,51 +116,57 @@ public AbstractPackageIndexWriter(HtmlConfiguration configuration,
115116
protected void buildPackageIndexFile(String title, boolean includeScript) throws DocFileIOException {
116117
String windowOverview = configuration.getText(title);
117118
Content body = getBody(includeScript, getWindowTitle(windowOverview));
118-
addNavigationBarHeader(body);
119-
addOverviewHeader(body);
120-
addIndex(body);
121-
addOverview(body);
122-
addNavigationBarFooter(body);
119+
Content header = createTagIfAllowed(HtmlTag.HEADER, HtmlTree::HEADER, ContentBuilder::new);
120+
addNavigationBarHeader(header);
121+
Content main = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
122+
addOverviewHeader(main);
123+
addIndex(header, main);
124+
addOverview(main);
125+
Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new);
126+
addNavigationBarFooter(footer);
127+
body.addContent(header);
128+
body.addContent(main);
129+
body.addContent(footer);
123130
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
124131
configuration.doctitle), includeScript, body);
125132
}
126133

127134
/**
128135
* Default to no overview, override to add overview.
129136
*
130-
* @param body the document tree to which the overview will be added
137+
* @param main the document tree to which the overview will be added
131138
*/
132-
protected void addOverview(Content body) { }
139+
protected void addOverview(Content main) { }
133140

134141
/**
135142
* Adds the frame or non-frame package index to the documentation tree.
136143
*
137-
* @param body the document tree to which the index will be added
144+
* @param header the document tree to which the navigation links will be added
145+
* @param main the document tree to which the packages list will be added
138146
*/
139-
protected void addIndex(Content body) {
140-
addIndexContents(body);
147+
protected void addIndex(Content header, Content main) {
148+
addIndexContents(header, main);
141149
}
142150

143151
/**
144152
* Adds package index contents. Call appropriate methods from
145153
* the sub-classes. Adds it to the body HtmlTree
146154
*
147-
* @param body the document tree to which the index contents will be added
155+
* @param header the document tree to which navigation links will be added
156+
* @param main the document tree to which the packages list will be added
148157
*/
149-
protected void addIndexContents(Content body) {
158+
protected void addIndexContents(Content header, Content main) {
150159
if (!packages.isEmpty()) {
151-
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
152-
? HtmlTree.NAV()
153-
: new HtmlTree(HtmlTag.DIV);
160+
HtmlTree htmlTree = (HtmlTree)createTagIfAllowed(HtmlTag.NAV, HtmlTree::NAV, () -> new HtmlTree(HtmlTag.DIV));
154161
htmlTree.setStyle(HtmlStyle.indexNav);
155162
HtmlTree ul = new HtmlTree(HtmlTag.UL);
156163
addAllClassesLink(ul);
157164
if (configuration.showModules && configuration.modules.size() > 1) {
158165
addAllModulesLink(ul);
159166
}
160167
htmlTree.addContent(ul);
161-
body.addContent(htmlTree);
162-
addPackagesList(body);
168+
header.addContent(htmlTree);
169+
addPackagesList(main);
163170
}
164171
}
165172

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import javax.lang.model.element.Element;
3030
import javax.lang.model.element.TypeElement;
3131

32+
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
3233
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
3334
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
3435
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -114,15 +115,15 @@ private static void generate(HtmlConfiguration configuration, IndexBuilder index
114115
protected void buildAllClassesFile(boolean wantFrames) throws DocFileIOException {
115116
String label = configuration.getText("doclet.All_Classes");
116117
Content body = getBody(false, getWindowTitle(label));
118+
Content htmlTree = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new);
117119
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
118120
HtmlStyle.bar, contents.allClassesLabel);
119-
body.addContent(heading);
121+
htmlTree.addContent(heading);
120122
Content ul = new HtmlTree(HtmlTag.UL);
121123
// Generate the class links and add it to the tdFont tree.
122124
addAllClasses(ul, wantFrames);
123-
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
124-
? HtmlTree.MAIN(HtmlStyle.indexContainer, ul)
125-
: HtmlTree.DIV(HtmlStyle.indexContainer, ul);
125+
HtmlTree div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
126+
htmlTree.addContent(div);
126127
body.addContent(htmlTree);
127128
printHtmlDocument(null, false, body);
128129
}

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
3030

3131
import java.util.*;
32+
import java.util.function.Supplier;
3233
import java.util.regex.Matcher;
3334
import java.util.regex.Pattern;
3435

@@ -2093,4 +2094,20 @@ public HtmlTree getBody(boolean includeScript, String title) {
20932094
Script getMainBodyScript() {
20942095
return mainBodyScript;
20952096
}
2097+
2098+
/**
2099+
* Creates the HTML tag if the tag is supported by this specific HTML version
2100+
* otherwise return the Content instance provided by Supplier ifNotSupported.
2101+
* @param tag the HTML tag
2102+
* @param ifSupported create this instance if HTML tag is supported
2103+
* @param ifNotSupported create this instance if HTML tag is not supported
2104+
* @return
2105+
*/
2106+
protected Content createTagIfAllowed(HtmlTag tag, Supplier<Content> ifSupported, Supplier<Content> ifNotSupported) {
2107+
if (configuration.allowTag(tag)) {
2108+
return ifSupported.get();
2109+
} else {
2110+
return ifNotSupported.get();
2111+
}
2112+
}
20962113
}

0 commit comments

Comments
 (0)