mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-07 03:48:22 +00:00
281 lines
10 KiB
C++
281 lines
10 KiB
C++
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
|
index 8aeb244ffca9f48661805f5b7d860b5896055562..5d49a40b35b2bc4ea2c9b8423bde07508326eaca 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 !tab.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 != this ||
|
|
event.composedTarget.localName == "toolbarbutton"
|
|
) {
|
|
return;
|
|
@@ -659,7 +659,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) {
|
|
@@ -1010,7 +1010,7 @@
|
|
}
|
|
} else {
|
|
let pinned = draggedTab.pinned;
|
|
- let numPinned = gBrowser.pinnedTabCount;
|
|
+ let numPinned = gBrowser._numVisiblePinTabs;
|
|
let tabs = this.visibleTabs.slice(
|
|
pinned ? 0 : numPinned,
|
|
pinned ? numPinned : undefined
|
|
@@ -1090,7 +1090,7 @@
|
|
let postTransitionCleanup = () => {
|
|
tab.removeAttribute("tabdrop-samewindow");
|
|
|
|
- this._finishAnimateTabMove();
|
|
+ this._finishAnimateTabMove(true);
|
|
if (dropIndex !== false) {
|
|
gBrowser.moveTabTo(tab, dropIndex);
|
|
if (!directionForward) {
|
|
@@ -1100,7 +1100,7 @@
|
|
|
|
gBrowser.syncThrobberAnimations(tab);
|
|
};
|
|
- if (gReduceMotion) {
|
|
+ if (gReduceMotion || true) {
|
|
postTransitionCleanup();
|
|
} else {
|
|
let onTransitionEnd = transitionendEvent => {
|
|
@@ -1263,7 +1263,8 @@
|
|
if (
|
|
dt.mozUserCancelled ||
|
|
dt.dropEffect != "none" ||
|
|
- this._isCustomizing
|
|
+ this._isCustomizing ||
|
|
+ draggedTab.pinned
|
|
) {
|
|
delete draggedTab._dragData;
|
|
return;
|
|
@@ -1512,7 +1513,7 @@
|
|
}
|
|
|
|
this.#allTabs = [
|
|
- ...this.verticalPinnedTabsContainer.children,
|
|
+ ...document.getElementById("zen-essentials-container").children, ...this.verticalPinnedTabsContainer.children,
|
|
...children,
|
|
];
|
|
return this.#allTabs;
|
|
@@ -1593,6 +1594,7 @@
|
|
}
|
|
|
|
this.#focusableItems = [
|
|
+ ...document.getElementById("zen-essentials-container").children,
|
|
...verticalPinnedTabsContainer.children,
|
|
...focusableItems,
|
|
];
|
|
@@ -1617,8 +1619,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"))
|
|
);
|
|
}
|
|
|
|
@@ -1816,7 +1818,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 {
|
|
@@ -1832,6 +1834,7 @@
|
|
this.arrowScrollbox.ensureElementIsVisible(selectedTab, aInstant);
|
|
}
|
|
|
|
+ gZenCompactModeManager.flashSidebarIfNecessary(aInstant);
|
|
selectedTab._notselectedsinceload = false;
|
|
}
|
|
|
|
@@ -1879,7 +1882,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 +1897,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";
|
|
@@ -1963,13 +1966,13 @@
|
|
let verticalTabsContainer = document.getElementById(
|
|
"vertical-pinned-tabs-container"
|
|
);
|
|
- let numPinned = gBrowser.pinnedTabCount;
|
|
+ let numPinned = gBrowser._numVisiblePinTabs;
|
|
|
|
- if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
|
|
+ if (gBrowser.pinnedTabCount !== (verticalTabsContainer.children.length + document.getElementById("zen-essentials-container").children.length)) {
|
|
let tabs = this.visibleTabs;
|
|
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.appendChild(tabs[i]);
|
|
}
|
|
}
|
|
|
|
@@ -1993,7 +1996,7 @@
|
|
|
|
_positionPinnedTabs() {
|
|
let tabs = this.visibleTabs;
|
|
- let numPinned = gBrowser.pinnedTabCount;
|
|
+ let numPinned = gBrowser._numVisiblePinTabs;
|
|
let absPositionHorizontalTabs =
|
|
this.overflowing && tabs.length > numPinned && numPinned > 0;
|
|
|
|
@@ -2074,7 +2077,7 @@
|
|
return;
|
|
}
|
|
|
|
- let tabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount);
|
|
+ let tabs = this.visibleTabs.slice(0, gBrowser._numVisiblePinTabs);
|
|
|
|
let directionX = screenX > dragData.animLastScreenX;
|
|
let directionY = screenY > dragData.animLastScreenY;
|
|
@@ -2257,9 +2260,9 @@
|
|
}
|
|
|
|
let pinned = draggedTab.pinned;
|
|
- let numPinned = gBrowser.pinnedTabCount;
|
|
+ let numPinned = gBrowser._numVisiblePinTabs;
|
|
let tabs = this.visibleTabs.slice(
|
|
- pinned ? 0 : numPinned,
|
|
+ pinned ? gBrowser._numZenEssentials : numPinned,
|
|
pinned ? numPinned : undefined
|
|
);
|
|
|
|
@@ -2502,8 +2505,8 @@
|
|
);
|
|
}
|
|
|
|
- _finishAnimateTabMove() {
|
|
- if (!this.hasAttribute("movingtab")) {
|
|
+ _finishAnimateTabMove(always = false) {
|
|
+ if (!this.hasAttribute("movingtab") && !always) {
|
|
return;
|
|
}
|
|
|
|
@@ -2668,9 +2671,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 +2757,7 @@
|
|
}
|
|
|
|
_notifyBackgroundTab(aTab) {
|
|
- if (aTab.pinned || !aTab.visible || !this.overflowing) {
|
|
+ if (aTab.hasAttribute("zen-essential") || !aTab.visible || !this.overflowing) {
|
|
return;
|
|
}
|
|
|
|
@@ -2772,12 +2775,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 +2799,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 +2811,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")) {
|