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

429 lines
16 KiB
C++

diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff7eed44ef 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -94,7 +94,7 @@
};
this.arrowScrollbox._canScrollToElement = element => {
if (isTab(element)) {
- return !element.pinned || !this.hasAttribute("positionpinnedtabs");
+ return !element.hasAttribute("zen-essential") || !this.hasAttribute("positionpinnedtabs");
}
return true;
};
@@ -362,7 +362,7 @@
// and we're not hitting the scroll buttons.
if (
event.button != 0 ||
- event.target != this.arrowScrollbox ||
+ event.target != document.getElementById("zen-tabs-wrapper") ||
event.composedTarget.localName == "toolbarbutton"
) {
return;
@@ -411,6 +411,7 @@
// Reset the "ignored click" flag
target._ignoredCloseButtonClicks = false;
}
+ gZenUIManager.saveScrollbarState();
}
/* Protects from close-tab-button errant doubleclick:
@@ -659,7 +660,7 @@
if (this.#isContainerVerticalPinnedExpanded(tab)) {
// In expanded vertical mode, the max number of pinned tabs per row is dynamic
// Set this before adjusting dragged tab's position
- let pinnedTabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount);
+ let pinnedTabs = this.visibleTabs.slice(0, gBrowser._numVisiblePinTabs);
let tabsPerRow = 0;
let position = 0;
for (let pinnedTab of pinnedTabs) {
@@ -859,6 +860,9 @@
}
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
+ if (draggedTab && effects === "move") {
+ gZenPinnedTabManager.applyDragoverClass(event, draggedTab);
+ }
if (
(effects == "move" || effects == "copy") &&
this == draggedTab.container &&
@@ -972,6 +976,14 @@
this._tabDropIndicator.hidden = true;
event.stopPropagation();
+ if (draggedTab && dropEffect == "move") {
+ let moved = gZenPinnedTabManager.moveToAnotherTabContainerIfNecessary(event, movingTabs);
+
+ if (moved) {
+ this._finishMoveTogetherSelectedTabs(draggedTab);
+ return;
+ }
+ }
if (draggedTab && dropEffect == "copy") {
// copy the dropped tab (wherever it's from)
let newIndex = this._getDropIndex(event);
@@ -1010,8 +1022,8 @@
}
} else {
let pinned = draggedTab.pinned;
- let numPinned = gBrowser.pinnedTabCount;
- let tabs = this.visibleTabs.slice(
+ let numPinned = gBrowser._numVisiblePinTabs;
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice(
pinned ? 0 : numPinned,
pinned ? numPinned : undefined
);
@@ -1090,7 +1102,7 @@
let postTransitionCleanup = () => {
tab.removeAttribute("tabdrop-samewindow");
- this._finishAnimateTabMove();
+ this._finishAnimateTabMove(true);
if (dropIndex !== false) {
gBrowser.moveTabTo(tab, dropIndex);
if (!directionForward) {
@@ -1100,7 +1112,7 @@
gBrowser.syncThrobberAnimations(tab);
};
- if (gReduceMotion) {
+ if (gReduceMotion || true) {
postTransitionCleanup();
} else {
let onTransitionEnd = transitionendEvent => {
@@ -1263,7 +1275,8 @@
if (
dt.mozUserCancelled ||
dt.dropEffect != "none" ||
- this._isCustomizing
+ this._isCustomizing ||
+ draggedTab.pinned
) {
delete draggedTab._dragData;
return;
@@ -1478,7 +1491,7 @@
}
get newTabButton() {
- return this.querySelector("#tabs-newtab-button");
+ return ZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
}
get verticalMode() {
@@ -1498,7 +1511,7 @@
if (this.#allTabs) {
return this.#allTabs;
}
- let children = Array.from(this.arrowScrollbox.children);
+ let children = Array.from(ZenWorkspaces.tabboxChildren);
// remove arrowScrollbox periphery element
children.pop();
@@ -1512,14 +1525,28 @@
}
this.#allTabs = [
- ...this.verticalPinnedTabsContainer.children,
+ ...document.getElementById("zen-essentials-container").children, ...this.verticalPinnedTabsContainer.children,
...children,
];
+ const lastPinnedTabIdx = gBrowser.pinnedTabCount;
+ for (let i = 0; i < this.#allTabs.length; i++) {
+ // add glance tabs (tabs inside tabs) to the list
+ const glanceTab = this.#allTabs[i].querySelector("tab[zen-glance-tab]");
+ if (glanceTab) {
+ // insert right after the parent tab
+ this.#allTabs.splice(i + 1, 0, glanceTab);
+ i++;
+ } else if (this.#allTabs[i].classList.contains("vertical-pinned-tabs-container-separator")) {
+ // remove the separator from the list
+ this.#allTabs.splice(i, 1);
+ i--;
+ }
+ }
return this.#allTabs;
}
get allGroups() {
- let children = Array.from(this.arrowScrollbox.children);
+ let children = Array.from(ZenWorkspaces.tabboxChildren);
return children.filter(node => node.tagName == "tab-group");
}
@@ -1574,10 +1601,8 @@
return this.#focusableItems;
}
- let verticalPinnedTabsContainer = document.getElementById(
- "vertical-pinned-tabs-container"
- );
- let children = Array.from(this.arrowScrollbox.children);
+ let verticalPinnedTabsContainer = this.verticalPinnedTabsContainer;
+ let children = Array.from(ZenWorkspaces.tabboxChildren);
let focusableItems = [];
for (let child of children) {
@@ -1593,6 +1618,7 @@
}
this.#focusableItems = [
+ ...document.getElementById("zen-essentials-container").children,
...verticalPinnedTabsContainer.children,
...focusableItems,
];
@@ -1617,8 +1643,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"))
);
}
@@ -1633,7 +1659,7 @@
if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox.
- node = this.arrowScrollbox.lastChild;
+ node = ZenWorkspaces.activeWorkspaceStrip.lastChild;
}
node.before(tab);
@@ -1733,7 +1759,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 = ZenWorkspaces.activeWorkspaceStrip.querySelector("#tabs-newtab-button");
const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button"
@@ -1816,7 +1842,7 @@
let rect = ele => {
return window.windowUtils.getBoundsWithoutFlushing(ele);
};
- let tab = this.visibleTabs[gBrowser.pinnedTabCount];
+ let tab = this.visibleTabs[gBrowser._numVisiblePinTabs];
if (tab && rect(tab).width <= this._tabClipWidth) {
this.setAttribute("closebuttons", "activetab");
} else {
@@ -1828,10 +1854,12 @@
_handleTabSelect(aInstant) {
let selectedTab = this.selectedItem;
+ if (!selectedTab) return;
if (this.overflowing) {
this.arrowScrollbox.ensureElementIsVisible(selectedTab, aInstant);
}
+ gZenCompactModeManager.flashSidebarIfNecessary(aInstant);
selectedTab._notselectedsinceload = false;
}
@@ -1843,7 +1871,7 @@
return;
}
- let tabs = this.visibleTabs;
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
if (!tabs.length) {
return;
}
@@ -1879,7 +1907,7 @@
if (isEndTab && !this._hasTabTempMaxWidth) {
return;
}
- let numPinned = gBrowser.pinnedTabCount;
+ let numPinned = gBrowser._numVisiblePinTabs;
// 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
// tabbar width is the same.
@@ -1894,7 +1922,7 @@
let tabsToReset = [];
for (let i = numPinned; i < tabs.length; i++) {
let tab = tabs[i];
- tab.style.setProperty("max-width", aTabWidth, "important");
+ //tab.style.setProperty("max-width", aTabWidth, "important");
if (!isEndTab) {
// keep tabs the same width
tab.style.transition = "none";
@@ -1960,16 +1988,15 @@
// Move pinned tabs to another container when the tabstrip is toggled to vertical
// and when session restore code calls _positionPinnedTabs; update styling whenever
// the number of pinned tabs changes.
- let verticalTabsContainer = document.getElementById(
- "vertical-pinned-tabs-container"
- );
+ let verticalTabsContainer = this.verticalPinnedTabsContainer;
let numPinned = gBrowser.pinnedTabCount;
- if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
- let tabs = this.visibleTabs;
+ let count = ZenWorkspaces.makeSurePinTabIsInCorrectPosition();
+ if (gBrowser.pinnedTabCount !== (verticalTabsContainer.children.length - count - 1 + document.getElementById("zen-essentials-container").children.length)) {
+ let tabs = this.allTabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
for (let i = 0; i < numPinned; i++) {
tabs[i].style.marginInlineStart = "";
- verticalTabsContainer.appendChild(tabs[i]);
+ tabs[i].hasAttribute("zen-essential") ? document.getElementById("zen-essentials-container").appendChild(tabs[i]) : verticalTabsContainer.insertBefore(tabs[i], verticalTabsContainer.lastChild);
}
}
@@ -1977,9 +2004,7 @@
}
_resetVerticalPinnedTabs() {
- let verticalTabsContainer = document.getElementById(
- "vertical-pinned-tabs-container"
- );
+ let verticalTabsContainer = this.verticalPinnedTabsContainer;
if (!verticalTabsContainer.children.length) {
return;
@@ -1992,8 +2017,8 @@
}
_positionPinnedTabs() {
- let tabs = this.visibleTabs;
- let numPinned = gBrowser.pinnedTabCount;
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
+ let numPinned = gBrowser._numVisiblePinTabs;
let absPositionHorizontalTabs =
this.overflowing && tabs.length > numPinned && numPinned > 0;
@@ -2003,6 +2028,7 @@
if (this.verticalMode) {
this._updateVerticalPinnedTabs();
} else if (absPositionHorizontalTabs) {
+ return;
let layoutData = this._pinnedTabsLayoutCache;
let uiDensity = document.documentElement.getAttribute("uidensity");
if (!layoutData || layoutData.uiDensity != uiDensity) {
@@ -2074,7 +2100,7 @@
return;
}
- let tabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount);
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice(0, gBrowser._numVisiblePinTabs);
let directionX = screenX > dragData.animLastScreenX;
let directionY = screenY > dragData.animLastScreenY;
@@ -2257,9 +2283,9 @@
}
let pinned = draggedTab.pinned;
- let numPinned = gBrowser.pinnedTabCount;
- let tabs = this.visibleTabs.slice(
- pinned ? 0 : numPinned,
+ let numPinned = gBrowser._numVisiblePinTabs;
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice(
+ pinned ? gBrowser._numZenEssentials : numPinned,
pinned ? numPinned : undefined
);
@@ -2502,8 +2528,9 @@
);
}
- _finishAnimateTabMove() {
- if (!this.hasAttribute("movingtab")) {
+ _finishAnimateTabMove(always = false) {
+ gZenPinnedTabManager.removeTabContainersDragoverClass();
+ if (!this.hasAttribute("movingtab") && !always) {
return;
}
@@ -2668,9 +2695,9 @@
function newIndex(aTab, index) {
// Don't allow mixing pinned and unpinned tabs.
if (aTab.pinned) {
- return Math.min(index, gBrowser.pinnedTabCount - 1);
+ return Math.min(index, gBrowser._numVisiblePinTabs - 1);
}
- return Math.max(index, gBrowser.pinnedTabCount);
+ return Math.max(index, gBrowser._numVisiblePinTabs);
}
}
@@ -2754,7 +2781,7 @@
}
_notifyBackgroundTab(aTab) {
- if (aTab.pinned || !aTab.visible || !this.overflowing) {
+ if (aTab.hasAttribute("zen-essential") || !aTab.visible || !this.overflowing) {
return;
}
@@ -2772,12 +2799,14 @@
selectedTab = {
left: selectedTab.left,
right: selectedTab.right,
+ top: selectedTab.top,
+ bottom: selectedTab.bottom,
};
}
return [
this._lastTabToScrollIntoView,
this.arrowScrollbox.scrollClientRect,
- { left: lastTabRect.left, right: lastTabRect.right },
+ lastTabRect,
selectedTab,
];
})
@@ -2794,8 +2823,11 @@
delete this._lastTabToScrollIntoView;
// Is the new tab already completely visible?
if (
- scrollRect.left <= tabRect.left &&
- tabRect.right <= scrollRect.right
+ this.verticalMode
+ ? scrollRect.top <= tabRect.top &&
+ tabRect.bottom <= scrollRect.bottom
+ : scrollRect.left <= tabRect.left &&
+ tabRect.right <= scrollRect.right
) {
return;
}
@@ -2803,21 +2835,29 @@
if (this.arrowScrollbox.smoothScroll) {
// Can we make both the new tab and the selected tab completely visible?
if (
- !selectedRect ||
- Math.max(
- tabRect.right - selectedRect.left,
- selectedRect.right - tabRect.left
- ) <= scrollRect.width
+ !selectedRect || (this.verticalMode
+ ? Math.max(
+ tabRect.bottom - selectedRect.top,
+ selectedRect.bottom - tabRect.top
+ ) <= scrollRect.height
+ : Math.max(
+ tabRect.right - selectedRect.left,
+ selectedRect.right - tabRect.left
+ ) <= scrollRect.width)
) {
this.arrowScrollbox.ensureElementIsVisible(tabToScrollIntoView);
return;
}
- this.arrowScrollbox.scrollByPixels(
- this.#rtlMode
- ? selectedRect.right - scrollRect.right
- : selectedRect.left - scrollRect.left
- );
+ let scrollPixels;
+ if (this.verticalMode) {
+ scrollPixels = tabRect.top - selectedRect.top;
+ } else if (this.#rtlMode) {
+ scrollPixels = selectedRect.right - scrollRect.right;
+ } else {
+ scrollPixels = selectedRect.left - scrollRect.left;
+ }
+ this.arrowScrollbox.scrollByPixels(scrollPixels);
}
if (!this._animateElement.hasAttribute("highlight")) {