Skip to content

Commit 6f5d20f

Browse files
committed
Merge branch 'firefox-139' of https://github.com/zen-browser/desktop into firefox-139
2 parents 15bd0b2 + a87cbfd commit 6f5d20f

File tree

7 files changed

+94
-35
lines changed

7 files changed

+94
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- TODO: Get a job ->
1+
<!-- TODO: Get a job -->
22
<img src="./docs/assets/zen-dark.svg" width="100px" align="left">
33

44
### `Zen Browser`

src/zen/common/styles/zen-theme.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@
184184
--zen-themed-toolbar-bg-transparent: transparent;
185185
}
186186

187+
&[zen-private-window='true'] {
188+
--zen-main-browser-background: linear-gradient(
189+
130deg,
190+
light-dark(rgb(247, 217, 255), rgb(10, 6, 11)) 0%,
191+
light-dark(rgb(242, 198, 255), rgb(19, 7, 22)) 100%
192+
);
193+
--zen-main-browser-background-toolbar: var(--zen-main-browser-background);
194+
--zen-primary-color: light-dark(rgb(93, 42, 107), rgb(110, 48, 125)) !important;
195+
}
196+
187197
--toolbar-field-background-color: var(--zen-colors-input-bg) !important;
188198
--arrowpanel-background: var(--zen-dialog-background) !important;
189199

src/zen/tabs/ZenPinnedTabManager.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
document.documentElement.getAttribute('chromehidden')?.includes('menubar')
150150
);
151151
}
152-
return this._enabled;
152+
return this._enabled && !gZenWorkspaces.privateWindowOrDisabled;
153153
}
154154

155155
async _refreshPinnedTabs({ init = false } = {}) {
@@ -741,6 +741,9 @@
741741
}
742742

