Revert "feat: Improved startup performance and flashes, p=#10588, c=common, t…" (#10604)

This commit is contained in:
mr. m
2025-09-28 16:06:17 +02:00
committed by GitHub
parent b0d0a79fc5
commit 88f26d8829
5 changed files with 68 additions and 92 deletions

View File

@@ -1,30 +0,0 @@
# nsBrowserGlue.js
# This component must restrict its registration for the app-startup category
# to the specific list of apps that use it so it doesn't get loaded in xpcshell.
# Thus we restrict it to these apps:
#
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
#
# The first rule of running code during startup is: don't.
#
# We take performance very seriously and ideally your component/feature should
# initialize only when needed.
#
# If you have established that you really must run code during startup,
# available entrypoints are:
#
# - registering a `browser-idle-startup` category entry for your JS module (or
# even a "best effort" user idle task, see `BrowserGlue.sys.mjs`)
# - registering a `browser-window-delayed-startup` category entry for your JS
# module. **Note that this is invoked for each browser window.**
# - registering a `browser-before-ui-startup` category entry if you really really
# need to. This will run code before the first browser window appears on the
# screen and make Firefox seem slow, so please don't do it unless absolutely
# necessary.
#ifdef XP_UNIX
#ifndef XP_MACOSX
#define UNIX_BUT_NOT_MAC
#endif
#endif

View File

@@ -2,25 +2,22 @@
// 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/.
{
class ZenStartupManager {
var gZenStartup = new (class {
#watermarkIgnoreElements = ['zen-toast-container'];
#hasInitializedLayout = false;
isReady = false;
constructor() {
gZenWorkspaces.init();
window.addEventListener(
'MozBeforeInitialXULLayout',
() => {
this.openWatermark();
this.#zenInitBrowserLayout();
this.#initBrowserBackground();
this.#changeSidebarLocation();
},
{ once: true }
);
async init() {
// important: We do this to ensure that some firefox components
// are initialized before we start our own initialization.
// please, do not remove this line and if you do, make sure to
// test the startup process.
await new Promise((resolve) => setTimeout(resolve, 0));
this.openWatermark();
this.#initBrowserBackground();
this.#changeSidebarLocation();
this.#zenInitBrowserLayout();
}
#initBrowserBackground() {
@@ -60,6 +57,7 @@
document.getElementById('zen-appcontent-wrapper').prepend(deckTemplate);
}
gZenWorkspaces.init();
setTimeout(() => {
gZenUIManager.init();
this.#checkForWelcomePage();
@@ -225,7 +223,13 @@
});
});
}
}
})();
window.gZenStartup = new ZenStartupManager();
window.addEventListener(
'MozBeforeInitialXULLayout',
() => {
gZenStartup.init();
},
{ once: true }
);
}

View File

@@ -10,7 +10,3 @@ DIRS += [
"urlbar",
"toolkit",
]
EXTRA_PP_COMPONENTS += [
"ZenComponents.manifest",
]

View File

@@ -418,13 +418,13 @@
overflow-y: auto;
height: 100%;
:root[zen-sidebar-expanded='true'] & {
:root[zen-workspace-id][zen-sidebar-expanded='true'] & {
margin-left: calc(-1 * var(--zen-toolbox-padding));
width: calc(100% + var(--zen-toolbox-padding) * 2);
}
}
#pinned-tabs-container {
:root[zen-workspace-id] #pinned-tabs-container {
display: none;
}

View File

