From 33a206b7b5ff403e67173785b1e90eb128c85300 Mon Sep 17 00:00:00 2001 From: onemen Date: Fri, 15 Nov 2024 08:37:17 +0200 Subject: [PATCH] chore: followup bug 1927094 - optimize lineScrollAmount so it doesn't iterate over all tabs --- addon/chrome/content/tab/scrollbox.js | 7 ------- addon/chrome/content/tabmix.js | 2 +- types/addon.d.ts | 1 + 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addon/chrome/content/tab/scrollbox.js b/addon/chrome/content/tab/scrollbox.js index d5471923..34525fc9 100644 --- a/addon/chrome/content/tab/scrollbox.js +++ b/addon/chrome/content/tab/scrollbox.js @@ -176,13 +176,6 @@ Tabmix.multiRow = { '$& && !this.isMultiRow', {flags: "g"} ).toCode(); - Tabmix.changeCode(this, "scrollbox.lineScrollAmount", {getter: true})._replace( - '{', `{ - if (this.isMultiRow) { - return this.scrollSize / Tabmix.tabsUtils.lastTabRowNumber; - }` - ).defineProperty(); - const codeToReplace = Tabmix.isVersion(1310) ? 'this.#verticalMode' : 'this.getAttribute("orient") == "vertical"'; Tabmix.changeCode(this, "scrollbox.on_touchstart")._replace( codeToReplace, 'this._verticalMode', {silent: true} diff --git a/addon/chrome/content/tabmix.js b/addon/chrome/content/tabmix.js index 19f28810..8e75e8e5 100644 --- a/addon/chrome/content/tabmix.js +++ b/addon/chrome/content/tabmix.js @@ -1030,7 +1030,7 @@ var TMP_eventListener = { let scrollAmount = 0; if (TabmixTabbar.isMultiRow) { delta = delta > 0 ? 1 : -1; - scrollAmount = delta * tabStrip.lineScrollAmount; + scrollAmount = delta * (tabStrip.scrollSize / Tabmix.tabsUtils.lastTabRowNumber); } else if (aEvent.deltaMode == aEvent.DOM_DELTA_PIXEL) { scrollAmount = delta; instant = true; diff --git a/types/addon.d.ts b/types/addon.d.ts index ac64b7a7..03b56f75 100644 --- a/types/addon.d.ts +++ b/types/addon.d.ts @@ -276,6 +276,7 @@ declare namespace TabmixArrowScrollboxNS { minOffset: number; offsetRatio: number; parentNode: MockedGeckoTypes.TabContainer; + readonly scrollSize: number; readonly shadowRoot: ShadowRoot; scrollboxPaddingBottom: number; scrollboxPaddingTop: number;