From 08cecbdc20f901b820acc714850f9835c494ddb8 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 15 May 2020 17:04:29 +0000 Subject: [PATCH] Bug 1634051 - don't eagerly initialize the all tabs menu, r=mstriemer The initialization costs of the TabList constructors is very small compared to the cost of actually calling _populate, so instead of calling init() from an idle task, we can just wait until the view actually needs to be shown. Differential Revision: https://phabricator.services.mozilla.com/D73946 --- .../content/browser-allTabsMenu.inc.xhtml | 87 +++++++++---------- browser/base/content/browser-allTabsMenu.js | 7 +- browser/base/content/browser.js | 5 -- .../browser/browser_favicon_firstParty.js | 2 + .../browser/browser_favicon_userContextId.js | 2 + 5 files changed, 48 insertions(+), 55 deletions(-) diff --git a/browser/base/content/browser-allTabsMenu.inc.xhtml b/browser/base/content/browser-allTabsMenu.inc.xhtml index 9df828d0d7a8..4b11260fea95 100644 --- a/browser/base/content/browser-allTabsMenu.inc.xhtml +++ b/browser/base/content/browser-allTabsMenu.inc.xhtml @@ -2,53 +2,44 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - + + + + + + + diff --git a/browser/base/content/browser-allTabsMenu.js b/browser/base/content/browser-allTabsMenu.js index 5f39f2d3a0fa..d43081e5dd2a 100644 --- a/browser/base/content/browser-allTabsMenu.js +++ b/browser/base/content/browser-allTabsMenu.js @@ -27,6 +27,8 @@ var gTabsPanel = { if (this._initializedElements) { return; } + let template = document.getElementById("allTabsMenu-container"); + template.replaceWith(template.content); for (let [name, id] of Object.entries(this.kElements)) { this[name] = document.getElementById(id); @@ -147,8 +149,9 @@ var gTabsPanel = { }, hideAllTabsPanel() { - this.init(); - PanelMultiView.hidePopup(this.allTabsView.closest("panel")); + if (this.allTabsView) { + PanelMultiView.hidePopup(this.allTabsView.closest("panel")); + } }, showHiddenTabsPanel(event) { diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 569177a9e9b2..31c687d447bf 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2269,11 +2269,6 @@ var gBrowserInit = { gSync.init(); }); - scheduleIdleTask(() => { - // Initialize the all tabs menu - gTabsPanel.init(); - }); - scheduleIdleTask(() => { // Read prefers-reduced-motion setting let reduceMotionQuery = window.matchMedia( diff --git a/browser/components/originattributes/test/browser/browser_favicon_firstParty.js b/browser/components/originattributes/test/browser/browser_favicon_firstParty.js index 709ff2b4228f..f6a95139b178 100644 --- a/browser/components/originattributes/test/browser/browser_favicon_firstParty.js +++ b/browser/components/originattributes/test/browser/browser_favicon_firstParty.js @@ -320,6 +320,8 @@ async function doTestForAllTabsFavicon( assertIconIsData(tabInfo.tab); + gTabsPanel.init(); + // Make the popup of allTabs showing up and trigger the loading of the favicon. let allTabsView = document.getElementById("allTabsMenu-allTabsView"); let allTabsPopupShownPromise = BrowserTestUtils.waitForEvent( diff --git a/browser/components/originattributes/test/browser/browser_favicon_userContextId.js b/browser/components/originattributes/test/browser/browser_favicon_userContextId.js index 77267c56e9bd..63d8cb190f5e 100644 --- a/browser/components/originattributes/test/browser/browser_favicon_userContextId.js +++ b/browser/components/originattributes/test/browser/browser_favicon_userContextId.js @@ -266,6 +266,8 @@ async function doTestForAllTabsFavicon(aTestPage, aFaviconHost, aFaviconURL) { // be made for the favicon of allTabs menuitem. clearAllImageCaches(); + gTabsPanel.init(); + // Make the popup of allTabs showing up and trigger the loading of the favicon. let allTabsView = document.getElementById("allTabsMenu-allTabsView"); let allTabsPopupShownPromise = BrowserTestUtils.waitForEvent(