mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
feat: Correctly identify glance tabs, b=(no-bug), c=tabs, glance
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tab.js b/browser/components/tabbrowser/content/tab.js
|
||||
index dc92771ebc65095dfebbddc238ee6d4fffd897bf..ae9120f7cc8989cf625ac101d053d82582e32009 100644
|
||||
index dc92771ebc65095dfebbddc238ee6d4fffd897bf..fa35f6835498f8e51f060479addb25237d3fe7ff 100644
|
||||
--- a/browser/components/tabbrowser/content/tab.js
|
||||
+++ b/browser/components/tabbrowser/content/tab.js
|
||||
@@ -21,6 +21,7 @@
|
||||
@@ -57,7 +57,18 @@ index dc92771ebc65095dfebbddc238ee6d4fffd897bf..ae9120f7cc8989cf625ac101d053d825
|
||||
event.target.classList.contains("tab-icon-overlay") ||
|
||||
event.target.classList.contains("tab-audio-button")
|
||||
) {
|
||||
@@ -554,6 +559,7 @@
|
||||
@@ -508,6 +513,10 @@
|
||||
this.style.MozUserFocus = "";
|
||||
}
|
||||
|
||||
+ get glanceTab() {
|
||||
+ return this.querySelector("tab[zen-glance-tab]");
|
||||
+ }
|
||||
+
|
||||
on_click(event) {
|
||||
if (event.button != 0) {
|
||||
return;
|
||||
@@ -554,6 +563,7 @@
|
||||
telemetrySource: lazy.TabMetrics.METRIC_SOURCE.TAB_STRIP,
|
||||
});
|
||||
} else {
|
||||
@@ -65,7 +76,7 @@ index dc92771ebc65095dfebbddc238ee6d4fffd897bf..ae9120f7cc8989cf625ac101d053d825
|
||||
gBrowser.removeTab(this, {
|
||||
animate: true,
|
||||
triggeringEvent: event,
|
||||
@@ -564,6 +570,14 @@
|
||||
@@ -564,6 +574,14 @@
|
||||
// (see tabbrowser-tabs 'click' handler).
|
||||
gBrowser.tabContainer._blockDblClick = true;
|
||||
}
|
||||
@@ -80,7 +91,7 @@ index dc92771ebc65095dfebbddc238ee6d4fffd897bf..ae9120f7cc8989cf625ac101d053d825
|
||||
}
|
||||
|
||||
on_dblclick(event) {
|
||||
@@ -587,6 +601,8 @@
|
||||
@@ -587,6 +605,8 @@
|
||||
animate: true,
|
||||
triggeringEvent: event,
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
||||
index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a0398ac88ea 100644
|
||||
index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..2b71bb2788c4e874388c999ae5b29f121d21bebf 100644
|
||||
--- a/browser/components/tabbrowser/content/tabs.js
|
||||
+++ b/browser/components/tabbrowser/content/tabs.js
|
||||
@@ -83,7 +83,7 @@
|
||||
@@ -136,7 +136,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
|
||||
get verticalMode() {
|
||||
@@ -1606,29 +1636,41 @@
|
||||
@@ -1606,29 +1636,42 @@
|
||||
if (this.#allTabs) {
|
||||
return this.#allTabs;
|
||||
}
|
||||
@@ -153,29 +153,32 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
- children.splice(i, 1, ...children[i].tabs);
|
||||
- }
|
||||
- }
|
||||
|
||||
this.#allTabs = [
|
||||
-
|
||||
- this.#allTabs = [
|
||||
- ...this.verticalPinnedTabsContainer.children,
|
||||
+ ...gZenWorkspaces.getCurrentEssentialsContainer().children, ...this.verticalPinnedTabsContainer.children,
|
||||
+ const pinnedTabs = [...gZenWorkspaces.getCurrentEssentialsContainer().children, ...this.verticalPinnedTabsContainer.children];
|
||||
+ const allTabs = [
|
||||
+ ...pinnedTabs,
|
||||
...children,
|
||||
];
|
||||
+ const lastPinnedTabIdx = gBrowser.pinnedTabCount;
|
||||
+ for (let i = 0; i < this.#allTabs.length; i++) {
|
||||
+ const lastPinnedTabIdx = pinnedTabs.length - 1;
|
||||
+ for (let i = 0; i < allTabs.length; i++) {
|
||||
+ // add glance tabs (tabs inside tabs) to the list
|
||||
+ const glanceTab = this.#allTabs[i].querySelector("tab[zen-glance-tab]");
|
||||
+ const glanceTab = allTabs[i].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
|
||||
+ this.#allTabs.splice(Math.max(i + 1, lastPinnedTabIdx), 0, glanceTab);
|
||||
+ allTabs.splice(Math.max(i + 1, lastPinnedTabIdx), 0, glanceTab);
|
||||
+ i++;
|
||||
+ } else if (this.#allTabs[i].classList.contains("vertical-pinned-tabs-container-separator")) {
|
||||
+ } else if (allTabs[i].classList.contains("vertical-pinned-tabs-container-separator")) {
|
||||
+ // remove the separator from the list
|
||||
+ this.#allTabs.splice(i, 1);
|
||||
+ allTabs.splice(i, 1);
|
||||
+ i--;
|
||||
+ } else if (this.#allTabs[i].tagName == "tab-group") {
|
||||
+ this.#allTabs.splice(i, 1, ...this.#allTabs[i].tabs);
|
||||
+ } else if (allTabs[i].tagName == "tab-group") {
|
||||
+ allTabs.splice(i, 1, ...allTabs[i].tabs);
|
||||
+ }
|
||||
+ }
|
||||
+ this.#allTabs = allTabs;
|
||||
return this.#allTabs;
|
||||
}
|
||||
|
||||
@@ -186,7 +189,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1648,7 +1690,7 @@
|
||||
@@ -1648,7 +1691,7 @@
|
||||
*/
|
||||
get visibleTabs() {
|
||||
if (!this.#visibleTabs) {
|
||||
@@ -195,7 +198,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
return this.#visibleTabs;
|
||||
}
|
||||
@@ -1683,36 +1725,40 @@
|
||||
@@ -1683,36 +1726,40 @@
|
||||
}
|
||||
|
||||
let elementIndex = 0;
|
||||
@@ -227,14 +230,14 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
focusableItems.push(...visibleTabsInGroup);
|
||||
}
|
||||
+ for (let tab of child.tabs) {
|
||||
+ let glanceTab = tab.querySelector("tab[zen-glance-tab]");
|
||||
+ let glanceTab = tab.glanceTab;
|
||||
+ if (isTab(glanceTab)) {
|
||||
+ glanceTab.elementIndex = elementIndex - 1;
|
||||
+ focusableItems.push(glanceTab);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ let glanceTab = child.querySelector("tab[zen-glance-tab]");
|
||||
+ let glanceTab = child.glanceTab;
|
||||
+ if (isTab(child) && glanceTab) {
|
||||
+ glanceTab.elementIndex = elementIndex - 1;
|
||||
+ focusableItems.push(glanceTab);
|
||||
@@ -249,7 +252,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
|
||||
return this.#focusableItems;
|
||||
}
|
||||
@@ -1720,6 +1766,7 @@
|
||||
@@ -1720,6 +1767,7 @@
|
||||
_invalidateCachedTabs() {
|
||||
this.#allTabs = null;
|
||||
this._invalidateCachedVisibleTabs();
|
||||
@@ -257,7 +260,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
|
||||
_invalidateCachedVisibleTabs() {
|
||||
@@ -1734,8 +1781,8 @@
|
||||
@@ -1734,8 +1782,8 @@
|
||||
#isContainerVerticalPinnedGrid(tab) {
|
||||
return (
|
||||
this.verticalMode &&
|
||||
@@ -268,7 +271,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
!this.expandOnHover
|
||||
);
|
||||
}
|
||||
@@ -1751,7 +1798,7 @@
|
||||
@@ -1751,7 +1799,7 @@
|
||||
|
||||
if (node == null) {
|
||||
// We have a container for non-tab elements at the end of the scrollbox.
|
||||
@@ -277,7 +280,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
|
||||
node.before(tab);
|
||||
@@ -1846,7 +1893,7 @@
|
||||
@@ -1846,7 +1894,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.
|
||||
@@ -286,7 +289,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
const newTab2 = this.newTabButton;
|
||||
const newTabVertical = document.getElementById(
|
||||
"vertical-tabs-newtab-button"
|
||||
@@ -1941,10 +1988,12 @@
|
||||
@@ -1941,10 +1989,12 @@
|
||||
|
||||
_handleTabSelect(aInstant) {
|
||||
let selectedTab = this.selectedItem;
|
||||
@@ -299,7 +302,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
selectedTab._notselectedsinceload = false;
|
||||
}
|
||||
|
||||
@@ -2085,16 +2134,15 @@
|
||||
@@ -2085,16 +2135,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.
|
||||
@@ -322,7 +325,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2102,9 +2150,7 @@
|
||||
@@ -2102,9 +2151,7 @@
|
||||
}
|
||||
|
||||
_resetVerticalPinnedTabs() {
|
||||
@@ -333,7 +336,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
|
||||
if (!verticalTabsContainer.children.length) {
|
||||
return;
|
||||
@@ -2117,7 +2163,7 @@
|
||||
@@ -2117,7 +2164,7 @@
|
||||
}
|
||||
|
||||
_positionPinnedTabs() {
|
||||
@@ -342,7 +345,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let numPinned = gBrowser.pinnedTabCount;
|
||||
let absPositionHorizontalTabs =
|
||||
this.overflowing && tabs.length > numPinned && numPinned > 0;
|
||||
@@ -2127,7 +2173,7 @@
|
||||
@@ -2127,7 +2174,7 @@
|
||||
|
||||
if (this.verticalMode) {
|
||||
this._updateVerticalPinnedTabs();
|
||||
@@ -351,7 +354,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let layoutData = this._pinnedTabsLayoutCache;
|
||||
let uiDensity = document.documentElement.getAttribute("uidensity");
|
||||
if (!layoutData || layoutData.uiDensity != uiDensity) {
|
||||
@@ -2191,7 +2237,7 @@
|
||||
@@ -2191,7 +2238,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,7 +363,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
|
||||
let directionX = screenX > dragData.animLastScreenX;
|
||||
let directionY = screenY > dragData.animLastScreenY;
|
||||
@@ -2199,7 +2245,7 @@
|
||||
@@ -2199,7 +2246,7 @@
|
||||
dragData.animLastScreenX = screenX;
|
||||
|
||||
let { width: tabWidth, height: tabHeight } =
|
||||
@@ -369,7 +372,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let shiftSizeX = tabWidth * movingTabs.length;
|
||||
let shiftSizeY = tabHeight;
|
||||
dragData.tabWidth = tabWidth;
|
||||
@@ -2374,12 +2420,16 @@
|
||||
@@ -2374,12 +2421,16 @@
|
||||
|
||||
this.#clearDragOverCreateGroupTimer();
|
||||
|
||||
@@ -391,7 +394,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
|
||||
if (this.#rtlMode) {
|
||||
tabs.reverse();
|
||||
@@ -2393,7 +2443,7 @@
|
||||
@@ -2393,7 +2444,7 @@
|
||||
let size = this.verticalMode ? "height" : "width";
|
||||
let translateAxis = this.verticalMode ? "translateY" : "translateX";
|
||||
let scrollDirection = this.verticalMode ? "scrollTop" : "scrollLeft";
|
||||
@@ -400,7 +403,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let translateX = event.screenX - dragData.screenX;
|
||||
let translateY = event.screenY - dragData.screenY;
|
||||
|
||||
@@ -2407,12 +2457,21 @@
|
||||
@@ -2407,12 +2458,21 @@
|
||||
let lastTab = tabs.at(-1);
|
||||
let lastMovingTab = movingTabs.at(-1);
|
||||
let firstMovingTab = movingTabs[0];
|
||||
@@ -423,7 +426,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
translate +=
|
||||
this.arrowScrollbox.scrollbox[scrollDirection] - dragData.scrollPos;
|
||||
} else if (isPinned && this.verticalMode) {
|
||||
@@ -2431,6 +2490,9 @@
|
||||
@@ -2431,6 +2491,9 @@
|
||||
// Shift the `.tab-group-label-container` to shift the label element.
|
||||
item = item.parentElement;
|
||||
}
|
||||
@@ -433,7 +436,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
item.style.transform = `${translateAxis}(${translate}px)`;
|
||||
}
|
||||
|
||||
@@ -2568,6 +2630,9 @@
|
||||
@@ -2568,6 +2631,9 @@
|
||||
break;
|
||||
}
|
||||
let element = tabs[mid];
|
||||
@@ -443,7 +446,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let elementForSize = isTabGroupLabel(element)
|
||||
? element.parentElement
|
||||
: element;
|
||||
@@ -2590,6 +2655,10 @@
|
||||
@@ -2590,6 +2656,10 @@
|
||||
if (!dropElement) {
|
||||
dropElement = this.ariaFocusableItems[oldDropElementIndex];
|
||||
}
|
||||
@@ -454,7 +457,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
let newDropElementIndex = dropElement
|
||||
? dropElement.elementIndex
|
||||
: oldDropElementIndex;
|
||||
@@ -2598,7 +2667,7 @@
|
||||
@@ -2598,7 +2668,7 @@
|
||||
let shouldCreateGroupOnDrop;
|
||||
let dropBefore;
|
||||
if (dropElement) {
|
||||
@@ -463,7 +466,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
? dropElement.parentElement
|
||||
: dropElement;
|
||||
|
||||
@@ -2660,12 +2729,12 @@
|
||||
@@ -2660,12 +2730,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +481,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
dropElement != draggedTab &&
|
||||
isTab(dropElement) &&
|
||||
!dropElement?.group &&
|
||||
@@ -2735,7 +2804,7 @@
|
||||
@@ -2735,7 +2805,7 @@
|
||||
// Shift background tabs to leave a gap where the dragged tab
|
||||
// would currently be dropped.
|
||||
for (let item of tabs) {
|
||||
@@ -487,7 +490,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2744,6 +2813,9 @@
|
||||
@@ -2744,6 +2814,9 @@
|
||||
if (isTabGroupLabel(item)) {
|
||||
// Shift the `.tab-group-label-container` to shift the label element.
|
||||
item = item.parentElement;
|
||||
@@ -497,7 +500,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
}
|
||||
item.style.transform = transform;
|
||||
}
|
||||
@@ -2796,8 +2868,9 @@
|
||||
@@ -2796,8 +2869,9 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -509,7 +512,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2809,6 +2882,12 @@
|
||||
@@ -2809,6 +2883,12 @@
|
||||
item = item.parentElement;
|
||||
}
|
||||
item.style.transform = "";
|
||||
@@ -522,7 +525,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
item.removeAttribute("dragover-createGroup");
|
||||
}
|
||||
this.removeAttribute("movingtab-createGroup");
|
||||
@@ -2855,7 +2934,7 @@
|
||||
@@ -2855,7 +2935,7 @@
|
||||
let postTransitionCleanup = () => {
|
||||
movingTab._moveTogetherSelectedTabsData.animate = false;
|
||||
};
|
||||
@@ -531,7 +534,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
postTransitionCleanup();
|
||||
} else {
|
||||
let onTransitionEnd = transitionendEvent => {
|
||||
@@ -3028,7 +3107,7 @@
|
||||
@@ -3028,7 +3108,7 @@
|
||||
}
|
||||
|
||||
_notifyBackgroundTab(aTab) {
|
||||
@@ -540,7 +543,7 @@ index ef9c0389ec926e6bc01c0dc3b883beceaf1f7d43..043c39f1bc7452e145ba325ffafb6a03
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3154,6 +3233,9 @@
|
||||
@@ -3154,6 +3234,9 @@
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -367,7 +367,9 @@
|
||||
this.#currentParentTab._visuallySelected = false;
|
||||
}
|
||||
|
||||
this.#currentParentTab.linkedBrowser.zenModeActive = false;
|
||||
if (this.#currentParentTab.linkedBrowser) {
|
||||
this.#currentParentTab.linkedBrowser.zenModeActive = false;
|
||||
}
|
||||
|
||||
// reset everything
|
||||
this.browserWrapper = null;
|
||||
@@ -447,7 +449,7 @@
|
||||
.classList.remove('zen-glance-background');
|
||||
}
|
||||
if (!justAnimateParent && this.overlay) {
|
||||
if (parentHasBrowser) {
|
||||
if (parentHasBrowser && !this.#currentParentTab.hasAttribute('split-view')) {
|
||||
if (closeParentTab) {
|
||||
this.#currentParentTab.linkedBrowser
|
||||
.closest('.browserSidebarContainer')
|
||||
|
Reference in New Issue
Block a user