mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 09:26:34 +00:00
Refactor pinned tab position handling to use cached pin objects for improved performance
This commit is contained in:
@@ -288,12 +288,15 @@
|
|||||||
|
|
||||||
for (let otherTab of gBrowser.tabs) {
|
for (let otherTab of gBrowser.tabs) {
|
||||||
if (otherTab.pinned && otherTab._tPos > tab.position) {
|
if (otherTab.pinned && otherTab._tPos > tab.position) {
|
||||||
otherTab.position = otherTab._tPos;
|
const actualPin = this._pinsCache.find(pin => pin.uuid === otherTab.getAttribute("zen-pin-id"));
|
||||||
await ZenPinnedTabsStorage.savePin(otherTab, false);
|
actualPin.position = otherTab._tPos;
|
||||||
|
await ZenPinnedTabsStorage.savePin(actualPin, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await ZenPinnedTabsStorage.savePin(tab);
|
const actualPin = this._pinsCache.find(pin => pin.uuid === tab.getAttribute("zen-pin-id"));
|
||||||
|
actualPin.position = tab.position;
|
||||||
|
await ZenPinnedTabsStorage.savePin(actualPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onTabClick(e) {
|
_onTabClick(e) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
||||||
index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c0317076f26d 100644
|
index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..14c15935c4d7decfb011312d15c8bb71924b19e9 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabs.js
|
--- a/browser/components/tabbrowser/content/tabs.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabs.js
|
+++ b/browser/components/tabbrowser/content/tabs.js
|
||||||
@@ -649,7 +649,7 @@
|
@@ -649,7 +649,7 @@
|
||||||
@@ -48,7 +48,26 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
...children,
|
...children,
|
||||||
];
|
];
|
||||||
return this.#allTabs;
|
return this.#allTabs;
|
||||||
@@ -1790,10 +1791,12 @@
|
@@ -1556,6 +1557,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#focusableItems = [
|
||||||
|
+ ...document.getElementById("zen-essentials-container").children,
|
||||||
|
...verticalPinnedTabsContainer.children,
|
||||||
|
...focusableItems,
|
||||||
|
];
|
||||||
|
@@ -1579,8 +1581,8 @@
|
||||||
|
#isContainerVerticalPinnedExpanded(tab) {
|
||||||
|
return (
|
||||||
|
this.verticalMode &&
|
||||||
|
- tab.hasAttribute("pinned") &&
|
||||||
|
- this.hasAttribute("expanded")
|
||||||
|
+ (tab.hasAttribute("zen-essential")) &&
|
||||||
|
+ (this.hasAttribute("expanded") || document.documentElement.hasAttribute("zen-sidebar-expanded"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1790,10 +1792,12 @@
|
||||||
|
|
||||||
_handleTabSelect(aInstant) {
|
_handleTabSelect(aInstant) {
|
||||||
let selectedTab = this.selectedItem;
|
let selectedTab = this.selectedItem;
|
||||||
@@ -64,7 +83,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
selectedTab._notselectedsinceload = false;
|
selectedTab._notselectedsinceload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1841,7 +1844,7 @@
|
@@ -1841,7 +1845,7 @@
|
||||||
if (isEndTab && !this._hasTabTempMaxWidth) {
|
if (isEndTab && !this._hasTabTempMaxWidth) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,7 +92,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
// Force tabs to stay the same width, unless we're closing the last tab,
|
// Force tabs to stay the same width, unless we're closing the last tab,
|
||||||
// which case we need to let them expand just enough so that the overall
|
// which case we need to let them expand just enough so that the overall
|
||||||
// tabbar width is the same.
|
// tabbar width is the same.
|
||||||
@@ -1856,7 +1859,7 @@
|
@@ -1856,7 +1860,7 @@
|
||||||
let tabsToReset = [];
|
let tabsToReset = [];
|
||||||
for (let i = numPinned; i < tabs.length; i++) {
|
for (let i = numPinned; i < tabs.length; i++) {
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@@ -82,7 +101,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
if (!isEndTab) {
|
if (!isEndTab) {
|
||||||
// keep tabs the same width
|
// keep tabs the same width
|
||||||
tab.style.transition = "none";
|
tab.style.transition = "none";
|
||||||
@@ -1922,13 +1925,13 @@
|
@@ -1922,13 +1926,13 @@
|
||||||
let verticalTabsContainer = document.getElementById(
|
let verticalTabsContainer = document.getElementById(
|
||||||
"vertical-pinned-tabs-container"
|
"vertical-pinned-tabs-container"
|
||||||
);
|
);
|
||||||
@@ -98,7 +117,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,7 +1955,7 @@
|
@@ -1952,7 +1956,7 @@
|
||||||
|
|
||||||
_positionPinnedTabs() {
|
_positionPinnedTabs() {
|
||||||
let tabs = this.visibleTabs;
|
let tabs = this.visibleTabs;
|
||||||
@@ -107,7 +126,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
let absPositionHorizontalTabs =
|
let absPositionHorizontalTabs =
|
||||||
this.overflowing && tabs.length > numPinned && numPinned > 0;
|
this.overflowing && tabs.length > numPinned && numPinned > 0;
|
||||||
|
|
||||||
@@ -2033,7 +2036,7 @@
|
@@ -2033,7 +2037,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +135,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
|
|
||||||
let directionX = screenX > dragData.animLastScreenX;
|
let directionX = screenX > dragData.animLastScreenX;
|
||||||
let directionY = screenY > dragData.animLastScreenY;
|
let directionY = screenY > dragData.animLastScreenY;
|
||||||
@@ -2221,7 +2224,7 @@
|
@@ -2221,7 +2225,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let pinned = draggedTab.pinned;
|
let pinned = draggedTab.pinned;
|
||||||
@@ -125,7 +144,7 @@ index f7c39fe804182e2bdf53045ba3b6a5ba17079fc3..bc8361d14f27a3ae00b791f15691c031
|
|||||||
let tabs = this.visibleTabs.slice(
|
let tabs = this.visibleTabs.slice(
|
||||||
pinned ? 0 : numPinned,
|
pinned ? 0 : numPinned,
|
||||||
pinned ? numPinned : undefined
|
pinned ? numPinned : undefined
|
||||||
@@ -2456,8 +2459,8 @@
|
@@ -2456,8 +2460,8 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user