Bug 1382170 - Only run gSearchResultsPane.initializeCategories() when search is used for the first time, r=jaws
This shuffled what
bug 1374852 did a little bit; instead of initialize all panes
when the page loads, the call will happen inside an idle callback.
An the event listener is added to ensure that even if idle callback doesn't run
soon enough, the function is run already when the user starts search.
MozReview-Commit-ID: LU4Nb8lql36
--- a/browser/components/preferences/in-content-new/findInPage.js
+++ b/browser/components/preferences/in-content-new/findInPage.js
@@ -14,31 +14,32 @@ var gSearchResultsPane = {
if (this.inited) {
return;
}
this.inited = true;
this.searchInput = document.getElementById("searchInput");
this.searchInput.hidden = !Services.prefs.getBoolPref("browser.preferences.search");
if (!this.searchInput.hidden) {
this.searchInput.addEventListener("command", this);
- window.addEventListener("load", () => {
+ window.addEventListener("DOMContentLoaded", () => {
this.searchInput.focus();
- this.initializeCategories();
});
+ // Initialize other panes in an idle callback.
+ window.requestIdleCallback(() => this.initializeCategories());
}
let strings = this.strings;
this.searchInput.placeholder = AppConstants.platform == "win" ?
strings.getString("searchInput.labelWin") :
strings.getString("searchInput.labelUnix");
},
handleEvent(event) {
- if (event.type === "command") {
- this.searchFunction(event);
- }
+ // Ensure categories are initialized if idle callback didn't run sooo enough.
+ this.initializeCategories();
+ this.searchFunction(event);
},
/**
* Check that the passed string matches the filter arguments.
*
* @param String str
* to search for filter words in.
* @param String filter