743743
_insertItemsIntoTabContextMenu() {
744+
if (!this.enabled) {
745+
return;
746+
}
744747
const elements = window.MozXULElement.parseXULToFragment(`
745748
<menuseparator id="context_zen-pinned-tab-separator" hidden="true"/>
746749
<menuitem id="context_zen-replace-pinned-url-with-current"
@@ -783,6 +786,7 @@
783786

784787
updatePinnedTabContextMenu(contextTab) {
785788
if (!this.enabled) {
789+
document.getElementById('context_pinTab').hidden = true;
786790
return;
787791
}
788792
const isVisible = contextTab.pinned && !contextTab.multiselected;
@@ -805,6 +809,9 @@
805809
}
806810

807811
moveToAnotherTabContainerIfNecessary(event, movingTabs) {
812+
if (!this.enabled) {
813+
return false;
814+
}
808815
try {
809816
const pinnedTabsTarget =
810817
event.target.closest('.zen-workspace-pinned-tabs-section') ||
@@ -1003,6 +1010,9 @@
10031010
}
10041011

10051012
applyDragoverClass(event, draggedTab) {
1013+
if (!this.enabled) {
1014+
return;
1015+
}
10061016
const pinnedTabsTarget = event.target.closest('.zen-workspace-pinned-tabs-section');
10071017
const essentialTabsTarget = event.target.closest('.zen-essentials-container');
10081018
const tabsTarget = event.target.closest('.zen-workspace-normal-tabs-section');

src/zen/tabs/zen-tabs/vertical-tabs.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,12 +1472,3 @@
14721472
width: 100%;
14731473
}
14741474
}
1475-
1476-
/* ==========================================================================
1477-
Section: Workspaces disabled, due to private browsing mode
1478-
========================================================================== */
1479-
1480-
:root:not([zen-workspace-id]) #tabbrowser-arrowscrollbox {
1481-
width: 100%;
1482-
position: absolute;
1483-
}

src/zen/workspaces/ZenGradientGenerator.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
super();
1919
if (
2020
!Services.prefs.getBoolPref('zen.theme.gradient', true) ||
21-
!gZenWorkspaces.shouldHaveWorkspaces
21+
!gZenWorkspaces.shouldHaveWorkspaces ||
22+
gZenWorkspaces.privateWindowOrDisabled
2223
) {
2324
return;
2425
}
@@ -427,7 +428,7 @@
427428
dot.classList.add('zen-theme-picker-dot', 'hidden', 'custom');
428429
dot.style.opacity = 0;
429430
dot.style.setProperty('--zen-theme-picker-dot-color', color);
430-
this.panel.querySelector('.zen-theme-picker-gradient').appendChild(dot);
431+
this.panel.querySelector('#PanelUI-zen-gradient-generator-custom-list').prepend(dot);
431432
this.customColorInput.value = '';
432433
await this.updateCurrentWorkspace();
433434
}
@@ -1088,7 +1089,7 @@
10881089
this.isDarkMode ? 0.2 : -0.5,
10891090
`rgb(${dominantColor[0]}, ${dominantColor[1]}, ${dominantColor[2]})`
10901091
);
1091-
const color = result?.match(/\d+/g).map(Number);
1092+
const color = result?.match(/\d+/g)?.map(Number);
10921093
if (!color || color.length !== 3) {
10931094
return this.getNativeAccentColor();
10941095
}
@@ -1255,6 +1256,7 @@
12551256
);
12561257
browser.gZenThemePicker.updateNoise(workspaceTheme.texture);
12571258

1259+
browser.gZenThemePicker.customColorList.innerHTML = '';
12581260
for (const dot of workspaceTheme.gradientColors) {
12591261
if (dot.isCustom) {
12601262
browser.gZenThemePicker.addColorToCustomList(dot.c);

src/zen/workspaces/ZenWorkspaces.mjs

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
4848
`;
4949

5050
async waitForPromises() {
51+
if (this.privateWindowOrDisabled) {
52+
return;
53+
}
5154
await Promise.all([
5255
this.promiseDBInitialized,
5356
this.promisePinnedInitialized,
@@ -115,6 +118,10 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
115118
);
116119
this._activeWorkspace = Services.prefs.getStringPref('zen.workspaces.active', '');
117120

121+
if (this.isPrivateWindow) {
122+
document.documentElement.setAttribute('zen-private-window', 'true');
123+
}
124+
118125
window.addEventListener('resize', this.onWindowResize.bind(this));
119126
this.addPopupListeners();
120127
}
@@ -136,21 +143,24 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
136143
await this.initializeWorkspaces();
137144
if (
138145
Services.prefs.getBoolPref('zen.workspaces.swipe-actions', false) &&
139-
this.workspaceEnabled
146+
this.workspaceEnabled &&
147+
!this.isPrivateWindow
140148
) {
141149
this.initializeGestureHandlers();
142150
this.initializeWorkspaceNavigation();
143151
}
144152

145-
Services.obs.addObserver(this, 'weave:engine:sync:finish');
146-
Services.obs.addObserver(
147-
async function observe(subject) {
148-
this._workspaceBookmarksCache = null;
149-
await this.workspaceBookmarks();
150-
this._invalidateBookmarkContainers();
151-
}.bind(this),
152-
'workspace-bookmarks-updated'
153-
);
153+
if (!this.privateWindowOrDisabled) {
154+
Services.obs.addObserver(this, 'weave:engine:sync:finish');
155+
Services.obs.addObserver(
156+
async function observe(subject) {
157+
this._workspaceBookmarksCache = null;
158+
await this.workspaceBookmarks();
159+
this._invalidateBookmarkContainers();
160+
}.bind(this),
161+
'workspace-bookmarks-updated'
162+
);
163+
}
154164
}
155165

156166
// Validate browser state before tab operations
@@ -548,7 +558,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
548558
toolbox.addEventListener(
549559
'wheel',
550560
async (event) => {
551-
if (!this.workspaceEnabled) return;
561+
if (this.privateWindowOrDisabled) return;
552562

553563
// Only process non-gesture scrolls
554564
if (event.deltaMode !== 1) return;
@@ -627,7 +637,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
627637
}
628638

629639
_handleSwipeMayStart(event) {
630-
if (!this.workspaceEnabled || this._inChangingWorkspace) return;
640+
if (this.privateWindowOrDisabled || this._inChangingWorkspace) return;
631641
if (event.target.closest('#zen-sidebar-bottom-buttons')) return;
632642

633643
// Only handle horizontal swipes
@@ -706,6 +716,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
706716

707717
set activeWorkspace(value) {
708718
this._activeWorkspace = value;
719+
if (this.privateWindowOrDisabled) {
720+
return;
721+
}
709722
Services.prefs.setStringPref('zen.workspaces.active', value);
710723
}
711724

@@ -734,7 +747,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
734747
if (typeof this._shouldHaveWorkspaces === 'undefined') {
735748
let docElement = document.documentElement;
736749
this._shouldHaveWorkspaces = !(
737-
PrivateBrowsingUtils.isWindowPrivate(window) ||
738750
docElement.getAttribute('chromehidden').includes('toolbar') ||
739751
docElement.getAttribute('chromehidden').includes('menubar')
740752
);
@@ -743,6 +755,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
743755
return this._shouldHaveWorkspaces;
744756
}
745757

758+
get isPrivateWindow() {
759+
return PrivateBrowsingUtils.isWindowPrivate(window);
760+
}
761+
762+
get privateWindowOrDisabled() {
763+
return this.isPrivateWindow || !this.shouldHaveWorkspaces;
764+
}
765+
746766
get workspaceEnabled() {
747767
if (typeof this._workspaceEnabled === 'undefined') {
748768
this._workspaceEnabled =
@@ -769,6 +789,15 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
769789
return this._workspaceCache;
770790
}
771791

792+
if (this.isPrivateWindow) {
793+
this._workspaceCache = {
794+
workspaces: this._privateWorkspace ? [this._privateWorkspace] : [],
795+
lastChangeTimestamp: 0,
796+
};
797+
this._activeWorkspace = this._privateWorkspace?.uuid;
798+
return this._workspaceCache;
799+
}
800+
772801
const [workspaces, lastChangeTimestamp] = await Promise.all([
773802
ZenWorkspacesStorage.getWorkspaces(),
774803
ZenWorkspacesStorage.getLastChangeTimestamp(),
@@ -1242,6 +1271,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
12421271
}
12431272

12441273
async saveWorkspace(workspaceData, preventPropagation = false) {
1274+
if (this.privateWindowOrDisabled) {
1275+
return;
1276+
}
12451277
await ZenWorkspacesStorage.saveWorkspace(workspaceData);
12461278
if (!preventPropagation) {
12471279
await this._propagateWorkspaceData();
@@ -1383,10 +1415,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
13831415
}
13841416

13851417
async _propagateWorkspaceData({ ignoreStrip = false, clearCache = true } = {}) {
1418+
const currentWindowIsPrivate = this.isPrivateWindow;
13861419
await this.foreachWindowAsActive(async (browser) => {
13871420
// Do not update the window if workspaces are not enabled in it.
13881421
// For example, when the window is in private browsing mode.
1389-
if (!browser.gZenWorkspaces.workspaceEnabled) {
1422+
if (
1423+
!browser.gZenWorkspaces.workspaceEnabled ||
1424+
browser.gZenWorkspaces.isPrivateWindow !== currentWindowIsPrivate
1425+
) {
13901426
return;
13911427
}
13921428

@@ -1710,7 +1746,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
17101746
}
17111747

17121748
async openWorkspacesDialog(event) {
1713-
if (!this.workspaceEnabled) {
1749+
if (!this.workspaceEnabled || this.isPrivateWindow) {
17141750
return;
17151751
}
17161752
let target = event.target.closest('.zen-current-workspace-indicator');
@@ -2526,6 +2562,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
25262562
}
25272563

25282564
async _updateWorkspacesChangeContextMenu() {
2565+
if (gZenWorkspaces.privateWindowOrDisabled) return;
25292566
const workspaces = await this._workspaces();
25302567

25312568
const menuPopup = document.getElementById('context-zen-change-workspace-tab-menu-popup');
@@ -2575,6 +2612,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
25752612
if (!this.workspaceEnabled) {
25762613
return;
25772614
}
2615+
if (this.isPrivateWindow) {
2616+
name = 'Private ' + name;
2617+
}
25782618
// get extra tabs remaning (e.g. on new profiles) and just move them to the new workspace
25792619
const extraTabs = Array.from(gBrowser.tabContainer.arrowScrollbox.children).filter(
25802620
(child) =>
@@ -2590,7 +2630,11 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
25902630
!dontChange,
25912631
containerTabId
25922632
);
2593-
await this.saveWorkspace(workspaceData, dontChange);
2633+
if (this.isPrivateWindow) {
2634+
this._privateWorkspace = workspaceData;
2635+
} else {
2636+
await this.saveWorkspace(workspaceData, dontChange);
2637+
}
25942638
if (!dontChange) {
25952639
this.registerPinnedResizeObserver();
25962640
let changed = extraTabs.length > 0;

src/zen/workspaces/zen-workspaces.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@
447447
position: relative;
448448
max-height: var(--zen-workspace-indicator-height);
449449
min-height: var(--zen-workspace-indicator-height);
450-
gap: var(--tab-icon-end-margin);
450+
gap: 10px;
451451
align-items: center;
452452
flex-direction: row !important;
453453
max-width: 100%;
@@ -466,10 +466,12 @@
466466
height: calc(100% - var(--zen-toolbox-padding) * 2);
467467
}
468468

469-
&:hover,
470-
&[open='true'] {
471-
&::before {
472-
background: var(--tab-hover-background-color);
469+
:root:not([zen-private-window]) & {
470+
&:hover,
471+
&[open='true'] {
472+
&::before {
473+
background: var(--tab-hover-background-color);
474+
}
473475
}
474476
}
475477

0 commit comments

Comments
 (0)