Skip to content

Commit 1205a2e

Browse files
committed
chore: Cleanup and add extra pref, b=no-bug, c=tests, tabs
1 parent 18caed0 commit 1205a2e

File tree

6 files changed

+57
-27
lines changed

6 files changed

+57
-27
lines changed

locales/en-US/browser/browser/preferences/zen-preferences.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ zen-tabs-close-on-back-with-no-history =
6161
6262
zen-tabs-cycle-by-attribute =
6363
.label = Ctrl+Tab cycles within Essential or Workspace tabs only
64+
zen-tabs-cycle-ignore-pending-tabs =
65+
.label = Ignore Pending tabs when cycling with Ctrl+Tab
6466
zen-tabs-cycle-by-attribute-warning = Ctrl+Tab will cycle by recently used order, as it is enabled
6567
6668
zen-look-and-feel-compact-toolbar-themed =

prefs/zen/zen.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@
3838
- name: zen.tabs.close-on-back-with-no-history
3939
value: true
4040

41-
- name: zen.tabs.cycle-by-attribute
41+
- name: zen.tabs.ctrl-tab.ignore-essential-tabs
42+
value: false
43+
44+
- name: zen.tabs.ctrl-tab.ignore-pending-tabs
4245
value: false

src/browser/components/preferences/zen-settings.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,28 +708,38 @@ var gZenWorkspacesSettings = {
708708
},
709709
};
710710

711-
var toggleZenCycleByAttrWarning = {
711+
let toggleZenCycleByAttrWarning = {
712712
observe() {
713713
const warning = document.getElementById('zenTabsCycleByAttributeWarning');
714714
warning.hidden = !(
715-
Services.prefs.getBoolPref('zen.tabs.cycle-by-attribute', false) &&
715+
Services.prefs.getBoolPref('zen.tabs.ctrl-tab.ignore-essential-tabs', false) &&
716716
Services.prefs.getBoolPref('browser.ctrlTab.sortByRecentlyUsed', false)
717717
);
718-
}
719-
}
720-
toggleZenCycleByAttrWarning.observe() // call it once on initial load
718+
},
719+
};
720+
721+
toggleZenCycleByAttrWarning.observe(); // call it once on initial load
721722

722723
Services.prefs.addObserver('zen.glance.enabled', tabsUnloaderPrefListener); // We can use the same listener for both prefs
723724
Services.prefs.addObserver('zen.workspaces.separate-essentials', tabsUnloaderPrefListener);
724725
Services.prefs.addObserver('zen.glance.activation-method', tabsUnloaderPrefListener);
725-
Services.prefs.addObserver('zen.tabs.cycle-by-attribute', toggleZenCycleByAttrWarning);
726+
Services.prefs.addObserver(
727+
'zen.tabs.ctrl-tab.ignore-essential-tabs',
728+
toggleZenCycleByAttrWarning
729+
);
726730
Services.prefs.addObserver('browser.ctrlTab.sortByRecentlyUsed', toggleZenCycleByAttrWarning);
727731
window.addEventListener('unload', () => {
728732
Services.prefs.removeObserver('zen.glance.enabled', tabsUnloaderPrefListener);
729733
Services.prefs.removeObserver('zen.glance.activation-method', tabsUnloaderPrefListener);
730734
Services.prefs.removeObserver('zen.workspaces.separate-essentials', tabsUnloaderPrefListener);
731-
Services.prefs.removeObserver('zen.tabs.cycle-by-attribute', toggleZenCycleByAttrWarning);
732-
Services.prefs.removeObserver('browser.ctrlTab.sortByRecentlyUsed', toggleZenCycleByAttrWarning);
735+
Services.prefs.removeObserver(
736+
'zen.tabs.ctrl-tab.ignore-essential-tabs',
737+
toggleZenCycleByAttrWarning
738+
);
739+
Services.prefs.removeObserver(
740+
'browser.ctrlTab.sortByRecentlyUsed',
741+
toggleZenCycleByAttrWarning
742+
);
733743
});
734744
},
735745
};
@@ -1152,12 +1162,17 @@ Preferences.addAll([
11521162
default: true,
11531163
},
11541164
{
1155-
id: 'zen.tabs.cycle-by-attribute',
1165+
id: 'zen.tabs.ctrl-tab.ignore-essential-tabs',
1166+
type: 'bool',
1167+
default: false,
1168+
},
1169+
{
1170+
id: 'zen.tabs.ctrl-tab.ignore-pending-tabs',
11561171
type: 'bool',
11571172
default: false,
11581173
},
11591174
{
1160-
id: 'browser.ctrlTab.sortByRecentlyUsed',
1175+
id: 'zen.tabs.close-on-back-with-no-history',
11611176
type: 'bool',
11621177
default: false,
11631178
},

src/browser/components/preferences/zenTabsManagement.inc.xhtml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
<checkbox id="zenTabsCloseOnBackWithNoHistory"
3030
data-l10n-id="zen-tabs-close-on-back-with-no-history"
3131
preference="zen.tabs.close-on-back-with-no-history"/>
32-
<checkbox id="zenTabsCycleByAttribute"
33-
data-l10n-id="zen-tabs-cycle-by-attribute"
34-
preference="zen.tabs.cycle-by-attribute"/>
32+
<checkbox data-l10n-id="zen-tabs-cycle-ignore-pending-tabs"
33+
preference="zen.tabs.ctrl-tab.ignore-pending-tabs"/>
34+
<checkbox data-l10n-id="zen-tabs-cycle-by-attribute"
35+
preference="zen.tabs.ctrl-tab.ignore-essential-tabs"/>
3536
<description id="zenTabsCycleByAttributeWarning"
3637
class="description-deemphasized"
3738
data-l10n-id="zen-tabs-cycle-by-attribute-warning"

src/toolkit/content/widgets/tabbox-js.patch

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
diff --git a/toolkit/content/widgets/tabbox.js b/toolkit/content/widgets/tabbox.js
2-
index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84df604086 100644
2+
index cfe2da6e199667bd668f117cc8972212c7f57da2..470033466eae0e853855e21b86a0722627f9ed4b 100644
33
--- a/toolkit/content/widgets/tabbox.js
44
+++ b/toolkit/content/widgets/tabbox.js
5-
@@ -11,6 +11,17 @@
5+
@@ -11,6 +11,23 @@
66
"resource://gre/modules/AppConstants.sys.mjs"
77
);
88

