Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 7dc952e

Browse files
committedMar 23, 2020
8241292: Interactive Search results are not highlighted as they used to be
Reviewed-by: prappo
1 parent 81353a5 commit 7dc952e

File tree

2 files changed

+36
-6
lines changed
  • src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources
  • test/langtools/jdk/javadoc/doclet/testSearch

2 files changed

+36
-6
lines changed
 

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var catPackages = "Packages";
2929
var catTypes = "Types";
3030
var catMembers = "Members";
3131
var catSearchTags = "SearchTags";
32-
var highlight = "<span class=\"resultHighlight\">$&</span>";
32+
var highlight = "<span class=\"result-highlight\">$&</span>";
3333
var searchPattern = "";
3434
var RANKING_THRESHOLD = 2;
3535
var NO_MATCH = 0xffff;
@@ -128,10 +128,10 @@ $.widget("custom.catcomplete", $.ui.autocomplete, {
128128
li = rMenu._renderItemData(ul, item);
129129
if (item.category) {
130130
li.attr("aria-label", item.category + " : " + item.l);
131-
li.attr("class", "resultItem");
131+
li.attr("class", "result-item");
132132
} else {
133133
li.attr("aria-label", item.l);
134-
li.attr("class", "resultItem");
134+
li.attr("class", "result-item");
135135
}
136136
});
137137
},
@@ -159,10 +159,10 @@ $.widget("custom.catcomplete", $.ui.autocomplete, {
159159
var div = $("<div/>").appendTo(li);
160160
if (item.category === catSearchTags) {
161161
if (item.d) {
162-
div.html(label + "<span class=\"searchTagHolderResult\"> (" + item.h + ")</span><br><span class=\"searchTagDescResult\">"
162+
div.html(label + "<span class=\"search-tag-holder-result\"> (" + item.h + ")</span><br><span class=\"search-tag-desc-result\">"
163163
+ item.d + "</span><br>");
164164
} else {
165-
div.html(label + "<span class=\"searchTagHolderResult\"> (" + item.h + ")</span>");
165+
div.html(label + "<span class=\"search-tag-holder-result\"> (" + item.h + ")</span>");
166166
}
167167
} else {
168168
div.html(label);

‎test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @test
2626
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
2727
* 8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202
28-
* 8184205 8214468 8222548 8223378 8234746
28+
* 8184205 8214468 8222548 8223378 8234746 8241219
2929
* @summary Test the search feature of javadoc.
3030
* @library ../../lib
3131
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -34,6 +34,10 @@
3434
*/
3535

3636
import java.util.Locale;
37+
import java.util.Set;
38+
import java.util.TreeSet;
39+
import java.util.regex.Matcher;
40+
import java.util.regex.Pattern;
3741

3842
import javadoc.tester.JavadocTester;
3943

@@ -623,6 +627,32 @@ void checkSearchJS() {
623627
+ " return urlPrefix;\n"
624628
+ "}",
625629
"url += ui.item.l;");
630+
631+
checkCssClasses("search.js", "stylesheet.css");
632+
}
633+
634+
void checkCssClasses(String jsFile, String cssFile) {
635+
// Check that all CSS class names mentioned in the JavaScript file
636+
// are also defined as class selectors somewhere in the stylesheet file.
637+
String js = readOutputFile(jsFile);
638+
Set<String> cssClasses = new TreeSet<>();
639+
addMatches(js, Pattern.compile("class=\\\\*\"([^\\\\\"]+)\\\\*\""), cssClasses);
640+
addMatches(js, Pattern.compile("attr\\(\"class\", \"([^\"]+)\"\\)"), cssClasses);
641+
// verify that the regex did find use of CSS class names
642+
checking("Checking CSS classes found");
643+
if (cssClasses.isEmpty()) {
644+
failed("no CSS classes found");
645+
} else {
646+
passed(cssClasses.size() + " found: " + cssClasses);
647+
}
648+
checkOutput(cssFile, true, cssClasses.toArray(new String[0]));
649+
}
650+
651+
void addMatches(String js, Pattern p, Set<String> cssClasses) {
652+
Matcher m = p.matcher(js);
653+
while (m.find()) {
654+
cssClasses.add("." + m.group(1));
655+
}
626656
}
627657

628658
void checkSingleIndexSearchTagDuplication() {

0 commit comments

Comments
 (0)