From fd82ad95b7c39c9eede9735d5cc8876ab5674d6c Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Mon, 12 Jan 2026 11:49:21 +0100 Subject: [PATCH] perf: Further optimize having to reflush the document on space switch, b=bug #11851, c=split-view, workspaces --- src/zen/split-view/ZenViewSplitter.mjs | 12 +++---- src/zen/workspaces/ZenWorkspaces.mjs | 45 ++++---------------------- 2 files changed, 13 insertions(+), 44 deletions(-) diff --git a/src/zen/split-view/ZenViewSplitter.mjs b/src/zen/split-view/ZenViewSplitter.mjs index 89a07a283..51afb6a61 100644 --- a/src/zen/split-view/ZenViewSplitter.mjs +++ b/src/zen/split-view/ZenViewSplitter.mjs @@ -1688,17 +1688,17 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature { }; _maybeRemoveFakeBrowser(select = true) { - gBrowser.tabbox.removeAttribute('style'); - this.tabBrowserPanel.removeAttribute('dragging-split'); - const tabboxAnimations = document.getElementById('tabbrowser-tabbox').getAnimations(); - if (tabboxAnimations.length > 0) { - tabboxAnimations.forEach((a) => a.cancel()); - } if (this._dndElement) { this._dndElement.remove(); delete this._dndElement; } if (this.fakeBrowser) { + gBrowser.tabbox.removeAttribute('style'); + this.tabBrowserPanel.removeAttribute('dragging-split'); + const tabboxAnimations = document.getElementById('tabbrowser-tabbox').getAnimations(); + if (tabboxAnimations.length > 0) { + tabboxAnimations.forEach((a) => a.cancel()); + } delete this._hasAnimated; this.fakeBrowser.remove(); this.fakeBrowser = null; diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 9b51fa5f2..ee7ca465f 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -1668,12 +1668,7 @@ class nsZenWorkspaces { } } - #updatePaddingTopOnTabs( - workspaceElement, - essentialContainer, - forAnimation = false, - animateContainer = false - ) { + #updatePaddingTopOnTabs(workspaceElement, essentialContainer, forAnimation = false) { if ( workspaceElement && !(this.#inChangingWorkspace && !forAnimation && !this._alwaysAnimatePaddingTop) @@ -1681,23 +1676,9 @@ class nsZenWorkspaces { delete this._alwaysAnimatePaddingTop; const essentialsHeight = window.windowUtils.getBoundsWithoutFlushing(essentialContainer).height; - if (!forAnimation && animateContainer && gZenUIManager.motion && gZenStartup.isReady) { - gZenUIManager.motion.animate( - workspaceElement, - { - paddingTop: [workspaceElement.style.paddingTop, essentialsHeight + 'px'], - }, - { - type: 'spring', - bounce: 0, - duration: 0.2, - } - ); - } else { - requestAnimationFrame(() => { - workspaceElement.style.paddingTop = essentialsHeight + 'px'; - }); - } + requestAnimationFrame(() => { + workspaceElement.style.paddingTop = essentialsHeight + 'px'; + }); } } @@ -2445,17 +2426,11 @@ class nsZenWorkspaces { if (target && !target.target?.parentNode) { target = null; } - // Only animate if it's from an event - let animateContainer = target && target.target instanceof EventTarget; - if (target?.type === 'TabClose' || target?.type === 'TabOpen') { - animateContainer = target.target.pinned; - } this.onPinnedTabsResize( // This is what happens when we join a resize observer, an event listener // while using it as a method. [{ target: (target?.target ? target.target : target) ?? this.pinnedTabsContainer }], - forAnimation, - animateContainer + forAnimation ); } @@ -2498,7 +2473,7 @@ class nsZenWorkspaces { } } - onPinnedTabsResize(entries, forAnimation = false, animateContainer = false) { + onPinnedTabsResize(entries, forAnimation = false) { if ( document.documentElement.hasAttribute('inDOMFullscreen') || !this._hasInitializedTabsStrip || @@ -2550,12 +2525,7 @@ class nsZenWorkspaces { } else { essentialContainer.removeAttribute('data-hack-type'); } - this.#updatePaddingTopOnTabs( - workspaceElement, - essentialContainer, - forAnimation, - animateContainer - ); + this.#updatePaddingTopOnTabs(workspaceElement, essentialContainer, forAnimation); this.updateShouldHideSeparator(arrowScrollbox, pinnedContainer); } } @@ -2615,7 +2585,6 @@ class nsZenWorkspaces { } const workspaceID = tab.getAttribute('zen-workspace-id'); const isEssential = tab.getAttribute('zen-essential') === 'true'; - this.updateShouldHideSeparator(this.activeWorkspaceStrip, this.pinnedTabsContainer, true); if (tab.hasAttribute('zen-empty-tab')) { return; }