99
+ const { XPCOMUtils } = ChromeUtils.importESModule(
1010
+ "resource://gre/modules/XPCOMUtils.sys.mjs"
1111
+ );
12-
+ const lazyPrefs = {};
12+
+ const lazyZenPrefs = {};
1313
+ XPCOMUtils.defineLazyPreferenceGetter(
14-
+ lazyPrefs,
14+
+ lazyZenPrefs,
1515
+ "cycleByAttribute",
16-
+ "zen.tabs.cycle-by-attribute",
16+
+ "zen.tabs.ctrl-tab.ignore-essential-tabs",
17+
+ false
18+
+ );
19+
+ XPCOMUtils.defineLazyPreferenceGetter(
20+
+ lazyZenPrefs,
21+
+ "ignorePendingTabs",
22+
+ "zen.tabs.ctrl-tab.ignore-pending-tabs",
1723
+ false
1824
+ );
1925
+
2026
let imports = {};
2127
ChromeUtils.defineESModuleGetters(imports, {
2228
ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs",
23-
@@ -213,7 +224,7 @@
29+
@@ -213,7 +230,7 @@
2430
) {
2531
this._inAsyncOperation = false;
2632
if (oldPanel != this._selectedPanel) {
@@ -29,7 +35,7 @@ index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84
2935
this._selectedPanel?.classList.add("deck-selected");
3036
}
3137
this.setAttribute("selectedIndex", val);
32-
@@ -697,7 +708,7 @@
38+
@@ -697,7 +714,7 @@
3339
if (!tab) {
3440
return;
3541
}
@@ -38,15 +44,15 @@ index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84
3844
if (otherTab != tab && otherTab.selected) {
3945
otherTab._selected = false;
4046
}
41-
@@ -733,6 +744,7 @@
47+
@@ -733,6 +750,7 @@
4248
* @param {MozTab|null} [val]
4349
*/
4450
set selectedItem(val) {
4551
+ val = window.gZenGlanceManager?.getTabOrGlanceChild(val) || val;
4652
if (val && !val.selected) {
4753
// The selectedIndex setter ignores invalid values
4854
// such as -1 if |val| isn't one of our child nodes.
49-
@@ -910,7 +922,7 @@
55+
@@ -910,7 +928,7 @@
5056
if (tab == startTab) {
5157
return null;
5258
}
@@ -55,7 +61,7 @@ index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84
5561
return tab;
5662
}
5763
}
58-
@@ -972,13 +984,27 @@
64+
@@ -972,13 +990,30 @@
5965
* @param {boolean} [aWrap]
6066
*/
6167
advanceSelectedTab(aDir, aWrap) {
@@ -72,7 +78,10 @@ index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84
7278
+ if (!tab.visible) {
7379
+ return false
7480
+ }
75-
+ if (!lazyPrefs.cycleByAttribute) {
81+
+ if (lazyZenPrefs.ignorePendingTabs && tab.hasAttribute("pending")) {
82+
+ return false
83+
+ }
84+
+ if (!lazyZenPrefs.cycleByAttribute) {
7685
+ return true
7786
+ }
7887
+ if (startTab.hasAttribute("zen-essential")) {
@@ -84,7 +93,7 @@ index cfe2da6e199667bd668f117cc8972212c7f57da2..3a007eaddd7f9de9d1e4f936113baf84
8493
// Handle keyboard navigation for a hidden tab that can be selected, like the Firefox View tab,
8594
// which has a random placement in this.allTabs.
8695
if (startTab.hidden) {
87-
@@ -991,7 +1017,7 @@
96+
@@ -991,7 +1026,7 @@
8897
newTab = this.findNextTab(startTab, {
8998
direction: aDir,
9099
wrap: aWrap,

src/zen/tests/tabs/browser_tabs_cycle_by_attribute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ add_setup(async () => {
5656

5757
add_task(async function cycleTabsByAttribute() {
5858
await SpecialPowers.pushPrefEnv({
59-
set: [['zen.tabs.cycle-by-attribute', true]],
59+
set: [['zen.tabs.ctrl-tab.ignore-essential-tabs', true]],
6060
});
6161

6262
const essentialTabs = gBrowser.tabs.filter((tab) => tab.hasAttribute('zen-essential'));

0 commit comments

Comments
 (0)