Skip to content

Commit

Permalink
Refactor tab handling logic to improve readability and maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-balades committed Nov 27, 2024
1 parent 62ca724 commit 5497016
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 69 deletions.
6 changes: 3 additions & 3 deletions src/browser/base/content/zen-styles/zen-urlbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#urlbar-background {
border: transparent !important;
margin: 1px;
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1) !important;
}

#urlbar[focused='true']:not([suppress-focus-border]) > #urlbar-background,
Expand Down Expand Up @@ -101,8 +101,8 @@

.urlbar-page-action,
#tracking-protection-icon-container {
width: calc(var(--urlbar-min-height) - 4 * var(--urlbar-container-padding)) !important;
height: calc(var(--urlbar-min-height) - 4 * var(--urlbar-container-padding)) !important;
width: calc(var(--urlbar-min-height) - 6 * var(--urlbar-container-padding)) !important;
height: calc(var(--urlbar-min-height) - 6 * var(--urlbar-container-padding)) !important;
margin-top: auto !important;
margin-bottom: auto !important;
}
Expand Down
76 changes: 10 additions & 66 deletions src/browser/components/tabbrowser/content/tabs-js.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80deb7ab07 100644
index f9e256b143786c18ba85859ca1b11182ab23f1aa..25eeaf2a61fcef53edcb8d1a45b6e41dc750013a 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -894,7 +894,7 @@
@@ -918,7 +918,7 @@
let postTransitionCleanup = () => {
tab.removeAttribute("tabdrop-samewindow");

Expand All @@ -11,7 +11,7 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
if (dropIndex !== false) {
gBrowser.moveTabTo(tab, dropIndex);
if (incrementDropIndex) {
@@ -904,7 +904,7 @@
@@ -928,7 +928,7 @@

gBrowser.syncThrobberAnimations(tab);
};
Expand All @@ -20,7 +20,7 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
postTransitionCleanup();
} else {
let onTransitionEnd = transitionendEvent => {
@@ -1044,7 +1044,8 @@
@@ -1077,7 +1077,8 @@
if (
dt.mozUserCancelled ||
dt.dropEffect != "none" ||
Expand All @@ -30,25 +30,16 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
) {
delete draggedTab._dragData;
return;
@@ -1284,7 +1285,7 @@
@@ -1328,7 +1329,7 @@
}
}

- this.#allTabs = [...verticalPinnedTabsContainer.children, ...children];
+ this.#allTabs = [...document.getElementById("zen-essentials-container").children, ...verticalPinnedTabsContainer.children, ...children];
return this.#allTabs;
}

@@ -1480,7 +1481,7 @@
let rect = ele => {
return window.windowUtils.getBoundsWithoutFlushing(ele);
};
- let tab = this.visibleTabs[gBrowser.pinnedTabCount];
+ let tab = this.visibleTabs[gBrowser.pinnedTabCount];
if (tab && rect(tab).width <= this._tabClipWidth) {
this.setAttribute("closebuttons", "activetab");
} else {
@@ -1499,10 +1500,12 @@

@@ -1520,10 +1521,12 @@

_handleTabSelect(aInstant) {
let selectedTab = this.selectedItem;
Expand All @@ -64,16 +55,7 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
selectedTab._notselectedsinceload = false;
}

@@ -1550,7 +1553,7 @@
if (isEndTab && !this._hasTabTempMaxWidth) {
return;
}
- let numPinned = gBrowser.pinnedTabCount;
+ let numPinned = gBrowser.pinnedTabCount;
// 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.
@@ -1565,7 +1568,7 @@
@@ -1586,7 +1589,7 @@
let tabsToReset = [];
for (let i = numPinned; i < tabs.length; i++) {
let tab = tabs[i];
Expand All @@ -82,15 +64,7 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
if (!isEndTab) {
// keep tabs the same width
tab.style.transition = "none";
@@ -1630,13 +1633,13 @@
let verticalTabsContainer = document.getElementById(
"vertical-pinned-tabs-container"
);
- let numPinned = gBrowser.pinnedTabCount;
+ let numPinned = gBrowser.pinnedTabCount;

- if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
+ if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
@@ -1657,7 +1660,7 @@
let tabs = this.visibleTabs;
for (let i = 0; i < numPinned; i++) {
tabs[i].style.marginInlineStart = "";
Expand All @@ -99,25 +73,7 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
}
}

@@ -1660,7 +1663,7 @@

_positionPinnedTabs() {
let tabs = this.visibleTabs;
- let numPinned = gBrowser.pinnedTabCount;
+ let numPinned = gBrowser.pinnedTabCount;
let absPositionHorizontalTabs =
this.overflowing && tabs.length > numPinned && numPinned > 0;

@@ -1934,7 +1937,7 @@
}

let pinned = draggedTab.pinned;
- let numPinned = gBrowser.pinnedTabCount;
+ let numPinned = gBrowser.pinnedTabCount;
let tabs = this.visibleTabs.slice(
pinned ? 0 : numPinned,
pinned ? numPinned : undefined
@@ -2059,8 +2062,8 @@
@@ -2140,8 +2143,8 @@
);
}

Expand All @@ -128,15 +84,3 @@ index f3a2f226a9056c5a75023281fdeb704cec49b4a6..ae808f0f16466edc3d5f70271cc40c80
return;
}

@@ -2218,9 +2221,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.pinnedTabCount - 1);
}
- return Math.max(index, gBrowser.pinnedTabCount);
+ return Math.max(index, gBrowser.pinnedTabCount);
}
}

0 comments on commit 5497016

Please sign in to comment.