@@ -51,7 +51,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
await Promise.all([this.promiseDBInitialized, this.promisePinnedInitialized]);
}
init() {
async init() {
// Initialize tab selection state
this._tabSelectionState = {
inProgress: false,
@@ -118,8 +118,12 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
this.popupOpenHandler = this._popupOpenHandler.bind(this);
window.addEventListener('resize', this.onWindowResize.bind(this));
this.addPopupListeners();
this.afterLoadInit();
await this.#waitForPromises();
await this._workspaces();
await this.afterLoadInit();
}
log(...args) {
@@ -132,13 +136,11 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
if (!this._hasInitializedTabsStrip) {
await this.delayedStartup();
}
this.#initializeWorkspaceTabContextMenus();
this._initializeWorkspaceTabContextMenus();
await this.initializeWorkspaces();
await this.promiseSectionsInitialized;
// Non UI related initializations
this.addPopupListeners();
if (
Services.prefs.getBoolPref('zen.workspaces.swipe-actions', false) &&
this.workspaceEnabled &&
@@ -309,7 +311,6 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
}
async _createDefaultWorkspaceIfNeeded() {
await this.#waitForPromises();
const workspaces = await this._workspaces();
if (!workspaces.workspaces.length) {
await this.createAndSaveWorkspace('Space', null, true);
@@ -400,42 +401,46 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
async initializeTabsStripSections() {
await SessionStore.promiseInitialized;
await SessionStore.promiseAllWindowsRestored;
await gZenSessionStore.promiseInitialized;
const perifery = document.getElementById('tabbrowser-arrowscrollbox-periphery');
perifery.setAttribute('hidden', 'true');
const tabs = gBrowser.tabContainer.allTabs;
const workspaces = await this._workspaces();
for (const workspace of workspaces.workspaces) {
await this._createWorkspaceTabsSection(workspace, tabs);
}
if (tabs.length) {
const defaultSelectedContainer = this.workspaceElement(this.activeWorkspace)?.querySelector(
'.zen-workspace-normal-tabs-section'
);
const pinnedContainer = this.workspaceElement(this.activeWorkspace).querySelector(
'.zen-workspace-pinned-tabs-section'
);
// New profile with no workspaces does not have a default selected container
if (defaultSelectedContainer) {
for (const tab of tabs) {
if (tab.hasAttribute('zen-essential')) {
this.getEssentialsSection(tab).appendChild(tab);
continue;
} else if (tab.pinned) {
pinnedContainer.insertBefore(tab, pinnedContainer.lastChild);
continue;
}
// before to the last child (perifery)
defaultSelectedContainer.insertBefore(tab, defaultSelectedContainer.lastChild);
await new Promise((resolve) => {
setTimeout(async () => {
const tabs = gBrowser.tabContainer.allTabs;
const workspaces = await this._workspaces();
for (const workspace of workspaces.workspaces) {
await this._createWorkspaceTabsSection(workspace, tabs);
}
}
gBrowser.tabContainer._invalidateCachedTabs();
}
perifery.setAttribute('hidden', 'true');
this._hasInitializedTabsStrip = true;
this.registerPinnedResizeObserver();
this._fixIndicatorsNames(workspaces);
this._resolveSectionsInitialized();
if (tabs.length) {
const defaultSelectedContainer = this.workspaceElement(
this.activeWorkspace
)?.querySelector('.zen-workspace-normal-tabs-section');
const pinnedContainer = this.workspaceElement(this.activeWorkspace).querySelector(
'.zen-workspace-pinned-tabs-section'
);
// New profile with no workspaces does not have a default selected container
if (defaultSelectedContainer) {
for (const tab of tabs) {
if (tab.hasAttribute('zen-essential')) {
this.getEssentialsSection(tab).appendChild(tab);
continue;
} else if (tab.pinned) {
pinnedContainer.insertBefore(tab, pinnedContainer.lastChild);
continue;
}
// before to the last child (perifery)
defaultSelectedContainer.insertBefore(tab, defaultSelectedContainer.lastChild);
}
}
gBrowser.tabContainer._invalidateCachedTabs();
}
perifery.setAttribute('hidden', 'true');
this._hasInitializedTabsStrip = true;
this.registerPinnedResizeObserver();
this._fixIndicatorsNames(workspaces);
this._resolveSectionsInitialized();
resolve();
}, 0);
});
}
getEssentialsSection(container = 0) {
@@ -915,6 +920,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
async initializeWorkspaces() {
let activeWorkspace = await this.getActiveWorkspace();
this.activeWorkspace = activeWorkspace?.uuid;
await gZenSessionStore.promiseInitialized;
try {
if (activeWorkspace) {
window.gZenThemePicker = new nsZenThemePicker();
@@ -2654,7 +2660,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
await this.changeWorkspace(nextWorkspace, { whileScrolling });
}
#initializeWorkspaceTabContextMenus() {
_initializeWorkspaceTabContextMenus() {
if (this.privateWindowOrDisabled) {
const commandsToDisable = [
'cmd_zenOpenFolderCreation',