Files
desktop/src/browser/components/tabbrowser/content/tabs-js.patch

212 lines
7.6 KiB
C++

diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index 6b6c04599fe80983d13d2069ca62b99d8ad70271..a765f2decc3a565226ac8793422474052f476573 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -436,7 +436,7 @@
// and we're not hitting the scroll buttons.
if (
event.button != 0 ||
- event.target != this.arrowScrollbox ||
+ !event.target.classList.contains("zen-workspace-empty-space") ||
event.composedTarget.localName == "toolbarbutton"
) {
return;
@@ -517,7 +517,6 @@
});
}
} else if (isTabGroupLabel(event.target)) {
- event.target.group.saveAndClose();
} else if (
event.originalTarget.closest("scrollbox") &&
!Services.prefs.getBoolPref(
@@ -553,6 +552,9 @@
}
on_keydown(event) {
+ if (document.documentElement.getAttribute('zen-renaming-tab') === 'true') {
+ return;
+ }
let { altKey, shiftKey } = event;
let [accel, nonAccel] =
AppConstants.platform == "macosx"
@@ -747,7 +749,6 @@
this._updateCloseButtons();
if (!this.#animatingGroups.size) {
- this._handleTabSelect(true);
}
document
@@ -808,7 +809,7 @@
}
get newTabButton() {
- return this.querySelector("#tabs-newtab-button");
+ return gZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
}
get verticalMode() {
@@ -824,6 +825,7 @@
}
get overflowing() {
+ gZenWorkspaces.updateOverflowingTabs();
return this.hasAttribute("overflow");
}
@@ -837,29 +839,54 @@
if (pinnedChildren?.at(-1)?.id == "pinned-tabs-container-periphery") {
pinnedChildren.pop();
}
- let unpinnedChildren = Array.from(this.arrowScrollbox.children);
+ let unpinnedChildren = gZenWorkspaces.tabboxChildren;
// remove arrowScrollbox periphery element.
unpinnedChildren.pop();
// explode tab groups and split view wrappers
// Iterate backwards over the array to preserve indices while we modify
// things in place
- for (let i = unpinnedChildren.length - 1; i >= 0; i--) {
- if (
- unpinnedChildren[i].tagName == "tab-group" ||
- unpinnedChildren[i].tagName == "tab-split-view-wrapper"
- ) {
- unpinnedChildren.splice(i, 1, ...unpinnedChildren[i].tabs);
+ const pinnedTabs = [...gZenWorkspaces.getCurrentEssentialsContainer().children, ...pinnedChildren];
+ const expandTabs = (tabs) => {
+ for (let i = tabs.length - 1; i >= 0; i--) {
+ const tab = tabs[i];
+ if (isTabGroup(tab)) {
+ // remove the group from the list
+ tabs.splice(i, 1);
+ // add the tabs in the group to the list
+ tabs.splice(i, 0, ...tab.tabs);
+ }
+ }
+ };
+ expandTabs(pinnedTabs);
+ expandTabs(unpinnedChildren);
+ const allTabs = [
+ ...pinnedTabs,
+ ...unpinnedChildren,
+ ];
+ const lastPinnedTabIdx = pinnedTabs.length - 1;
+ let i = 0;
+ for (const tab of [...allTabs]) {
+ // add glance tabs (tabs inside tabs) to the list
+ const glanceTab = tab.glanceTab;
+ if (glanceTab) {
+ // insert right after the parent tab. note: it must be inserted before
+ // the last pinned tab so it can be inserted in the correct order
+ allTabs.splice(Math.max(i++ + 1, lastPinnedTabIdx), 0, glanceTab);
+ } else if (tab.classList.contains("pinned-tabs-container-separator")) {
+ // remove the separator from the list
+ allTabs.splice(i, 1);
+ i--;
}
+ i++;
}
-
- this.#allTabs = [...pinnedChildren, ...unpinnedChildren];
+ this.#allTabs = allTabs;
return this.#allTabs;
}
get allGroups() {
let children = Array.from(this.arrowScrollbox.children);
- return children.filter(node => node.tagName == "tab-group");
+ return gZenWorkspaces.allTabGroups;
}
/**
@@ -926,17 +953,10 @@
let elementIndex = 0;
- let unpinnedChildren = Array.from(this.arrowScrollbox.children);
- let pinnedChildren = Array.from(this.pinnedTabsContainer.children);
+ let children = gZenWorkspaces.tabboxChildrenWithoutEmpty;
let focusableItems = [];
- for (let child of pinnedChildren) {
- if (isTab(child)) {
- child.elementIndex = elementIndex++;
- focusableItems.push(child);
- }
- }
- for (let child of unpinnedChildren) {
+ for (let child of [...gZenWorkspaces.getCurrentEssentialsContainer().children, ...this.pinnedTabsContainer.children, ...children]) {
if (isTab(child) && child.visible) {
child.elementIndex = elementIndex++;
focusableItems.push(child);
@@ -944,11 +964,13 @@
child.labelElement.elementIndex = elementIndex++;
focusableItems.push(child.labelElement);
- let visibleTabsInGroup = child.tabs.filter(tab => tab.visible);
+ if (!child.hasAttribute("split-view-group")) {
+ let visibleTabsInGroup = child.childGroupsAndTabs.filter(tab => tab.visible);
visibleTabsInGroup.forEach(tab => {
tab.elementIndex = elementIndex++;
});
focusableItems.push(...visibleTabsInGroup);
+ }
} else if (child.tagName == "tab-split-view-wrapper") {
let visibleTabsInSplitView = child.tabs.filter(tab => tab.visible);
visibleTabsInSplitView.forEach(tab => {
@@ -992,6 +1014,7 @@
_invalidateCachedTabs() {
this.#allTabs = null;
this._invalidateCachedVisibleTabs();
+ gZenWorkspaces._allStoredTabs = null;
}
_invalidateCachedVisibleTabs() {
@@ -1095,7 +1118,7 @@
if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox.
- node = this.arrowScrollbox.lastChild;
+ node = gZenWorkspaces.activeWorkspaceStrip.lastChild;
}
node.before(tab);
@@ -1193,7 +1216,7 @@
// There are separate "new tab" buttons for horizontal tabs toolbar, vertical tabs and
// for when the tab strip is overflowed (which is shared by vertical and horizontal tabs);
// Attach the long click popup to all of them.
- const newTab = document.getElementById("new-tab-button");
+ const newTab = gZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button"
@@ -1294,8 +1317,10 @@
*/
_handleTabSelect(aInstant) {
let selectedTab = this.selectedItem;
+ if (!selectedTab) return;
this.#ensureTabIsVisible(selectedTab, aInstant);
+ gZenCompactModeManager.flashSidebarIfNecessary(aInstant);
selectedTab._notselectedsinceload = false;
}
@@ -1304,7 +1329,7 @@
* @param {boolean} [shouldScrollInstantly=false]
*/
#ensureTabIsVisible(tab, shouldScrollInstantly = false) {
- let arrowScrollbox = tab.closest("arrowscrollbox");
+ let arrowScrollbox = this.arrowScrollbox;
if (arrowScrollbox?.overflowing) {
arrowScrollbox.ensureElementIsVisible(tab, shouldScrollInstantly);
}
@@ -1437,7 +1462,7 @@
}
_notifyBackgroundTab(aTab) {
- if (aTab.pinned || !aTab.visible || !this.overflowing) {
+ if (aTab.hasAttribute("zen-essential") || !aTab.visible || !this.overflowing) {
return;
}