mirror of
https://github.com/zen-browser/desktop.git
synced 2025-12-16 19:35:31 +00:00
Compare commits
86 Commits
1.17.14b
...
drag-and-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04833ad090 | ||
|
|
f044433bd1 | ||
|
|
6367a5aba0 | ||
|
|
74face2299 | ||
|
|
8b33fe91eb | ||
|
|
fa1693d16b | ||
|
|
cc7780e078 | ||
|
|
f094b6239d | ||
|
|
1207d2163d | ||
|
|
a3c6d412bb | ||
|
|
cc31282ce2 | ||
|
|
f5ae793ff0 | ||
|
|
132fc0e28b | ||
|
|
38aad02d07 | ||
|
|
097c7ed17b | ||
|
|
669a54c5a2 | ||
|
|
3285eb9dd5 | ||
|
|
5ce257de83 | ||
|
|
d97404d03b | ||
|
|
60c0afc5ac | ||
|
|
307e8fc0ef | ||
|
|
cd8f8fdb6f | ||
|
|
f720dce237 | ||
|
|
cde32ca1e0 | ||
|
|
aecea1f565 | ||
|
|
73f408c9e1 | ||
|
|
899d590329 | ||
|
|
22f2b1f29b | ||
|
|
5d964511aa | ||
|
|
a0268ace63 | ||
|
|
8be603ac88 | ||
|
|
8bf790df4c | ||
|
|
a84bd5b0ce | ||
|
|
ae62f5c41d | ||
|
|
7dd3cf5817 | ||
|
|
722ffa5e97 | ||
|
|
57233a18f6 | ||
|
|
04ab9a4b4e | ||
|
|
1fcef12d0a | ||
|
|
c6cd912262 | ||
|
|
a765d3642f | ||
|
|
40bc51f904 | ||
|
|
8a963a9257 | ||
|
|
9c5bf19ae3 | ||
|
|
6fbba04dab | ||
|
|
c5df63711b | ||
|
|
a61846bf9a | ||
|
|
c2a5066181 | ||
|
|
00417582fb | ||
|
|
32d603ced9 | ||
|
|
2706e8761d | ||
|
|
61659c63d9 | ||
|
|
34c725aad0 | ||
|
|
435762c682 | ||
|
|
c60990c283 | ||
|
|
1d26040fc6 | ||
|
|
acb3708936 | ||
|
|
c3b9c3c526 | ||
|
|
0adf260ddc | ||
|
|
ce986beb2f | ||
|
|
c86875b7b0 | ||
|
|
eefc8cb20c | ||
|
|
12c921fd87 | ||
|
|
e419c4dc9f | ||
|
|
68b37ac736 | ||
|
|
7f225ac3ee | ||
|
|
3e39ef2538 | ||
|
|
e5517eb164 | ||
|
|
c4dd470864 | ||
|
|
bf1b0dcd48 | ||
|
|
76acc8b0e4 | ||
|
|
1b83b77cad | ||
|
|
79ff574978 | ||
|
|
af20a65fa1 | ||
|
|
4a7f8fc9c0 | ||
|
|
a738a829de | ||
|
|
240a031e38 | ||
|
|
9bc7b9ce4e | ||
|
|
86006c8891 | ||
|
|
a55b1c7495 | ||
|
|
6e6337a95b | ||
|
|
6b12153c8a | ||
|
|
f6922ef2ba | ||
|
|
91f5d58fbc | ||
|
|
7a4cdaa45c | ||
|
|
81e854a89f |
@@ -66,6 +66,10 @@ zen-panel-ui-gradient-click-to-add = Click to add a color
|
|||||||
zen-workspace-creation-name =
|
zen-workspace-creation-name =
|
||||||
.placeholder = Space Name
|
.placeholder = Space Name
|
||||||
|
|
||||||
|
zen-move-tab-to-workspace-button =
|
||||||
|
.label = Move To...
|
||||||
|
.tooltiptext = Move all tabs in this window to a Space
|
||||||
|
|
||||||
zen-workspaces-panel-context-reorder =
|
zen-workspaces-panel-context-reorder =
|
||||||
.label = Reorder Spaces
|
.label = Reorder Spaces
|
||||||
|
|
||||||
|
|||||||
9
prefs/zen/session-store.yaml
Normal file
9
prefs/zen/session-store.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
- name: zen.session-store.backup-file
|
||||||
|
value: true
|
||||||
|
|
||||||
|
- name: zen.session-store.log
|
||||||
|
value: false
|
||||||
@@ -40,12 +40,6 @@
|
|||||||
- name: zen.view.window.scheme
|
- name: zen.view.window.scheme
|
||||||
value: 2
|
value: 2
|
||||||
|
|
||||||
- name: zen.view.drag-and-drop.move-over-threshold
|
|
||||||
value: 70
|
|
||||||
|
|
||||||
- name: zen.view.drag-and-drop.edge-zone-threshold
|
|
||||||
value: 25
|
|
||||||
|
|
||||||
- name: zen.view.context-menu.refresh
|
- name: zen.view.context-menu.refresh
|
||||||
value: false
|
value: false
|
||||||
|
|
||||||
|
|||||||
9
prefs/zen/window-sync.yaml
Normal file
9
prefs/zen/window-sync.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
- name: zen.window-sync.enabled
|
||||||
|
value: true
|
||||||
|
|
||||||
|
- name: zen.window-sync.log
|
||||||
|
value: false
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
# Scripts used all over the browser
|
# Scripts used all over the browser
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenFolder.mjs"></script>
|
<script type="module" src="chrome://browser/content/zen-components/ZenFolder.mjs"></script>
|
||||||
|
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenPinnedTabsStorage.mjs"></script>
|
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenWorkspacesStorage.mjs"></script>
|
<script type="module" src="chrome://browser/content/zen-components/ZenWorkspacesStorage.mjs"></script>
|
||||||
|
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenMediaController.mjs"></script>
|
<script type="module" src="chrome://browser/content/zen-components/ZenMediaController.mjs"></script>
|
||||||
|
|||||||
@@ -59,3 +59,8 @@
|
|||||||
<menuseparator />
|
<menuseparator />
|
||||||
<menuitem id="context_zenOpenSiteSettings" data-l10n-id="zen-site-data-site-settings"/>
|
<menuitem id="context_zenOpenSiteSettings" data-l10n-id="zen-site-data-site-settings"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
|
|
||||||
|
<menupopup id="zenMoveTabsToSyncedWorkspacePopup">
|
||||||
|
# Popup to move tabs to a synced workspace.
|
||||||
|
# This would be automatically populated with the list of available synced workspaces.
|
||||||
|
</menupopup>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
# the window is fully loaded.
|
# the window is fully loaded.
|
||||||
# Make sure they are loaded before the global-scripts.inc file.
|
# Make sure they are loaded before the global-scripts.inc file.
|
||||||
<script type="text/javascript" src="chrome://browser/content/zen-sets.js"></script>
|
<script type="text/javascript" src="chrome://browser/content/zen-sets.js"></script>
|
||||||
<script type="text/javascript" src="chrome://browser/content/zen-components/ZenWorkspacesSync.mjs"></script>
|
|
||||||
|
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenHasPolyfill.mjs"></script>
|
<script type="module" src="chrome://browser/content/zen-components/ZenHasPolyfill.mjs"></script>
|
||||||
<script type="module" src="chrome://browser/content/zen-components/ZenWorkspaces.mjs"></script>
|
<script type="module" src="chrome://browser/content/zen-components/ZenWorkspaces.mjs"></script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/places/content/editBookmark.js b/browser/components/places/content/editBookmark.js
|
diff --git a/browser/components/places/content/editBookmark.js b/browser/components/places/content/editBookmark.js
|
||||||
index f562f19741d882d92365da531b55e2810a0e79ea..9339e1158b074c41fc19bf91cbfde3c4016594b9 100644
|
index f562f19741d882d92365da531b55e2810a0e79ea..a68ce8191314845c589f3a9f14b56028e0532628 100644
|
||||||
--- a/browser/components/places/content/editBookmark.js
|
--- a/browser/components/places/content/editBookmark.js
|
||||||
+++ b/browser/components/places/content/editBookmark.js
|
+++ b/browser/components/places/content/editBookmark.js
|
||||||
@@ -387,6 +387,10 @@ var gEditItemOverlay = {
|
@@ -387,6 +387,10 @@ var gEditItemOverlay = {
|
||||||
@@ -31,34 +31,11 @@ index f562f19741d882d92365da531b55e2810a0e79ea..9339e1158b074c41fc19bf91cbfde3c4
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1280,6 +1288,148 @@ var gEditItemOverlay = {
|
@@ -1280,6 +1288,128 @@ var gEditItemOverlay = {
|
||||||
get bookmarkState() {
|
get bookmarkState() {
|
||||||
return this._bookmarkState;
|
return this._bookmarkState;
|
||||||
},
|
},
|
||||||
+
|
+
|
||||||
+ async _initWorkspaceSelector() {
|
|
||||||
+ if(document.documentElement.getAttribute("windowtype") === "Places:Organizer") {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ this._workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
|
||||||
+
|
|
||||||
+ const selectElement = this._workspaceSelect;
|
|
||||||
+
|
|
||||||
+ // Clear any existing options
|
|
||||||
+ while (selectElement.firstChild) {
|
|
||||||
+ selectElement.removeChild(selectElement.firstChild);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // For each workspace, create an option element
|
|
||||||
+ for (let workspace of this._workspaces) {
|
|
||||||
+ const option = document.createElementNS("http://www.w3.org/1999/xhtml", "option");
|
|
||||||
+ option.textContent = workspace.name;
|
|
||||||
+ option.value = workspace.uuid;
|
|
||||||
+ selectElement.appendChild(option);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ selectElement.disabled = this.readOnly;
|
|
||||||
+ },
|
|
||||||
+ async onWorkspaceSelectionChange(event) {
|
+ async onWorkspaceSelectionChange(event) {
|
||||||
+ if(document.documentElement.getAttribute("windowtype") === "Places:Organizer") {
|
+ if(document.documentElement.getAttribute("windowtype") === "Places:Organizer") {
|
||||||
+ return;
|
+ return;
|
||||||
@@ -129,7 +106,10 @@ index f562f19741d882d92365da531b55e2810a0e79ea..9339e1158b074c41fc19bf91cbfde3c4
|
|||||||
+ if(document.documentElement.getAttribute("windowtype") === "Places:Organizer") {
|
+ if(document.documentElement.getAttribute("windowtype") === "Places:Organizer") {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ this._workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
+ const { ZenSessionStore } = ChromeUtils.importESModule(
|
||||||
|
+ "resource:///modules/zen/ZenSessionManager.sys.mjs"
|
||||||
|
+ );
|
||||||
|
+ this._workspaces = ZenSessionStore.getClonedSpaces();
|
||||||
+ const workspaceList = this._workspaceList;
|
+ const workspaceList = this._workspaceList;
|
||||||
+ if(aInfo.node?.bookmarkGuid) {
|
+ if(aInfo.node?.bookmarkGuid) {
|
||||||
+ this._selectedWorkspaces = await ZenWorkspaceBookmarksStorage.getBookmarkWorkspaces(aInfo.node.bookmarkGuid);
|
+ this._selectedWorkspaces = await ZenWorkspaceBookmarksStorage.getBookmarkWorkspaces(aInfo.node.bookmarkGuid);
|
||||||
@@ -180,7 +160,7 @@ index f562f19741d882d92365da531b55e2810a0e79ea..9339e1158b074c41fc19bf91cbfde3c4
|
|||||||
};
|
};
|
||||||
|
|
||||||
ChromeUtils.defineLazyGetter(gEditItemOverlay, "_folderTree", () => {
|
ChromeUtils.defineLazyGetter(gEditItemOverlay, "_folderTree", () => {
|
||||||
@@ -1318,6 +1468,9 @@ for (let elt of [
|
@@ -1318,6 +1448,9 @@ for (let elt of [
|
||||||
"locationField",
|
"locationField",
|
||||||
"keywordField",
|
"keywordField",
|
||||||
"tagsField",
|
"tagsField",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
diff --git a/browser/components/sessionstore/SessionFile.sys.mjs b/browser/components/sessionstore/SessionFile.sys.mjs
|
||||||
|
index 31140cb8be3b529a0952ca8dc55165690b0e2120..605c9e0aa84da0a2d3171a0573e8cd95e27bd0c4 100644
|
||||||
|
--- a/browser/components/sessionstore/SessionFile.sys.mjs
|
||||||
|
+++ b/browser/components/sessionstore/SessionFile.sys.mjs
|
||||||
|
@@ -22,6 +22,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
RunState: "resource:///modules/sessionstore/RunState.sys.mjs",
|
||||||
|
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
||||||
|
SessionWriter: "resource:///modules/sessionstore/SessionWriter.sys.mjs",
|
||||||
|
+ ZenSessionStore: "resource:///modules/zen/ZenSessionManager.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
const PREF_UPGRADE_BACKUP = "browser.sessionstore.upgradeBackup.latestBuildID";
|
||||||
|
@@ -380,7 +381,7 @@ var SessionFileInternal = {
|
||||||
|
this._readOrigin = result.origin;
|
||||||
|
|
||||||
|
result.noFilesFound = noFilesFound;
|
||||||
|
-
|
||||||
|
+ await lazy.ZenSessionStore.readFile();
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
diff --git a/browser/components/sessionstore/SessionSaver.sys.mjs b/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||||
|
index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..f00314ebf75ac826e1c9cca8af264ff8aae106c0 100644
|
||||||
|
--- a/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||||
|
+++ b/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||||
|
@@ -20,6 +20,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
SessionFile: "resource:///modules/sessionstore/SessionFile.sys.mjs",
|
||||||
|
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
||||||
|
sessionStoreLogger: "resource:///modules/sessionstore/SessionLogger.sys.mjs",
|
||||||
|
+ ZenSessionStore: "resource:///modules/zen/ZenSessionManager.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -305,6 +306,7 @@ var SessionSaverInternal = {
|
||||||
|
this._maybeClearCookiesAndStorage(state);
|
||||||
|
|
||||||
|
Glean.sessionRestore.collectData.stopAndAccumulate(timerId);
|
||||||
|
+ lazy.ZenSessionStore.saveState(state);
|
||||||
|
return this._writeState(state);
|
||||||
|
},
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
diff --git a/browser/components/sessionstore/SessionStartup.sys.mjs b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||||
|
index be23213ae9ec7e59358a17276c6c3764d38d9996..ca5a8ccc916ceeab5140f1278d15233cefbe5815 100644
|
||||||
|
--- a/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||||
|
+++ b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||||
|
@@ -40,6 +40,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
StartupPerformance:
|
||||||
|
"resource:///modules/sessionstore/StartupPerformance.sys.mjs",
|
||||||
|
sessionStoreLogger: "resource:///modules/sessionstore/SessionLogger.sys.mjs",
|
||||||
|
+ ZenSessionStore: "resource:///modules/zen/ZenSessionManager.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
const STATE_RUNNING_STR = "running";
|
||||||
|
@@ -179,6 +180,8 @@ export var SessionStartup = {
|
||||||
|
this._initialState = parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ lazy.ZenSessionStore.onFileRead(this._initialState);
|
||||||
|
+
|
||||||
|
if (this._initialState == null) {
|
||||||
|
// No valid session found.
|
||||||
|
this._sessionType = this.NO_SESSION;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||||
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb22176c60c4e 100644
|
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..5ce4eb0b21cf4ed2b8e7c6ad0c57e77416a2ab48 100644
|
||||||
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
||||||
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||||
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
|
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
|
||||||
@@ -11,7 +11,15 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
];
|
];
|
||||||
|
|
||||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
@@ -1911,6 +1913,8 @@ var SessionStoreInternal = {
|
@@ -196,6 +198,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs",
|
||||||
|
TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.sys.mjs",
|
||||||
|
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||||
|
+ ZenSessionStore: "resource:///modules/zen/ZenSessionManager.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
ChromeUtils.defineLazyGetter(lazy, "blankURI", () => {
|
||||||
|
@@ -1911,6 +1914,8 @@ var SessionStoreInternal = {
|
||||||
case "TabPinned":
|
case "TabPinned":
|
||||||
case "TabUnpinned":
|
case "TabUnpinned":
|
||||||
case "SwapDocShells":
|
case "SwapDocShells":
|
||||||
@@ -20,19 +28,68 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
this.saveStateDelayed(win);
|
this.saveStateDelayed(win);
|
||||||
break;
|
break;
|
||||||
case "TabGroupCreate":
|
case "TabGroupCreate":
|
||||||
@@ -2384,11 +2388,9 @@ var SessionStoreInternal = {
|
@@ -2020,6 +2025,10 @@ var SessionStoreInternal = {
|
||||||
tabbrowser.selectedTab.label;
|
this._windows[aWindow.__SSi].isTaskbarTab = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (aWindow.document.documentElement.hasAttribute("zen-unsynced-window")) {
|
||||||
|
+ this._windows[aWindow.__SSi].isZenUnsynced = true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
let tabbrowser = aWindow.gBrowser;
|
||||||
|
|
||||||
|
// add tab change listeners to all already existing tabs
|
||||||
|
@@ -2151,7 +2160,6 @@ var SessionStoreInternal = {
|
||||||
|
if (closedWindowState) {
|
||||||
|
let newWindowState;
|
||||||
|
if (
|
||||||
|
- AppConstants.platform == "macosx" ||
|
||||||
|
!lazy.SessionStartup.willRestore()
|
||||||
|
) {
|
||||||
|
// We want to split the window up into pinned tabs and unpinned tabs.
|
||||||
|
@@ -2215,6 +2223,15 @@ var SessionStoreInternal = {
|
||||||
|
});
|
||||||
|
this._shouldRestoreLastSession = false;
|
||||||
|
}
|
||||||
|
+ else if (!aInitialState && isRegularWindow) {
|
||||||
|
+ let windowPromises = [];
|
||||||
|
+ for (let window of this._browserWindows) {
|
||||||
|
+ windowPromises.push(lazy.TabStateFlusher.flushWindow(window));
|
||||||
|
+ }
|
||||||
|
+ Promise.all(windowPromises).finally(() => {
|
||||||
|
+ lazy.ZenSessionStore.restoreNewWindow(aWindow, this);
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (this._restoreLastWindow && aWindow.toolbar.visible) {
|
||||||
|
// always reset (if not a popup window)
|
||||||
|
@@ -2465,7 +2482,7 @@ var SessionStoreInternal = {
|
||||||
|
// 2) Flush the window.
|
||||||
|
// 3) When the flush is complete, revisit our decision to store the window
|
||||||
|
// in _closedWindows, and add/remove as necessary.
|
||||||
|
- if (!winData.isPrivate && !winData.isTaskbarTab) {
|
||||||
|
+ if (!winData.isPrivate && !winData.isTaskbarTab && !winData.isZenUnsynced) {
|
||||||
|
this.maybeSaveClosedWindow(winData, isLastWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
- if (AppConstants.platform != "macosx") {
|
@@ -2486,7 +2503,7 @@ var SessionStoreInternal = {
|
||||||
// Until we decide otherwise elsewhere, this window is part of a series
|
|
||||||
// of closing windows to quit.
|
|
||||||
winData._shouldRestore = true;
|
|
||||||
- }
|
|
||||||
|
|
||||||
// Store the window's close date to figure out when each individual tab
|
// Save non-private windows if they have at
|
||||||
// was closed. This timestamp should allow re-arranging data based on how
|
// least one saveable tab or are the last window.
|
||||||
@@ -3373,7 +3375,7 @@ var SessionStoreInternal = {
|
- if (!winData.isPrivate && !winData.isTaskbarTab) {
|
||||||
|
+ if (!winData.isPrivate && !winData.isTaskbarTab && !winData.isZenUnsynced) {
|
||||||
|
this.maybeSaveClosedWindow(winData, isLastWindow);
|
||||||
|
|
||||||
|
if (!isLastWindow && winData.closedId > -1) {
|
||||||
|
@@ -2582,6 +2599,7 @@ var SessionStoreInternal = {
|
||||||
|
let alreadyStored = winIndex != -1;
|
||||||
|
// If sidebar command is truthy, i.e. sidebar is open, store sidebar settings
|
||||||
|
let shouldStore = hasSaveableTabs || isLastWindow;
|
||||||
|
+ lazy.ZenSessionStore.maybeSaveClosedWindow(winData, isLastWindow);
|
||||||
|
|
||||||
|
if (shouldStore && !alreadyStored) {
|
||||||
|
let index = this._closedWindows.findIndex(win => {
|
||||||
|
@@ -3373,7 +3391,7 @@ var SessionStoreInternal = {
|
||||||
if (!isPrivateWindow && tabState.isPrivate) {
|
if (!isPrivateWindow && tabState.isPrivate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,12 +98,12 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4089,6 +4091,12 @@ var SessionStoreInternal = {
|
@@ -4089,6 +4107,12 @@ var SessionStoreInternal = {
|
||||||
Math.min(tabState.index, tabState.entries.length)
|
Math.min(tabState.index, tabState.entries.length)
|
||||||
);
|
);
|
||||||
tabState.pinned = false;
|
tabState.pinned = false;
|
||||||
+ tabState.zenEssential = false;
|
+ tabState.zenEssential = false;
|
||||||
+ tabState.zenPinnedId = null;
|
+ tabState.zenSyncId = null;
|
||||||
+ tabState.zenIsGlance = false;
|
+ tabState.zenIsGlance = false;
|
||||||
+ tabState.zenGlanceId = null;
|
+ tabState.zenGlanceId = null;
|
||||||
+ tabState.zenHasStaticLabel = false;
|
+ tabState.zenHasStaticLabel = false;
|
||||||
@@ -54,7 +111,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
|
|
||||||
if (inBackground === false) {
|
if (inBackground === false) {
|
||||||
aWindow.gBrowser.selectedTab = newTab;
|
aWindow.gBrowser.selectedTab = newTab;
|
||||||
@@ -4525,6 +4533,7 @@ var SessionStoreInternal = {
|
@@ -4525,6 +4549,7 @@ var SessionStoreInternal = {
|
||||||
// Append the tab if we're opening into a different window,
|
// Append the tab if we're opening into a different window,
|
||||||
tabIndex: aSource == aTargetWindow ? pos : Infinity,
|
tabIndex: aSource == aTargetWindow ? pos : Infinity,
|
||||||
pinned: state.pinned,
|
pinned: state.pinned,
|
||||||
@@ -62,7 +119,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
userContextId: state.userContextId,
|
userContextId: state.userContextId,
|
||||||
skipLoad: true,
|
skipLoad: true,
|
||||||
preferredRemoteType,
|
preferredRemoteType,
|
||||||
@@ -5374,7 +5383,7 @@ var SessionStoreInternal = {
|
@@ -5374,7 +5399,7 @@ var SessionStoreInternal = {
|
||||||
|
|
||||||
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
|
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
|
||||||
let tab = tabbrowser.tabs[i];
|
let tab = tabbrowser.tabs[i];
|
||||||
@@ -71,16 +128,16 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
removableTabs.push(tab);
|
removableTabs.push(tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5434,7 +5443,7 @@ var SessionStoreInternal = {
|
@@ -5483,7 +5508,7 @@ var SessionStoreInternal = {
|
||||||
}
|
|
||||||
|
|
||||||
let workspaceID = aWindow.getWorkspaceID();
|
// collect the data for all windows
|
||||||
- if (workspaceID) {
|
for (ix in this._windows) {
|
||||||
+ if (workspaceID && !(this.isLastRestorableWindow() && AppConstants.platform == "macosx")) {
|
- if (this._windows[ix]._restoring || this._windows[ix].isTaskbarTab) {
|
||||||
winData.workspaceID = workspaceID;
|
+ if (this._windows[ix]._restoring || this._windows[ix].isTaskbarTab || this._windows[ix].isZenUnsynced) {
|
||||||
}
|
// window data is still in _statesToRestore
|
||||||
},
|
continue;
|
||||||
@@ -5625,11 +5634,12 @@ var SessionStoreInternal = {
|
}
|
||||||
|
@@ -5625,11 +5650,16 @@ var SessionStoreInternal = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let tabbrowser = aWindow.gBrowser;
|
let tabbrowser = aWindow.gBrowser;
|
||||||
@@ -90,19 +147,15 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
let winData = this._windows[aWindow.__SSi];
|
let winData = this._windows[aWindow.__SSi];
|
||||||
let tabsData = (winData.tabs = []);
|
let tabsData = (winData.tabs = []);
|
||||||
|
|
||||||
|
+ winData.activeZenSpace = aWindow.gZenWorkspaces?.activeWorkspace || null;
|
||||||
+ winData.splitViewData = aWindow.gZenViewSplitter?.storeDataForSessionStore();
|
+ winData.splitViewData = aWindow.gZenViewSplitter?.storeDataForSessionStore();
|
||||||
|
+ winData.folders = aWindow.gZenFolders?.storeDataForSessionStore() || [];
|
||||||
|
+ winData.spaces = aWindow.gZenWorkspaces?.getWorkspaces();
|
||||||
|
+
|
||||||
// update the internal state data for this window
|
// update the internal state data for this window
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
if (tab == aWindow.FirefoxViewHandler.tab) {
|
if (tab == aWindow.FirefoxViewHandler.tab) {
|
||||||
@@ -5640,6 +5650,7 @@ var SessionStoreInternal = {
|
@@ -5652,7 +5682,7 @@ var SessionStoreInternal = {
|
||||||
tabsData.push(tabData);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ winData.folders = aWindow.gZenFolders?.storeDataForSessionStore() || [];
|
|
||||||
// update tab group state for this window
|
|
||||||
winData.groups = [];
|
|
||||||
for (let tabGroup of aWindow.gBrowser.tabGroups) {
|
|
||||||
@@ -5652,7 +5663,7 @@ var SessionStoreInternal = {
|
|
||||||
// a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab,
|
// a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab,
|
||||||
// since it's only inserted into the tab strip after it's selected).
|
// since it's only inserted into the tab strip after it's selected).
|
||||||
if (aWindow.FirefoxViewHandler.tab?.selected) {
|
if (aWindow.FirefoxViewHandler.tab?.selected) {
|
||||||
@@ -111,7 +164,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
winData.title = tabbrowser.tabs[0].label;
|
winData.title = tabbrowser.tabs[0].label;
|
||||||
}
|
}
|
||||||
winData.selected = selectedIndex;
|
winData.selected = selectedIndex;
|
||||||
@@ -5765,8 +5776,8 @@ var SessionStoreInternal = {
|
@@ -5765,8 +5795,8 @@ var SessionStoreInternal = {
|
||||||
// selectTab represents.
|
// selectTab represents.
|
||||||
let selectTab = 0;
|
let selectTab = 0;
|
||||||
if (overwriteTabs) {
|
if (overwriteTabs) {
|
||||||
@@ -122,16 +175,17 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
selectTab = Math.min(selectTab, winData.tabs.length);
|
selectTab = Math.min(selectTab, winData.tabs.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5809,6 +5820,8 @@ var SessionStoreInternal = {
|
@@ -5809,6 +5839,9 @@ var SessionStoreInternal = {
|
||||||
winData.tabs,
|
winData.tabs,
|
||||||
winData.groups ?? []
|
winData.groups ?? []
|
||||||
);
|
);
|
||||||
+ aWindow.gZenFolders?.restoreDataFromSessionStore(winData.folders);
|
+ aWindow.gZenFolders?.restoreDataFromSessionStore(winData.folders);
|
||||||
+ aWindow.gZenViewSplitter?.restoreDataFromSessionStore(winData.splitViewData);
|
+ aWindow.gZenViewSplitter?.restoreDataFromSessionStore(winData.splitViewData);
|
||||||
|
+ aWindow.gZenWorkspaces?.restoreWorkspacesFromSessionStore(winData);
|
||||||
this._log.debug(
|
this._log.debug(
|
||||||
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
|
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
|
||||||
);
|
);
|
||||||
@@ -6372,6 +6385,25 @@ var SessionStoreInternal = {
|
@@ -6372,6 +6405,25 @@ var SessionStoreInternal = {
|
||||||
|
|
||||||
// Most of tabData has been restored, now continue with restoring
|
// Most of tabData has been restored, now continue with restoring
|
||||||
// attributes that may trigger external events.
|
// attributes that may trigger external events.
|
||||||
@@ -145,8 +199,8 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
+ if (tabData.zenHasStaticLabel) {
|
+ if (tabData.zenHasStaticLabel) {
|
||||||
+ tab.setAttribute("zen-has-static-label", "true");
|
+ tab.setAttribute("zen-has-static-label", "true");
|
||||||
+ }
|
+ }
|
||||||
+ if (tabData.zenPinnedId) {
|
+ if (tabData.zenSyncId) {
|
||||||
+ tab.setAttribute("zen-pin-id", tabData.zenPinnedId);
|
+ tab.setAttribute("id", tabData.zenSyncId);
|
||||||
+ }
|
+ }
|
||||||
+ if (tabData.zenDefaultUserContextId) {
|
+ if (tabData.zenDefaultUserContextId) {
|
||||||
+ tab.setAttribute("zenDefaultUserContextId", true);
|
+ tab.setAttribute("zenDefaultUserContextId", true);
|
||||||
@@ -157,7 +211,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
|
|
||||||
if (tabData.pinned) {
|
if (tabData.pinned) {
|
||||||
tabbrowser.pinTab(tab);
|
tabbrowser.pinTab(tab);
|
||||||
@@ -7290,7 +7322,7 @@ var SessionStoreInternal = {
|
@@ -7290,7 +7342,7 @@ var SessionStoreInternal = {
|
||||||
|
|
||||||
let groupsToSave = new Map();
|
let groupsToSave = new Map();
|
||||||
for (let tIndex = 0; tIndex < window.tabs.length; ) {
|
for (let tIndex = 0; tIndex < window.tabs.length; ) {
|
||||||
@@ -166,7 +220,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..61bfa1b530c407dd1236543f785eb221
|
|||||||
// Adjust window.selected
|
// Adjust window.selected
|
||||||
if (tIndex + 1 < window.selected) {
|
if (tIndex + 1 < window.selected) {
|
||||||
window.selected -= 1;
|
window.selected -= 1;
|
||||||
@@ -7305,7 +7337,7 @@ var SessionStoreInternal = {
|
@@ -7305,7 +7357,7 @@ var SessionStoreInternal = {
|
||||||
);
|
);
|
||||||
// We don't want to increment tIndex here.
|
// We don't want to increment tIndex here.
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
|
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
|
||||||
index 82721356d191055bec0d4b0ca49e481221988801..1ea5c394c704da295149443d7794961a12f2060b 100644
|
index 82721356d191055bec0d4b0ca49e481221988801..80547ec951f881bef134b637730954eb1525c623 100644
|
||||||
--- a/browser/components/sessionstore/TabState.sys.mjs
|
--- a/browser/components/sessionstore/TabState.sys.mjs
|
||||||
+++ b/browser/components/sessionstore/TabState.sys.mjs
|
+++ b/browser/components/sessionstore/TabState.sys.mjs
|
||||||
@@ -85,7 +85,22 @@ class _TabState {
|
@@ -85,7 +85,24 @@ class _TabState {
|
||||||
tabData.groupId = tab.group.id;
|
tabData.groupId = tab.group.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ tabData.zenWorkspace = tab.getAttribute("zen-workspace-id");
|
+ tabData.zenWorkspace = tab.getAttribute("zen-workspace-id");
|
||||||
+ tabData.zenPinnedId = tab.getAttribute("zen-pin-id");
|
+ tabData.zenSyncId = tab.getAttribute("id");
|
||||||
+ tabData.zenEssential = tab.getAttribute("zen-essential");
|
+ tabData.zenEssential = tab.getAttribute("zen-essential");
|
||||||
+ tabData.pinned = tabData.pinned || tabData.zenEssential;
|
+ tabData.pinned = tabData.pinned || tabData.zenEssential;
|
||||||
+ tabData.zenDefaultUserContextId = tab.getAttribute("zenDefaultUserContextId");
|
+ tabData.zenDefaultUserContextId = tab.getAttribute("zenDefaultUserContextId");
|
||||||
@@ -17,6 +17,8 @@ index 82721356d191055bec0d4b0ca49e481221988801..1ea5c394c704da295149443d7794961a
|
|||||||
+ tabData.zenHasStaticLabel = tab.hasAttribute("zen-has-static-label");
|
+ tabData.zenHasStaticLabel = tab.hasAttribute("zen-has-static-label");
|
||||||
+ tabData.zenGlanceId = tab.getAttribute("glance-id");
|
+ tabData.zenGlanceId = tab.getAttribute("glance-id");
|
||||||
+ tabData.zenIsGlance = tab.hasAttribute("zen-glance-tab");
|
+ tabData.zenIsGlance = tab.hasAttribute("zen-glance-tab");
|
||||||
|
+ tabData._zenPinnedInitialState = tab._zenPinnedInitialState;
|
||||||
|
+ tabData._zenIsActiveTab = tab._zenContentsVisible;
|
||||||
+
|
+
|
||||||
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
|
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
|
||||||
+ if (tabData.searchMode?.source === tab.ownerGlobal.UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS) {
|
+ if (tabData.searchMode?.source === tab.ownerGlobal.UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS) {
|
||||||
@@ -25,3 +27,12 @@ index 82721356d191055bec0d4b0ca49e481221988801..1ea5c394c704da295149443d7794961a
|
|||||||
|
|
||||||
tabData.userContextId = tab.userContextId || 0;
|
tabData.userContextId = tab.userContextId || 0;
|
||||||
|
|
||||||
|
@@ -98,7 +115,7 @@ class _TabState {
|
||||||
|
|
||||||
|
// Copy data from the tab state cache only if the tab has fully finished
|
||||||
|
// restoring. We don't want to overwrite data contained in __SS_data.
|
||||||
|
- this.copyFromCache(browser.permanentKey, tabData, options);
|
||||||
|
+ this.copyFromCache(tab.permanentKey, tabData, options);
|
||||||
|
|
||||||
|
// After copyFromCache() was called we check for properties that are kept
|
||||||
|
// in the cache only while the tab is pending or restoring. Once that
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/drag-and-drop.js b/browser/components/tabbrowser/content/drag-and-drop.js
|
diff --git a/browser/components/tabbrowser/content/drag-and-drop.js b/browser/components/tabbrowser/content/drag-and-drop.js
|
||||||
index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9548dce83 100644
|
index 97b931c3c7385a52d20204369fcf6d6999053687..b028c923d24adf0e9dbe12f80deb3ad4fda535eb 100644
|
||||||
--- a/browser/components/tabbrowser/content/drag-and-drop.js
|
--- a/browser/components/tabbrowser/content/drag-and-drop.js
|
||||||
+++ b/browser/components/tabbrowser/content/drag-and-drop.js
|
+++ b/browser/components/tabbrowser/content/drag-and-drop.js
|
||||||
@@ -32,6 +32,9 @@
|
@@ -32,6 +32,9 @@
|
||||||
@@ -12,18 +12,17 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
if (isTab(element)) {
|
if (isTab(element)) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@@ -112,6 +115,10 @@
|
@@ -112,6 +115,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
|
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||||
+ if (draggedTab && dropEffect === "move") {
|
+ if (draggedTab && dropEffect === "move") {
|
||||||
+ gZenPinnedTabManager.applyDragoverClass(event, draggedTab);
|
|
||||||
+ gZenViewSplitter.onBrowserDragEndToSplit(event);
|
+ gZenViewSplitter.onBrowserDragEndToSplit(event);
|
||||||
+ }
|
+ }
|
||||||
if (
|
if (
|
||||||
(dropEffect == "move" || dropEffect == "copy") &&
|
(dropEffect == "move" || dropEffect == "copy") &&
|
||||||
document == draggedTab.ownerDocument &&
|
document == draggedTab.ownerDocument &&
|
||||||
@@ -266,6 +273,18 @@
|
@@ -266,6 +272,18 @@
|
||||||
|
|
||||||
this._tabDropIndicator.hidden = true;
|
this._tabDropIndicator.hidden = true;
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -42,7 +41,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
if (draggedTab && dropEffect == "copy") {
|
if (draggedTab && dropEffect == "copy") {
|
||||||
let duplicatedDraggedTab;
|
let duplicatedDraggedTab;
|
||||||
let duplicatedTabs = [];
|
let duplicatedTabs = [];
|
||||||
@@ -291,8 +310,9 @@
|
@@ -291,8 +309,9 @@
|
||||||
let translateOffsetY = oldTranslateY % tabHeight;
|
let translateOffsetY = oldTranslateY % tabHeight;
|
||||||
let newTranslateX = oldTranslateX - translateOffsetX;
|
let newTranslateX = oldTranslateX - translateOffsetX;
|
||||||
let newTranslateY = oldTranslateY - translateOffsetY;
|
let newTranslateY = oldTranslateY - translateOffsetY;
|
||||||
@@ -54,7 +53,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
|
|
||||||
if (this._isContainerVerticalPinnedGrid(draggedTab)) {
|
if (this._isContainerVerticalPinnedGrid(draggedTab)) {
|
||||||
// Update both translate axis for pinned vertical expanded tabs
|
// Update both translate axis for pinned vertical expanded tabs
|
||||||
@@ -308,8 +328,8 @@
|
@@ -308,8 +327,8 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let tabs = this._tabbrowserTabs.ariaFocusableItems.slice(
|
let tabs = this._tabbrowserTabs.ariaFocusableItems.slice(
|
||||||
@@ -65,7 +64,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
);
|
);
|
||||||
let size = this._tabbrowserTabs.verticalMode ? "height" : "width";
|
let size = this._tabbrowserTabs.verticalMode ? "height" : "width";
|
||||||
let screenAxis = this._tabbrowserTabs.verticalMode
|
let screenAxis = this._tabbrowserTabs.verticalMode
|
||||||
@@ -362,11 +382,13 @@
|
@@ -362,11 +381,13 @@
|
||||||
this._dragToPinPromoCard,
|
this._dragToPinPromoCard,
|
||||||
];
|
];
|
||||||
let shouldPin =
|
let shouldPin =
|
||||||
@@ -79,7 +78,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
isTab(draggedTab) &&
|
isTab(draggedTab) &&
|
||||||
draggedTab.pinned &&
|
draggedTab.pinned &&
|
||||||
this._tabbrowserTabs.arrowScrollbox.contains(event.target);
|
this._tabbrowserTabs.arrowScrollbox.contains(event.target);
|
||||||
@@ -384,6 +406,7 @@
|
@@ -384,6 +405,7 @@
|
||||||
(oldTranslateY && oldTranslateY != newTranslateY);
|
(oldTranslateY && oldTranslateY != newTranslateY);
|
||||||
} else if (this._tabbrowserTabs.verticalMode) {
|
} else if (this._tabbrowserTabs.verticalMode) {
|
||||||
shouldTranslate &&= oldTranslateY && oldTranslateY != newTranslateY;
|
shouldTranslate &&= oldTranslateY && oldTranslateY != newTranslateY;
|
||||||
@@ -87,7 +86,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
} else {
|
} else {
|
||||||
shouldTranslate &&= oldTranslateX && oldTranslateX != newTranslateX;
|
shouldTranslate &&= oldTranslateX && oldTranslateX != newTranslateX;
|
||||||
}
|
}
|
||||||
@@ -440,7 +463,7 @@
|
@@ -440,7 +462,7 @@
|
||||||
item.removeAttribute("tabdrop-samewindow");
|
item.removeAttribute("tabdrop-samewindow");
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
@@ -96,7 +95,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
postTransitionCleanup();
|
postTransitionCleanup();
|
||||||
} else {
|
} else {
|
||||||
let onTransitionEnd = transitionendEvent => {
|
let onTransitionEnd = transitionendEvent => {
|
||||||
@@ -581,6 +604,7 @@
|
@@ -581,6 +603,7 @@
|
||||||
|
|
||||||
let nextItem = this._tabbrowserTabs.ariaFocusableItems[newIndex];
|
let nextItem = this._tabbrowserTabs.ariaFocusableItems[newIndex];
|
||||||
let tabGroup = isTab(nextItem) && nextItem.group;
|
let tabGroup = isTab(nextItem) && nextItem.group;
|
||||||
@@ -104,7 +103,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
gBrowser.loadTabs(urls, {
|
gBrowser.loadTabs(urls, {
|
||||||
inBackground,
|
inBackground,
|
||||||
replace,
|
replace,
|
||||||
@@ -618,7 +642,16 @@
|
@@ -618,7 +641,16 @@
|
||||||
this._expandGroupOnDrop(draggedTab);
|
this._expandGroupOnDrop(draggedTab);
|
||||||
}
|
}
|
||||||
this._resetTabsAfterDrop(draggedTab.ownerDocument);
|
this._resetTabsAfterDrop(draggedTab.ownerDocument);
|
||||||
@@ -122,7 +121,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
if (
|
if (
|
||||||
dt.mozUserCancelled ||
|
dt.mozUserCancelled ||
|
||||||
dt.dropEffect != "none" ||
|
dt.dropEffect != "none" ||
|
||||||
@@ -822,7 +855,10 @@
|
@@ -822,7 +854,10 @@
|
||||||
_getDragTarget(event, { ignoreSides = false } = {}) {
|
_getDragTarget(event, { ignoreSides = false } = {}) {
|
||||||
let { target } = event;
|
let { target } = event;
|
||||||
while (target) {
|
while (target) {
|
||||||
@@ -134,7 +133,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
@@ -839,14 +875,17 @@
|
@@ -839,14 +874,17 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +153,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
!this._tabbrowserTabs.expandOnHover
|
!this._tabbrowserTabs.expandOnHover
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -877,7 +916,8 @@
|
@@ -877,7 +915,8 @@
|
||||||
isTabGroupLabel(draggedTab) &&
|
isTabGroupLabel(draggedTab) &&
|
||||||
draggedTab._dragData?.expandGroupOnDrop
|
draggedTab._dragData?.expandGroupOnDrop
|
||||||
) {
|
) {
|
||||||
@@ -164,7 +163,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,10 +982,7 @@
|
@@ -942,10 +981,7 @@
|
||||||
if (this._isContainerVerticalPinnedGrid(tab)) {
|
if (this._isContainerVerticalPinnedGrid(tab)) {
|
||||||
// In expanded vertical mode, the max number of pinned tabs per row is dynamic
|
// In expanded vertical mode, the max number of pinned tabs per row is dynamic
|
||||||
// Set this before adjusting dragged tab's position
|
// Set this before adjusting dragged tab's position
|
||||||
@@ -176,7 +175,23 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
let tabsPerRow = 0;
|
let tabsPerRow = 0;
|
||||||
let position = RTL_UI
|
let position = RTL_UI
|
||||||
? window.windowUtils.getBoundsWithoutFlushing(
|
? window.windowUtils.getBoundsWithoutFlushing(
|
||||||
@@ -1112,7 +1149,7 @@
|
@@ -1055,7 +1091,6 @@
|
||||||
|
// using updateDragImage. On Linux, we can use a panel.
|
||||||
|
if (platform == "win" || platform == "macosx") {
|
||||||
|
captureListener = function () {
|
||||||
|
- dt.updateDragImage(canvas, dragImageOffset, dragImageOffset);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Create a panel to use it in setDragImage
|
||||||
|
@@ -1093,7 +1128,6 @@
|
||||||
|
);
|
||||||
|
dragImageOffset = dragImageOffset * scale;
|
||||||
|
}
|
||||||
|
- dt.setDragImage(toDrag, dragImageOffset, dragImageOffset);
|
||||||
|
|
||||||
|
// _dragData.offsetX/Y give the coordinates that the mouse should be
|
||||||
|
// positioned relative to the corner of the new window created upon
|
||||||
|
@@ -1112,7 +1146,7 @@
|
||||||
let dropEffect = this.getDropEffectForTabDrag(event);
|
let dropEffect = this.getDropEffectForTabDrag(event);
|
||||||
let isMovingInTabStrip = !fromTabList && dropEffect == "move";
|
let isMovingInTabStrip = !fromTabList && dropEffect == "move";
|
||||||
let collapseTabGroupDuringDrag =
|
let collapseTabGroupDuringDrag =
|
||||||
@@ -185,7 +200,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
|
|
||||||
tab._dragData = {
|
tab._dragData = {
|
||||||
offsetX: this._tabbrowserTabs.verticalMode
|
offsetX: this._tabbrowserTabs.verticalMode
|
||||||
@@ -1122,7 +1159,7 @@
|
@@ -1122,7 +1156,7 @@
|
||||||
? event.screenY - window.screenY - tabOffset
|
? event.screenY - window.screenY - tabOffset
|
||||||
: event.screenY - window.screenY,
|
: event.screenY - window.screenY,
|
||||||
scrollPos:
|
scrollPos:
|
||||||
@@ -194,7 +209,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
? this._tabbrowserTabs.pinnedTabsContainer.scrollPosition
|
? this._tabbrowserTabs.pinnedTabsContainer.scrollPosition
|
||||||
: this._tabbrowserTabs.arrowScrollbox.scrollPosition,
|
: this._tabbrowserTabs.arrowScrollbox.scrollPosition,
|
||||||
screenX: event.screenX,
|
screenX: event.screenX,
|
||||||
@@ -1149,6 +1186,7 @@
|
@@ -1149,6 +1183,7 @@
|
||||||
|
|
||||||
if (collapseTabGroupDuringDrag) {
|
if (collapseTabGroupDuringDrag) {
|
||||||
tab.group.collapsed = true;
|
tab.group.collapsed = true;
|
||||||
@@ -202,7 +217,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1173,6 +1211,16 @@
|
@@ -1173,6 +1208,16 @@
|
||||||
if (tabStripItemElement.hasAttribute("dragtarget")) {
|
if (tabStripItemElement.hasAttribute("dragtarget")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -219,7 +234,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
let isPinned = tab.pinned;
|
let isPinned = tab.pinned;
|
||||||
let numPinned = gBrowser.pinnedTabCount;
|
let numPinned = gBrowser.pinnedTabCount;
|
||||||
let allTabs = this._tabbrowserTabs.ariaFocusableItems;
|
let allTabs = this._tabbrowserTabs.ariaFocusableItems;
|
||||||
@@ -1624,10 +1672,7 @@
|
@@ -1624,10 +1669,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +246,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
|
|
||||||
let directionX = screenX > dragData.animLastScreenX;
|
let directionX = screenX > dragData.animLastScreenX;
|
||||||
let directionY = screenY > dragData.animLastScreenY;
|
let directionY = screenY > dragData.animLastScreenY;
|
||||||
@@ -1636,6 +1681,8 @@
|
@@ -1636,6 +1678,8 @@
|
||||||
|
|
||||||
let { width: tabWidth, height: tabHeight } =
|
let { width: tabWidth, height: tabHeight } =
|
||||||
draggedTab.getBoundingClientRect();
|
draggedTab.getBoundingClientRect();
|
||||||
@@ -240,7 +255,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
let shiftSizeX = tabWidth * movingTabs.length;
|
let shiftSizeX = tabWidth * movingTabs.length;
|
||||||
let shiftSizeY = tabHeight;
|
let shiftSizeY = tabHeight;
|
||||||
dragData.tabWidth = tabWidth;
|
dragData.tabWidth = tabWidth;
|
||||||
@@ -1672,8 +1719,8 @@
|
@@ -1672,8 +1716,8 @@
|
||||||
let lastBoundX =
|
let lastBoundX =
|
||||||
lastTabInRow.screenX +
|
lastTabInRow.screenX +
|
||||||
lastTabInRow.getBoundingClientRect().width -
|
lastTabInRow.getBoundingClientRect().width -
|
||||||
@@ -251,161 +266,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
translateX = Math.min(Math.max(translateX, firstBoundX), lastBoundX);
|
translateX = Math.min(Math.max(translateX, firstBoundX), lastBoundX);
|
||||||
translateY = Math.min(Math.max(translateY, firstBoundY), lastBoundY);
|
translateY = Math.min(Math.max(translateY, firstBoundY), lastBoundY);
|
||||||
|
|
||||||
@@ -1833,13 +1880,18 @@
|
@@ -2417,6 +2461,7 @@
|
||||||
this._clearDragOverGroupingTimer();
|
|
||||||
this.#clearPinnedDropIndicatorTimer();
|
|
||||||
|
|
||||||
- let isPinned = draggedTab.pinned;
|
|
||||||
- let numPinned = gBrowser.pinnedTabCount;
|
|
||||||
+ let isPinned = draggedTab?.group ? draggedTab.group.pinned : draggedTab.pinned;
|
|
||||||
+ let numPinned = gBrowser._numVisiblePinTabsWithoutCollapsed;
|
|
||||||
+ let essential = draggedTab.hasAttribute("zen-essential");
|
|
||||||
+ const isDraggingFolder = isTabGroupLabel(draggedTab) && draggedTab.group?.isZenFolder;
|
|
||||||
let allTabs = this._tabbrowserTabs.ariaFocusableItems;
|
|
||||||
let tabs = allTabs.slice(
|
|
||||||
- isPinned ? 0 : numPinned,
|
|
||||||
- isPinned ? numPinned : undefined
|
|
||||||
+ (isPinned && essential) ? 0 : gBrowser._numZenEssentials,
|
|
||||||
+ isPinned ? (essential ? gBrowser._numZenEssentials : (isDraggingFolder ? numPinned : undefined)) : undefined
|
|
||||||
);
|
|
||||||
+ if (draggedTab.group?.hasAttribute("split-view-group")) {
|
|
||||||
+ draggedTab = draggedTab.group.labelElement;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
if (this._rtlMode) {
|
|
||||||
tabs.reverse();
|
|
||||||
@@ -1854,7 +1906,7 @@
|
|
||||||
let translateAxis = this._tabbrowserTabs.verticalMode
|
|
||||||
? "translateY"
|
|
||||||
: "translateX";
|
|
||||||
- let { width: tabWidth, height: tabHeight } = bounds(draggedTab);
|
|
||||||
+ let { width: tabWidth, height: tabHeight } = bounds(draggedTab.group?.hasAttribute("split-view-group") ? draggedTab.group : draggedTab);
|
|
||||||
let tabSize = this._tabbrowserTabs.verticalMode ? tabHeight : tabWidth;
|
|
||||||
let translateX = event.screenX - dragData.screenX;
|
|
||||||
let translateY = event.screenY - dragData.screenY;
|
|
||||||
@@ -1870,6 +1922,12 @@
|
|
||||||
);
|
|
||||||
let lastMovingTab = movingTabs.at(-1);
|
|
||||||
let firstMovingTab = movingTabs[0];
|
|
||||||
+ if (lastMovingTab.group?.hasAttribute("split-view-group")) {
|
|
||||||
+ lastMovingTab = lastMovingTab.group;
|
|
||||||
+ }
|
|
||||||
+ if (firstMovingTab.group?.hasAttribute("split-view-group")) {
|
|
||||||
+ firstMovingTab = firstMovingTab.group;
|
|
||||||
+ }
|
|
||||||
let endEdge = ele => ele[screenAxis] + bounds(ele)[size];
|
|
||||||
let lastMovingTabScreen = endEdge(lastMovingTab);
|
|
||||||
let firstMovingTabScreen = firstMovingTab[screenAxis];
|
|
||||||
@@ -1884,6 +1942,13 @@
|
|
||||||
let endBound = this._rtlMode
|
|
||||||
? endEdge(this._tabbrowserTabs) - lastMovingTabScreen
|
|
||||||
: periphery[screenAxis] - 1 - lastMovingTabScreen;
|
|
||||||
+ {
|
|
||||||
+ let firstTab = tabs.at(this._rtlMode ? -1 : 0);
|
|
||||||
+ let lastTab = tabs.at(this._rtlMode ? 0 : -1);
|
|
||||||
+ startBound = firstTab[screenAxis] - firstMovingTabScreen;
|
|
||||||
+ endBound = endEdge(lastTab) - lastMovingTabScreen;
|
|
||||||
+ endBound = gZenPinnedTabManager.getLastTabBound(endBound, lastTab, isDraggingFolder);
|
|
||||||
+ }
|
|
||||||
translate = Math.min(Math.max(translate, startBound), endBound);
|
|
||||||
|
|
||||||
// Center the tab under the cursor if the tab is not under the cursor while dragging
|
|
||||||
@@ -2075,6 +2140,8 @@
|
|
||||||
};
|
|
||||||
|
|
||||||
let dropElement = getOverlappedElement();
|
|
||||||
+ if (dropElement?.hasAttribute("split-view-group")) dropElement = dropElement.labelElement;
|
|
||||||
+ gZenPinnedTabManager.animateSeparatorMove(movingTabs, dropElement, isPinned, event);
|
|
||||||
|
|
||||||
let newDropElementIndex;
|
|
||||||
if (dropElement) {
|
|
||||||
@@ -2157,7 +2224,7 @@
|
|
||||||
? Services.prefs.getIntPref(
|
|
||||||
"browser.tabs.dragDrop.moveOverThresholdPercent"
|
|
||||||
) / 100
|
|
||||||
- : 0.5;
|
|
||||||
+ : Services.prefs.getIntPref('zen.view.drag-and-drop.move-over-threshold') / 100;
|
|
||||||
moveOverThreshold = Math.min(1, Math.max(0, moveOverThreshold));
|
|
||||||
let shouldMoveOver = overlapPercent > moveOverThreshold;
|
|
||||||
if (logicalForward && shouldMoveOver) {
|
|
||||||
@@ -2190,6 +2257,7 @@
|
|
||||||
// If dragging a group over another group, don't make it look like it is
|
|
||||||
// possible to drop the dragged group inside the other group.
|
|
||||||
if (
|
|
||||||
+ false &&
|
|
||||||
isTabGroupLabel(draggedTab) &&
|
|
||||||
dropElement?.group &&
|
|
||||||
(!dropElement.group.collapsed ||
|
|
||||||
@@ -2216,20 +2284,13 @@
|
|
||||||
let isOutOfBounds = isPinned
|
|
||||||
? dropElement.elementIndex >= numPinned
|
|
||||||
: dropElement.elementIndex < numPinned;
|
|
||||||
- if (isOutOfBounds) {
|
|
||||||
- // Drop after last pinned tab
|
|
||||||
- dropElement = this._tabbrowserTabs.ariaFocusableItems[numPinned - 1];
|
|
||||||
- dropBefore = false;
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (
|
|
||||||
- gBrowser._tabGroupsEnabled &&
|
|
||||||
- isTab(draggedTab) &&
|
|
||||||
- !isPinned &&
|
|
||||||
- (!numPinned || newDropElementIndex >= numPinned)
|
|
||||||
- ) {
|
|
||||||
+ if (isTab(draggedTab) || isTabGroupLabel(draggedTab)) {
|
|
||||||
let dragOverGroupingThreshold = 1 - moveOverThreshold;
|
|
||||||
+ if (draggedTab && !dropElement?.group) {
|
|
||||||
+ gZenFolders.highlightGroupOnDragOver(null);
|
|
||||||
+ }
|
|
||||||
let groupingDelay = Services.prefs.getIntPref(
|
|
||||||
"browser.tabs.dragDrop.createGroup.delayMS"
|
|
||||||
);
|
|
||||||
@@ -2237,6 +2298,7 @@
|
|
||||||
// When dragging tab(s) over an ungrouped tab, signal to the user
|
|
||||||
// that dropping the tab(s) will create a new tab group.
|
|
||||||
let shouldCreateGroupOnDrop =
|
|
||||||
+ false &&
|
|
||||||
!movingTabsSet.has(dropElement) &&
|
|
||||||
isTab(dropElement) &&
|
|
||||||
!dropElement?.group &&
|
|
||||||
@@ -2245,6 +2307,7 @@
|
|
||||||
// When dragging tab(s) over a collapsed tab group label, signal to the
|
|
||||||
// user that dropping the tab(s) will add them to the group.
|
|
||||||
let shouldDropIntoCollapsedTabGroup =
|
|
||||||
+ false &&
|
|
||||||
isTabGroupLabel(dropElement) &&
|
|
||||||
dropElement.group.collapsed &&
|
|
||||||
overlapPercent > dragOverGroupingThreshold;
|
|
||||||
@@ -2302,6 +2365,14 @@
|
|
||||||
dropElement = dropElementGroup.tabs[0];
|
|
||||||
dropBefore = true;
|
|
||||||
}
|
|
||||||
+ ({ dropElement, colorCode, dropBefore } = gZenFolders.handleDragOverTabGroupLabel(
|
|
||||||
+ dropElement,
|
|
||||||
+ draggedTab,
|
|
||||||
+ overlapPercent,
|
|
||||||
+ movingTabs,
|
|
||||||
+ dropBefore,
|
|
||||||
+ colorCode
|
|
||||||
+ ));
|
|
||||||
}
|
|
||||||
this._setDragOverGroupColor(colorCode);
|
|
||||||
this._tabbrowserTabs.toggleAttribute(
|
|
||||||
@@ -2324,10 +2395,11 @@
|
|
||||||
dragData.dropBefore = dropBefore;
|
|
||||||
dragData.animDropElementIndex = newDropElementIndex;
|
|
||||||
|
|
||||||
+ gZenFolders.setFolderIndentation(movingTabs, dropElement);
|
|
||||||
// Shift background tabs to leave a gap where the dragged tab
|
|
||||||
// would currently be dropped.
|
|
||||||
for (let item of tabs) {
|
|
||||||
- if (item == draggedTab) {
|
|
||||||
+ if (item == draggedTab || (item.group?.hasAttribute("split-view-group") && item.group == draggedTab.group)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2417,11 +2489,13 @@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishAnimateTabMove() {
|
finishAnimateTabMove() {
|
||||||
@@ -413,13 +274,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
if (!this.#isMovingTab()) {
|
if (!this.#isMovingTab()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -2457,7 +2502,7 @@
|
||||||
this.#setMovingTabMode(false);
|
|
||||||
+ gZenFolders.highlightGroupOnDragOver(null);
|
|
||||||
|
|
||||||
for (let item of this._tabbrowserTabs.ariaFocusableItems) {
|
|
||||||
this._resetGroupTarget(item);
|
|
||||||
@@ -2457,7 +2531,7 @@
|
|
||||||
tab.style.left = "";
|
tab.style.left = "";
|
||||||
tab.style.top = "";
|
tab.style.top = "";
|
||||||
tab.style.maxWidth = "";
|
tab.style.maxWidth = "";
|
||||||
@@ -428,7 +283,7 @@ index 97b931c3c7385a52d20204369fcf6d6999053687..bc49f4f5a90638d725eca016d00f30d9
|
|||||||
}
|
}
|
||||||
for (let label of draggedTabDocument.getElementsByClassName(
|
for (let label of draggedTabDocument.getElementsByClassName(
|
||||||
"tab-group-label-container"
|
"tab-group-label-container"
|
||||||
@@ -2467,7 +2541,7 @@
|
@@ -2467,7 +2512,7 @@
|
||||||
label.style.left = "";
|
label.style.left = "";
|
||||||
label.style.top = "";
|
label.style.top = "";
|
||||||
label.style.maxWidth = "";
|
label.style.maxWidth = "";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tab.js b/browser/components/tabbrowser/content/tab.js
|
diff --git a/browser/components/tabbrowser/content/tab.js b/browser/components/tabbrowser/content/tab.js
|
||||||
index 2dacb325190b6ae42ebeb3e9f0e862dc690ecdca..02d70e9b0261f92917d274759838cfbfd6214f77 100644
|
index 2dacb325190b6ae42ebeb3e9f0e862dc690ecdca..23b134a8ba674978182415a8bac926f7600f564a 100644
|
||||||
--- a/browser/components/tabbrowser/content/tab.js
|
--- a/browser/components/tabbrowser/content/tab.js
|
||||||
+++ b/browser/components/tabbrowser/content/tab.js
|
+++ b/browser/components/tabbrowser/content/tab.js
|
||||||
@@ -21,6 +21,7 @@
|
@@ -21,6 +21,7 @@
|
||||||
@@ -121,15 +121,7 @@ index 2dacb325190b6ae42ebeb3e9f0e862dc690ecdca..02d70e9b0261f92917d274759838cfbf
|
|||||||
on_click(event) {
|
on_click(event) {
|
||||||
if (event.button != 0) {
|
if (event.button != 0) {
|
||||||
return;
|
return;
|
||||||
@@ -575,6 +599,7 @@
|
@@ -587,6 +611,14 @@
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
+ gZenPinnedTabManager._removePinnedAttributes(this, true);
|
|
||||||
gBrowser.removeTab(this, {
|
|
||||||
animate: true,
|
|
||||||
triggeringEvent: event,
|
|
||||||
@@ -587,6 +612,14 @@
|
|
||||||
// (see tabbrowser-tabs 'click' handler).
|
// (see tabbrowser-tabs 'click' handler).
|
||||||
gBrowser.tabContainer._blockDblClick = true;
|
gBrowser.tabContainer._blockDblClick = true;
|
||||||
}
|
}
|
||||||
@@ -144,7 +136,7 @@ index 2dacb325190b6ae42ebeb3e9f0e862dc690ecdca..02d70e9b0261f92917d274759838cfbf
|
|||||||
}
|
}
|
||||||
|
|
||||||
on_dblclick(event) {
|
on_dblclick(event) {
|
||||||
@@ -610,6 +643,8 @@
|
@@ -610,6 +642,8 @@
|
||||||
animate: true,
|
animate: true,
|
||||||
triggeringEvent: event,
|
triggeringEvent: event,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f53bc059b 100644
|
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..ebf699804db90e5509d1b1b704c95f18e829ca07 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
@@ -386,6 +386,7 @@
|
@@ -386,6 +386,7 @@
|
||||||
@@ -10,7 +10,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
const browsers = [];
|
const browsers = [];
|
||||||
if (this.#activeSplitView) {
|
if (this.#activeSplitView) {
|
||||||
for (const tab of this.#activeSplitView.tabs) {
|
for (const tab of this.#activeSplitView.tabs) {
|
||||||
@@ -450,15 +451,64 @@
|
@@ -450,15 +451,66 @@
|
||||||
return this.tabContainer.visibleTabs;
|
return this.tabContainer.visibleTabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +18,8 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
+ return this.#handleTabMove(...args);
|
+ return this.#handleTabMove(...args);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ get zenTabProgressListener() { return TabProgressListener; }
|
||||||
|
+
|
||||||
+ get _numVisiblePinTabsWithoutCollapsed() {
|
+ get _numVisiblePinTabsWithoutCollapsed() {
|
||||||
+ let i = 0;
|
+ let i = 0;
|
||||||
+ for (let item of this.tabContainer.ariaFocusableItems) {
|
+ for (let item of this.tabContainer.ariaFocusableItems) {
|
||||||
@@ -77,7 +79,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
set selectedTab(val) {
|
set selectedTab(val) {
|
||||||
if (
|
if (
|
||||||
gSharedTabWarning.willShowSharedTabWarning(val) ||
|
gSharedTabWarning.willShowSharedTabWarning(val) ||
|
||||||
@@ -613,6 +663,7 @@
|
@@ -613,6 +665,7 @@
|
||||||
this.tabpanels.appendChild(panel);
|
this.tabpanels.appendChild(panel);
|
||||||
|
|
||||||
let tab = this.tabs[0];
|
let tab = this.tabs[0];
|
||||||
@@ -85,7 +87,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
tab.linkedPanel = uniqueId;
|
tab.linkedPanel = uniqueId;
|
||||||
this._selectedTab = tab;
|
this._selectedTab = tab;
|
||||||
this._selectedBrowser = browser;
|
this._selectedBrowser = browser;
|
||||||
@@ -898,13 +949,17 @@
|
@@ -898,13 +951,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showTab(aTab);
|
this.showTab(aTab);
|
||||||
@@ -104,7 +106,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
aTab.setAttribute("pinned", "true");
|
aTab.setAttribute("pinned", "true");
|
||||||
this._updateTabBarForPinnedTabs();
|
this._updateTabBarForPinnedTabs();
|
||||||
@@ -917,11 +972,15 @@
|
@@ -917,11 +974,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#handleTabMove(aTab, () => {
|
this.#handleTabMove(aTab, () => {
|
||||||
@@ -121,7 +123,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
});
|
});
|
||||||
|
|
||||||
aTab.style.marginInlineStart = "";
|
aTab.style.marginInlineStart = "";
|
||||||
@@ -1098,6 +1157,8 @@
|
@@ -1098,6 +1159,8 @@
|
||||||
|
|
||||||
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
||||||
|
|
||||||
@@ -130,7 +132,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (
|
if (
|
||||||
aIconURL &&
|
aIconURL &&
|
||||||
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
|
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
|
||||||
@@ -1107,6 +1168,9 @@
|
@@ -1107,6 +1170,9 @@
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -140,7 +142,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
let browser = this.getBrowserForTab(aTab);
|
let browser = this.getBrowserForTab(aTab);
|
||||||
browser.mIconURL = aIconURL;
|
browser.mIconURL = aIconURL;
|
||||||
@@ -1379,7 +1443,6 @@
|
@@ -1379,7 +1445,6 @@
|
||||||
|
|
||||||
// Preview mode should not reset the owner
|
// Preview mode should not reset the owner
|
||||||
if (!this._previewMode && !oldTab.selected) {
|
if (!this._previewMode && !oldTab.selected) {
|
||||||
@@ -148,7 +150,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
|
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
|
||||||
@@ -1470,6 +1533,7 @@
|
@@ -1470,6 +1535,7 @@
|
||||||
if (!this._previewMode) {
|
if (!this._previewMode) {
|
||||||
newTab.recordTimeFromUnloadToReload();
|
newTab.recordTimeFromUnloadToReload();
|
||||||
newTab.updateLastAccessed();
|
newTab.updateLastAccessed();
|
||||||
@@ -156,7 +158,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
oldTab.updateLastAccessed();
|
oldTab.updateLastAccessed();
|
||||||
// if this is the foreground window, update the last-seen timestamps.
|
// if this is the foreground window, update the last-seen timestamps.
|
||||||
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
||||||
@@ -1622,6 +1686,9 @@
|
@@ -1622,6 +1688,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let activeEl = document.activeElement;
|
let activeEl = document.activeElement;
|
||||||
@@ -166,17 +168,20 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// If focus is on the old tab, move it to the new tab.
|
// If focus is on the old tab, move it to the new tab.
|
||||||
if (activeEl == oldTab) {
|
if (activeEl == oldTab) {
|
||||||
newTab.focus();
|
newTab.focus();
|
||||||
@@ -1945,7 +2012,8 @@
|
@@ -1945,7 +2014,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
||||||
- if (!aLabel || aLabel.includes("about:reader?")) {
|
- if (!aLabel || aLabel.includes("about:reader?")) {
|
||||||
|
+ if (!aTab._zenContentsVisible && !aTab._zenChangeLabelFlag && !aTab._labelIsInitialTitle && !gZenWorkspaces.privateWindowOrDisabled) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
+ gZenPinnedTabManager.onTabLabelChanged(aTab);
|
+ gZenPinnedTabManager.onTabLabelChanged(aTab);
|
||||||
+ if (!aLabel || aLabel.includes("about:reader?") || aTab.hasAttribute("zen-has-static-label")) {
|
+ if (!aLabel || aLabel.includes("about:reader?") || (aTab.hasAttribute("zen-has-static-label") && !aTab._zenChangeLabelFlag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2053,7 +2121,7 @@
|
@@ -2053,7 +2126,7 @@
|
||||||
newIndex = this.selectedTab._tPos + 1;
|
newIndex = this.selectedTab._tPos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +190,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (this.isTabGroupLabel(targetTab)) {
|
if (this.isTabGroupLabel(targetTab)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Replacing a tab group label with a tab is not supported"
|
"Replacing a tab group label with a tab is not supported"
|
||||||
@@ -2328,6 +2396,7 @@
|
@@ -2328,6 +2401,7 @@
|
||||||
uriIsAboutBlank,
|
uriIsAboutBlank,
|
||||||
userContextId,
|
userContextId,
|
||||||
skipLoad,
|
skipLoad,
|
||||||
@@ -193,7 +198,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} = {}) {
|
} = {}) {
|
||||||
let b = document.createXULElement("browser");
|
let b = document.createXULElement("browser");
|
||||||
// Use the JSM global to create the permanentKey, so that if the
|
// Use the JSM global to create the permanentKey, so that if the
|
||||||
@@ -2401,8 +2470,7 @@
|
@@ -2401,8 +2475,7 @@
|
||||||
// we use a different attribute name for this?
|
// we use a different attribute name for this?
|
||||||
b.setAttribute("name", name);
|
b.setAttribute("name", name);
|
||||||
}
|
}
|
||||||
@@ -203,7 +208,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
b.setAttribute("transparent", "true");
|
b.setAttribute("transparent", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2567,7 +2635,7 @@
|
@@ -2567,7 +2640,7 @@
|
||||||
|
|
||||||
let panel = this.getPanel(browser);
|
let panel = this.getPanel(browser);
|
||||||
let uniqueId = this._generateUniquePanelID();
|
let uniqueId = this._generateUniquePanelID();
|
||||||
@@ -212,7 +217,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
aTab.linkedPanel = uniqueId;
|
aTab.linkedPanel = uniqueId;
|
||||||
|
|
||||||
// Inject the <browser> into the DOM if necessary.
|
// Inject the <browser> into the DOM if necessary.
|
||||||
@@ -2626,8 +2694,8 @@
|
@@ -2626,8 +2699,8 @@
|
||||||
// If we transitioned from one browser to two browsers, we need to set
|
// If we transitioned from one browser to two browsers, we need to set
|
||||||
// hasSiblings=false on both the existing browser and the new browser.
|
// hasSiblings=false on both the existing browser and the new browser.
|
||||||
if (this.tabs.length == 2) {
|
if (this.tabs.length == 2) {
|
||||||
@@ -223,7 +228,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else {
|
} else {
|
||||||
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
|
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
|
||||||
}
|
}
|
||||||
@@ -2814,7 +2882,6 @@
|
@@ -2814,7 +2887,6 @@
|
||||||
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
||||||
tabIndex: tab._tPos + 1,
|
tabIndex: tab._tPos + 1,
|
||||||
userContextId: tab.userContextId,
|
userContextId: tab.userContextId,
|
||||||
@@ -231,16 +236,17 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
focusUrlBar: true,
|
focusUrlBar: true,
|
||||||
});
|
});
|
||||||
resolve(this.selectedBrowser);
|
resolve(this.selectedBrowser);
|
||||||
@@ -2923,6 +2990,8 @@
|
@@ -2923,6 +2995,9 @@
|
||||||
schemelessInput,
|
schemelessInput,
|
||||||
hasValidUserGestureActivation = false,
|
hasValidUserGestureActivation = false,
|
||||||
textDirectiveUserActivation = false,
|
textDirectiveUserActivation = false,
|
||||||
+ _forZenEmptyTab,
|
+ _forZenEmptyTab,
|
||||||
+ essential,
|
+ essential,
|
||||||
|
+ zenWorkspaceId,
|
||||||
} = {}
|
} = {}
|
||||||
) {
|
) {
|
||||||
// all callers of addTab that pass a params object need to pass
|
// all callers of addTab that pass a params object need to pass
|
||||||
@@ -2933,10 +3002,17 @@
|
@@ -2933,10 +3008,17 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +264,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// If we're opening a foreground tab, set the owner by default.
|
// If we're opening a foreground tab, set the owner by default.
|
||||||
ownerTab ??= inBackground ? null : this.selectedTab;
|
ownerTab ??= inBackground ? null : this.selectedTab;
|
||||||
|
|
||||||
@@ -2944,6 +3020,7 @@
|
@@ -2944,6 +3026,7 @@
|
||||||
if (this.selectedTab.owner) {
|
if (this.selectedTab.owner) {
|
||||||
this.selectedTab.owner = null;
|
this.selectedTab.owner = null;
|
||||||
}
|
}
|
||||||
@@ -266,14 +272,16 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
// Find the tab that opened this one, if any. This is used for
|
// Find the tab that opened this one, if any. This is used for
|
||||||
// determining positioning, and inherited attributes such as the
|
// determining positioning, and inherited attributes such as the
|
||||||
@@ -2996,6 +3073,19 @@
|
@@ -2996,6 +3079,21 @@
|
||||||
noInitialLabel,
|
noInitialLabel,
|
||||||
skipBackgroundNotify,
|
skipBackgroundNotify,
|
||||||
});
|
});
|
||||||
+ if (hasZenDefaultUserContextId) {
|
+ if (hasZenDefaultUserContextId) {
|
||||||
+ t.setAttribute("zenDefaultUserContextId", "true");
|
+ t.setAttribute("zenDefaultUserContextId", "true");
|
||||||
+ }
|
+ }
|
||||||
+ if (zenForcedWorkspaceId !== undefined) {
|
+ if (zenWorkspaceId) {
|
||||||
|
+ t.setAttribute("zen-workspace-id", zenWorkspaceId);
|
||||||
|
+ } else if (zenForcedWorkspaceId !== undefined) {
|
||||||
+ t.setAttribute("zen-workspace-id", zenForcedWorkspaceId);
|
+ t.setAttribute("zen-workspace-id", zenForcedWorkspaceId);
|
||||||
+ t.setAttribute("change-workspace", "")
|
+ t.setAttribute("change-workspace", "")
|
||||||
+ }
|
+ }
|
||||||
@@ -286,7 +294,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (insertTab) {
|
if (insertTab) {
|
||||||
// Insert the tab into the tab container in the correct position.
|
// Insert the tab into the tab container in the correct position.
|
||||||
this.#insertTabAtIndex(t, {
|
this.#insertTabAtIndex(t, {
|
||||||
@@ -3004,6 +3094,7 @@
|
@@ -3004,6 +3102,7 @@
|
||||||
ownerTab,
|
ownerTab,
|
||||||
openerTab,
|
openerTab,
|
||||||
pinned,
|
pinned,
|
||||||
@@ -294,7 +302,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
bulkOrderedOpen,
|
bulkOrderedOpen,
|
||||||
tabGroup: tabGroup ?? openerTab?.group,
|
tabGroup: tabGroup ?? openerTab?.group,
|
||||||
});
|
});
|
||||||
@@ -3022,6 +3113,7 @@
|
@@ -3022,6 +3121,7 @@
|
||||||
openWindowInfo,
|
openWindowInfo,
|
||||||
skipLoad,
|
skipLoad,
|
||||||
triggeringRemoteType,
|
triggeringRemoteType,
|
||||||
@@ -302,7 +310,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (focusUrlBar) {
|
if (focusUrlBar) {
|
||||||
@@ -3146,6 +3238,12 @@
|
@@ -3146,6 +3246,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +323,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// Additionally send pinned tab events
|
// Additionally send pinned tab events
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
this.#notifyPinnedStatus(t);
|
this.#notifyPinnedStatus(t);
|
||||||
@@ -3349,10 +3447,10 @@
|
@@ -3349,10 +3455,10 @@
|
||||||
isAdoptingGroup = false,
|
isAdoptingGroup = false,
|
||||||
isUserTriggered = false,
|
isUserTriggered = false,
|
||||||
telemetryUserCreateSource = "unknown",
|
telemetryUserCreateSource = "unknown",
|
||||||
@@ -327,7 +335,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!color) {
|
if (!color) {
|
||||||
@@ -3373,9 +3471,14 @@
|
@@ -3373,9 +3479,14 @@
|
||||||
label,
|
label,
|
||||||
isAdoptingGroup
|
isAdoptingGroup
|
||||||
);
|
);
|
||||||
@@ -344,7 +352,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
);
|
);
|
||||||
group.addTabs(tabs);
|
group.addTabs(tabs);
|
||||||
|
|
||||||
@@ -3496,7 +3599,7 @@
|
@@ -3496,7 +3607,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#handleTabMove(tab, () =>
|
this.#handleTabMove(tab, () =>
|
||||||
@@ -353,7 +361,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3698,6 +3801,7 @@
|
@@ -3698,6 +3809,7 @@
|
||||||
openWindowInfo,
|
openWindowInfo,
|
||||||
skipLoad,
|
skipLoad,
|
||||||
triggeringRemoteType,
|
triggeringRemoteType,
|
||||||
@@ -361,7 +369,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
||||||
@@ -3767,6 +3871,7 @@
|
@@ -3767,6 +3879,7 @@
|
||||||
openWindowInfo,
|
openWindowInfo,
|
||||||
name,
|
name,
|
||||||
skipLoad,
|
skipLoad,
|
||||||
@@ -369,7 +377,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3955,7 +4060,7 @@
|
@@ -3955,7 +4068,7 @@
|
||||||
// Add a new tab if needed.
|
// Add a new tab if needed.
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
let createLazyBrowser =
|
let createLazyBrowser =
|
||||||
@@ -378,7 +386,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
let url = "about:blank";
|
let url = "about:blank";
|
||||||
if (tabData.entries?.length) {
|
if (tabData.entries?.length) {
|
||||||
@@ -3992,8 +4097,10 @@
|
@@ -3992,8 +4105,10 @@
|
||||||
insertTab: false,
|
insertTab: false,
|
||||||
skipLoad: true,
|
skipLoad: true,
|
||||||
preferredRemoteType,
|
preferredRemoteType,
|
||||||
@@ -390,7 +398,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (select) {
|
if (select) {
|
||||||
tabToSelect = tab;
|
tabToSelect = tab;
|
||||||
}
|
}
|
||||||
@@ -4005,7 +4112,8 @@
|
@@ -4005,7 +4120,8 @@
|
||||||
this.pinTab(tab);
|
this.pinTab(tab);
|
||||||
// Then ensure all the tab open/pinning information is sent.
|
// Then ensure all the tab open/pinning information is sent.
|
||||||
this._fireTabOpen(tab, {});
|
this._fireTabOpen(tab, {});
|
||||||
@@ -400,7 +408,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
let { groupId } = tabData;
|
let { groupId } = tabData;
|
||||||
const tabGroup = tabGroupWorkingData.get(groupId);
|
const tabGroup = tabGroupWorkingData.get(groupId);
|
||||||
// if a tab refers to a tab group we don't know, skip any group
|
// if a tab refers to a tab group we don't know, skip any group
|
||||||
@@ -4019,7 +4127,10 @@
|
@@ -4019,7 +4135,10 @@
|
||||||
tabGroup.stateData.id,
|
tabGroup.stateData.id,
|
||||||
tabGroup.stateData.color,
|
tabGroup.stateData.color,
|
||||||
tabGroup.stateData.collapsed,
|
tabGroup.stateData.collapsed,
|
||||||
@@ -412,7 +420,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
);
|
);
|
||||||
tabsFragment.appendChild(tabGroup.node);
|
tabsFragment.appendChild(tabGroup.node);
|
||||||
}
|
}
|
||||||
@@ -4064,9 +4175,23 @@
|
@@ -4064,9 +4183,23 @@
|
||||||
// to remove the old selected tab.
|
// to remove the old selected tab.
|
||||||
if (tabToSelect) {
|
if (tabToSelect) {
|
||||||
let leftoverTab = this.selectedTab;
|
let leftoverTab = this.selectedTab;
|
||||||
@@ -428,15 +436,15 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+ else {
|
+ else {
|
||||||
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
||||||
}
|
+ }
|
||||||
+ this._hasAlreadyInitializedZenSessionStore = true;
|
+ this._hasAlreadyInitializedZenSessionStore = true;
|
||||||
|
|
||||||
if (tabs.length > 1 || !tabs[0].selected) {
|
if (tabs.length > 1 || !tabs[0].selected) {
|
||||||
this._updateTabsAfterInsert();
|
this._updateTabsAfterInsert();
|
||||||
@@ -4257,11 +4382,14 @@
|
@@ -4257,11 +4390,14 @@
|
||||||
if (ownerTab) {
|
if (ownerTab) {
|
||||||
tab.owner = ownerTab;
|
tab.owner = ownerTab;
|
||||||
}
|
}
|
||||||
@@ -452,7 +460,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (
|
if (
|
||||||
!bulkOrderedOpen &&
|
!bulkOrderedOpen &&
|
||||||
((openerTab &&
|
((openerTab &&
|
||||||
@@ -4273,7 +4401,7 @@
|
@@ -4273,7 +4409,7 @@
|
||||||
let lastRelatedTab =
|
let lastRelatedTab =
|
||||||
openerTab && this._lastRelatedTabMap.get(openerTab);
|
openerTab && this._lastRelatedTabMap.get(openerTab);
|
||||||
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
|
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
|
||||||
@@ -461,7 +469,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
tabGroup = previousTab.group;
|
tabGroup = previousTab.group;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
@@ -4284,7 +4412,7 @@
|
@@ -4284,7 +4420,7 @@
|
||||||
) {
|
) {
|
||||||
elementIndex = Infinity;
|
elementIndex = Infinity;
|
||||||
} else if (previousTab.visible) {
|
} else if (previousTab.visible) {
|
||||||
@@ -470,7 +478,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else if (previousTab == FirefoxViewHandler.tab) {
|
} else if (previousTab == FirefoxViewHandler.tab) {
|
||||||
elementIndex = 0;
|
elementIndex = 0;
|
||||||
}
|
}
|
||||||
@@ -4312,14 +4440,14 @@
|
@@ -4312,14 +4448,14 @@
|
||||||
}
|
}
|
||||||
// Ensure index is within bounds.
|
// Ensure index is within bounds.
|
||||||
if (tab.pinned) {
|
if (tab.pinned) {
|
||||||
@@ -489,7 +497,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
if (pinned && !itemAfter?.pinned) {
|
if (pinned && !itemAfter?.pinned) {
|
||||||
itemAfter = null;
|
itemAfter = null;
|
||||||
@@ -4330,7 +4458,7 @@
|
@@ -4330,7 +4466,7 @@
|
||||||
|
|
||||||
this.tabContainer._invalidateCachedTabs();
|
this.tabContainer._invalidateCachedTabs();
|
||||||
|
|
||||||
@@ -498,7 +506,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
|
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
|
||||||
// Place at the front of, or between tabs in, the same tab group
|
// Place at the front of, or between tabs in, the same tab group
|
||||||
this.tabContainer.insertBefore(tab, itemAfter);
|
this.tabContainer.insertBefore(tab, itemAfter);
|
||||||
@@ -4358,7 +4486,11 @@
|
@@ -4358,7 +4494,11 @@
|
||||||
const tabContainer = pinned
|
const tabContainer = pinned
|
||||||
? this.tabContainer.pinnedTabsContainer
|
? this.tabContainer.pinnedTabsContainer
|
||||||
: this.tabContainer;
|
: this.tabContainer;
|
||||||
@@ -510,7 +518,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._updateTabsAfterInsert();
|
this._updateTabsAfterInsert();
|
||||||
@@ -4366,6 +4498,7 @@
|
@@ -4366,6 +4506,7 @@
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
this._updateTabBarForPinnedTabs();
|
this._updateTabBarForPinnedTabs();
|
||||||
}
|
}
|
||||||
@@ -518,17 +526,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
TabBarVisibility.update();
|
TabBarVisibility.update();
|
||||||
}
|
}
|
||||||
@@ -4655,6 +4788,9 @@
|
@@ -4916,6 +5057,7 @@
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ for (let tab of selectedTabs) {
|
|
||||||
+ gZenPinnedTabManager._removePinnedAttributes(tab, true);
|
|
||||||
+ }
|
|
||||||
this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource });
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -4916,6 +5052,7 @@
|
|
||||||
telemetrySource,
|
telemetrySource,
|
||||||
} = {}
|
} = {}
|
||||||
) {
|
) {
|
||||||
@@ -536,7 +534,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
|
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
|
||||||
// can be considered equivalent to closing the window.
|
// can be considered equivalent to closing the window.
|
||||||
if (
|
if (
|
||||||
@@ -5005,6 +5142,7 @@
|
@@ -5005,6 +5147,7 @@
|
||||||
if (lastToClose) {
|
if (lastToClose) {
|
||||||
this.removeTab(lastToClose, aParams);
|
this.removeTab(lastToClose, aParams);
|
||||||
}
|
}
|
||||||
@@ -544,7 +542,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
@@ -5043,6 +5181,12 @@
|
@@ -5043,6 +5186,12 @@
|
||||||
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
|
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +555,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// Handle requests for synchronously removing an already
|
// Handle requests for synchronously removing an already
|
||||||
// asynchronously closing tab.
|
// asynchronously closing tab.
|
||||||
if (!animate && aTab.closing) {
|
if (!animate && aTab.closing) {
|
||||||
@@ -5057,6 +5201,9 @@
|
@@ -5057,6 +5206,9 @@
|
||||||
// state).
|
// state).
|
||||||
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
||||||
let isLastTab = this.#isLastTabInWindow(aTab);
|
let isLastTab = this.#isLastTabInWindow(aTab);
|
||||||
@@ -567,7 +565,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (
|
if (
|
||||||
!this._beginRemoveTab(aTab, {
|
!this._beginRemoveTab(aTab, {
|
||||||
closeWindowFastpath: true,
|
closeWindowFastpath: true,
|
||||||
@@ -5105,7 +5252,13 @@
|
@@ -5105,7 +5257,13 @@
|
||||||
// We're not animating, so we can cancel the animation stopwatch.
|
// We're not animating, so we can cancel the animation stopwatch.
|
||||||
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
|
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
|
||||||
aTab._closeTimeAnimTimerId = null;
|
aTab._closeTimeAnimTimerId = null;
|
||||||
@@ -582,7 +580,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5239,7 +5392,7 @@
|
@@ -5239,7 +5397,7 @@
|
||||||
closeWindowWithLastTab != null
|
closeWindowWithLastTab != null
|
||||||
? closeWindowWithLastTab
|
? closeWindowWithLastTab
|
||||||
: !window.toolbar.visible ||
|
: !window.toolbar.visible ||
|
||||||
@@ -591,7 +589,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
if (closeWindow) {
|
if (closeWindow) {
|
||||||
// We've already called beforeunload on all the relevant tabs if we get here,
|
// We've already called beforeunload on all the relevant tabs if we get here,
|
||||||
@@ -5263,6 +5416,7 @@
|
@@ -5263,6 +5421,7 @@
|
||||||
|
|
||||||
newTab = true;
|
newTab = true;
|
||||||
}
|
}
|
||||||
@@ -599,7 +597,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
aTab._endRemoveArgs = [closeWindow, newTab];
|
aTab._endRemoveArgs = [closeWindow, newTab];
|
||||||
|
|
||||||
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
||||||
@@ -5303,13 +5457,7 @@
|
@@ -5303,13 +5462,7 @@
|
||||||
aTab._mouseleave();
|
aTab._mouseleave();
|
||||||
|
|
||||||
if (newTab) {
|
if (newTab) {
|
||||||
@@ -614,7 +612,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else {
|
} else {
|
||||||
TabBarVisibility.update();
|
TabBarVisibility.update();
|
||||||
}
|
}
|
||||||
@@ -5442,6 +5590,7 @@
|
@@ -5442,6 +5595,7 @@
|
||||||
this.tabs[i]._tPos = i;
|
this.tabs[i]._tPos = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,7 +620,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (!this._windowIsClosing) {
|
if (!this._windowIsClosing) {
|
||||||
// update tab close buttons state
|
// update tab close buttons state
|
||||||
this.tabContainer._updateCloseButtons();
|
this.tabContainer._updateCloseButtons();
|
||||||
@@ -5663,6 +5812,7 @@
|
@@ -5663,6 +5817,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let excludeTabs = new Set(aExcludeTabs);
|
let excludeTabs = new Set(aExcludeTabs);
|
||||||
@@ -630,7 +628,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
|
|
||||||
// If this tab has a successor, it should be selectable, since
|
// If this tab has a successor, it should be selectable, since
|
||||||
// hiding or closing a tab removes that tab as a successor.
|
// hiding or closing a tab removes that tab as a successor.
|
||||||
@@ -5675,13 +5825,13 @@
|
@@ -5675,13 +5830,13 @@
|
||||||
!excludeTabs.has(aTab.owner) &&
|
!excludeTabs.has(aTab.owner) &&
|
||||||
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
||||||
) {
|
) {
|
||||||
@@ -646,7 +644,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
);
|
);
|
||||||
|
|
||||||
let tab = this.tabContainer.findNextTab(aTab, {
|
let tab = this.tabContainer.findNextTab(aTab, {
|
||||||
@@ -5697,7 +5847,7 @@
|
@@ -5697,7 +5852,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab) {
|
if (tab) {
|
||||||
@@ -655,7 +653,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If no qualifying visible tab was found, see if there is a tab in
|
// If no qualifying visible tab was found, see if there is a tab in
|
||||||
@@ -5718,7 +5868,7 @@
|
@@ -5718,7 +5873,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,7 +662,47 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
_blurTab(aTab) {
|
_blurTab(aTab) {
|
||||||
@@ -6124,10 +6274,10 @@
|
@@ -5729,7 +5884,7 @@
|
||||||
|
* @returns {boolean}
|
||||||
|
* False if swapping isn't permitted, true otherwise.
|
||||||
|
*/
|
||||||
|
- swapBrowsersAndCloseOther(aOurTab, aOtherTab) {
|
||||||
|
+ swapBrowsersAndCloseOther(aOurTab, aOtherTab, zenCloseOther = true) {
|
||||||
|
// Do not allow transfering a private tab to a non-private window
|
||||||
|
// and vice versa.
|
||||||
|
if (
|
||||||
|
@@ -5783,6 +5938,7 @@
|
||||||
|
// fire the beforeunload event in the process. Close the other
|
||||||
|
// window if this was its last tab.
|
||||||
|
if (
|
||||||
|
+ zenCloseOther &&
|
||||||
|
!remoteBrowser._beginRemoveTab(aOtherTab, {
|
||||||
|
adoptedByTab: aOurTab,
|
||||||
|
closeWindowWithLastTab: true,
|
||||||
|
@@ -5794,7 +5950,7 @@
|
||||||
|
// If this is the last tab of the window, hide the window
|
||||||
|
// immediately without animation before the docshell swap, to avoid
|
||||||
|
// about:blank being painted.
|
||||||
|
- let [closeWindow] = aOtherTab._endRemoveArgs;
|
||||||
|
+ let [closeWindow] = !zenCloseOther ? [false] : aOtherTab._endRemoveArgs;
|
||||||
|
if (closeWindow) {
|
||||||
|
let win = aOtherTab.ownerGlobal;
|
||||||
|
win.windowUtils.suppressAnimation(true);
|
||||||
|
@@ -5918,11 +6074,13 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish tearing down the tab that's going away.
|
||||||
|
+ if (zenCloseOther) {
|
||||||
|
if (closeWindow) {
|
||||||
|
aOtherTab.ownerGlobal.close();
|
||||||
|
} else {
|
||||||
|
remoteBrowser._endRemoveTab(aOtherTab);
|
||||||
|
}
|
||||||
|
+ }
|
||||||
|
|
||||||
|
this.setTabTitle(aOurTab);
|
||||||
|
|
||||||
|
@@ -6124,10 +6282,10 @@
|
||||||
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,15 +715,33 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
aTab.selected ||
|
aTab.selected ||
|
||||||
aTab.closing ||
|
aTab.closing ||
|
||||||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
||||||
@@ -6186,6 +6336,7 @@
|
@@ -6185,7 +6343,8 @@
|
||||||
|
*
|
||||||
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
|
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
|
||||||
*/
|
*/
|
||||||
replaceTabWithWindow(aTab, aOptions) {
|
- replaceTabWithWindow(aTab, aOptions) {
|
||||||
|
+ replaceTabWithWindow(aTab, aOptions, zenForceSync = false) {
|
||||||
+ if (!this.isTab(aTab)) return; // TODO: Handle tab groups
|
+ if (!this.isTab(aTab)) return; // TODO: Handle tab groups
|
||||||
if (this.tabs.length == 1) {
|
if (this.tabs.length == 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -6319,7 +6470,7 @@
|
@@ -6209,12 +6368,14 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
// tell a new window to take the "dropped" tab
|
||||||
|
- return window.openDialog(
|
||||||
|
+ let win = window.openDialog(
|
||||||
|
AppConstants.BROWSER_CHROME_URL,
|
||||||
|
"_blank",
|
||||||
|
options,
|
||||||
|
aTab
|
||||||
|
);
|
||||||
|
+ win._zenStartupSyncFlag = zenForceSync ? 'synced' : 'unsynced';
|
||||||
|
+ return win;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -6319,7 +6480,7 @@
|
||||||
* `true` if element is a `<tab-group>`
|
* `true` if element is a `<tab-group>`
|
||||||
*/
|
*/
|
||||||
isTabGroup(element) {
|
isTabGroup(element) {
|
||||||
@@ -694,7 +750,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6404,8 +6555,8 @@
|
@@ -6404,8 +6565,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't allow mixing pinned and unpinned tabs.
|
// Don't allow mixing pinned and unpinned tabs.
|
||||||
@@ -705,7 +761,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else {
|
} else {
|
||||||
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
|
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
|
||||||
}
|
}
|
||||||
@@ -6431,10 +6582,16 @@
|
@@ -6431,10 +6592,16 @@
|
||||||
this.#handleTabMove(
|
this.#handleTabMove(
|
||||||
element,
|
element,
|
||||||
() => {
|
() => {
|
||||||
@@ -724,7 +780,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
|
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
|
||||||
neighbor.after(element);
|
neighbor.after(element);
|
||||||
} else {
|
} else {
|
||||||
@@ -6492,23 +6649,28 @@
|
@@ -6492,23 +6659,28 @@
|
||||||
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
|
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
|
||||||
if (this.isTabGroupLabel(targetElement)) {
|
if (this.isTabGroupLabel(targetElement)) {
|
||||||
targetElement = targetElement.group;
|
targetElement = targetElement.group;
|
||||||
@@ -759,7 +815,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else if (!element.pinned && targetElement && targetElement.pinned) {
|
} else if (!element.pinned && targetElement && targetElement.pinned) {
|
||||||
// If the caller asks to move an unpinned element next to a pinned
|
// If the caller asks to move an unpinned element next to a pinned
|
||||||
// tab, move the unpinned element to be the first unpinned element
|
// tab, move the unpinned element to be the first unpinned element
|
||||||
@@ -6521,14 +6683,34 @@
|
@@ -6521,14 +6693,34 @@
|
||||||
// move the tab group right before the first unpinned tab.
|
// move the tab group right before the first unpinned tab.
|
||||||
// 4. Moving a tab group and the first unpinned tab is grouped:
|
// 4. Moving a tab group and the first unpinned tab is grouped:
|
||||||
// move the tab group right before the first unpinned tab's tab group.
|
// move the tab group right before the first unpinned tab's tab group.
|
||||||
@@ -795,7 +851,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
element.pinned
|
element.pinned
|
||||||
? this.tabContainer.pinnedTabsContainer
|
? this.tabContainer.pinnedTabsContainer
|
||||||
: this.tabContainer;
|
: this.tabContainer;
|
||||||
@@ -6537,7 +6719,7 @@
|
@@ -6537,7 +6729,7 @@
|
||||||
element,
|
element,
|
||||||
() => {
|
() => {
|
||||||
if (moveBefore) {
|
if (moveBefore) {
|
||||||
@@ -804,7 +860,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
} else if (targetElement) {
|
} else if (targetElement) {
|
||||||
targetElement.after(element);
|
targetElement.after(element);
|
||||||
} else {
|
} else {
|
||||||
@@ -6607,10 +6789,10 @@
|
@@ -6607,10 +6799,10 @@
|
||||||
* @param {TabMetricsContext} [metricsContext]
|
* @param {TabMetricsContext} [metricsContext]
|
||||||
*/
|
*/
|
||||||
moveTabToGroup(aTab, aGroup, metricsContext) {
|
moveTabToGroup(aTab, aGroup, metricsContext) {
|
||||||
@@ -817,7 +873,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (aTab.group && aTab.group.id === aGroup.id) {
|
if (aTab.group && aTab.group.id === aGroup.id) {
|
||||||
@@ -6656,6 +6838,7 @@
|
@@ -6656,6 +6848,7 @@
|
||||||
|
|
||||||
let state = {
|
let state = {
|
||||||
tabIndex: tab._tPos,
|
tabIndex: tab._tPos,
|
||||||
@@ -825,7 +881,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
};
|
};
|
||||||
if (tab.visible) {
|
if (tab.visible) {
|
||||||
state.elementIndex = tab.elementIndex;
|
state.elementIndex = tab.elementIndex;
|
||||||
@@ -6682,7 +6865,7 @@
|
@@ -6682,7 +6875,7 @@
|
||||||
let changedTabGroup =
|
let changedTabGroup =
|
||||||
previousTabState.tabGroupId != currentTabState.tabGroupId;
|
previousTabState.tabGroupId != currentTabState.tabGroupId;
|
||||||
|
|
||||||
@@ -834,7 +890,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
tab.dispatchEvent(
|
tab.dispatchEvent(
|
||||||
new CustomEvent("TabMove", {
|
new CustomEvent("TabMove", {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
@@ -6723,6 +6906,10 @@
|
@@ -6723,6 +6916,10 @@
|
||||||
|
|
||||||
moveActionCallback();
|
moveActionCallback();
|
||||||
|
|
||||||
@@ -845,7 +901,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// Clear tabs cache after moving nodes because the order of tabs may have
|
// Clear tabs cache after moving nodes because the order of tabs may have
|
||||||
// changed.
|
// changed.
|
||||||
this.tabContainer._invalidateCachedTabs();
|
this.tabContainer._invalidateCachedTabs();
|
||||||
@@ -7623,7 +7810,7 @@
|
@@ -7623,7 +7820,7 @@
|
||||||
// preventDefault(). It will still raise the window if appropriate.
|
// preventDefault(). It will still raise the window if appropriate.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -854,7 +910,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
window.focus();
|
window.focus();
|
||||||
aEvent.preventDefault();
|
aEvent.preventDefault();
|
||||||
break;
|
break;
|
||||||
@@ -7640,7 +7827,6 @@
|
@@ -7640,7 +7837,6 @@
|
||||||
}
|
}
|
||||||
case "TabGroupCollapse":
|
case "TabGroupCollapse":
|
||||||
aEvent.target.tabs.forEach(tab => {
|
aEvent.target.tabs.forEach(tab => {
|
||||||
@@ -862,7 +918,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "TabGroupCreateByUser":
|
case "TabGroupCreateByUser":
|
||||||
@@ -8589,6 +8775,7 @@
|
@@ -8589,6 +8785,7 @@
|
||||||
aWebProgress.isTopLevel
|
aWebProgress.isTopLevel
|
||||||
) {
|
) {
|
||||||
this.mTab.setAttribute("busy", "true");
|
this.mTab.setAttribute("busy", "true");
|
||||||
@@ -870,7 +926,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
||||||
this.mTab._notselectedsinceload = !this.mTab.selected;
|
this.mTab._notselectedsinceload = !this.mTab.selected;
|
||||||
}
|
}
|
||||||
@@ -9623,7 +9810,7 @@ var TabContextMenu = {
|
@@ -9623,7 +9820,7 @@ var TabContextMenu = {
|
||||||
);
|
);
|
||||||
contextUnpinSelectedTabs.hidden =
|
contextUnpinSelectedTabs.hidden =
|
||||||
!this.contextTab.pinned || !this.multiselected;
|
!this.contextTab.pinned || !this.multiselected;
|
||||||
@@ -879,11 +935,3 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..6aa725c0e5a6a29dc33fcb162f83522f
|
|||||||
// Build Ask Chat items
|
// Build Ask Chat items
|
||||||
TabContextMenu.GenAI.buildTabMenu(
|
TabContextMenu.GenAI.buildTabMenu(
|
||||||
document.getElementById("context_askChat"),
|
document.getElementById("context_askChat"),
|
||||||
@@ -9943,6 +10130,7 @@ var TabContextMenu = {
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
+ gZenPinnedTabManager._removePinnedAttributes(this.contextTab, true);
|
|
||||||
gBrowser.removeTab(this.contextTab, {
|
|
||||||
animate: true,
|
|
||||||
...gBrowser.TabMetrics.userTriggeredContext(
|
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
||||||
index 6b6c04599fe80983d13d2069ca62b99d8ad70271..a765f2decc3a565226ac8793422474052f476573 100644
|
index 6b6c04599fe80983d13d2069ca62b99d8ad70271..009a9c398e2434b8b6704ed2c75b0f09ecc22ca1 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabs.js
|
--- a/browser/components/tabbrowser/content/tabs.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabs.js
|
+++ b/browser/components/tabbrowser/content/tabs.js
|
||||||
|
@@ -235,7 +235,7 @@
|
||||||
|
true
|
||||||
|
)
|
||||||
|
? new window.TabStacking(this)
|
||||||
|
- : new window.TabDragAndDrop(this);
|
||||||
|
+ : new window.ZenDragAndDrop(this);
|
||||||
|
this.tabDragAndDrop.init();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -436,7 +436,7 @@
|
@@ -436,7 +436,7 @@
|
||||||
// and we're not hitting the scroll buttons.
|
// and we're not hitting the scroll buttons.
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
diff --git a/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs b/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
|
|
||||||
index 4db61038e5e476bad3a61dbdb707e5222c1f08f8..9eca13d9cfac3b762917aaaa942267effb743cf7 100644
|
|
||||||
--- a/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
|
|
||||||
+++ b/browser/components/urlbar/UrlbarProviderPlaces.sys.mjs
|
|
||||||
@@ -45,11 +45,13 @@ function defaultQuery(conditions = "") {
|
|
||||||
let query = `
|
|
||||||
SELECT h.url, h.title, ${SQL_BOOKMARK_TAGS_FRAGMENT}, h.id, t.open_count,
|
|
||||||
${lazy.PAGES_FRECENCY_FIELD} AS frecency, t.userContextId,
|
|
||||||
- h.last_visit_date, NULLIF(t.groupId, '') groupId
|
|
||||||
+ h.last_visit_date, NULLIF(t.groupId, '') groupId, zp.url AS pinned_url, zp.title AS pinned_title
|
|
||||||
FROM moz_places h
|
|
||||||
LEFT JOIN moz_openpages_temp t
|
|
||||||
ON t.url = h.url
|
|
||||||
AND (t.userContextId = :userContextId OR (t.userContextId <> -1 AND :userContextId IS NULL))
|
|
||||||
+ LEFT JOIN zen_pins zp
|
|
||||||
+ ON zp.url = h.url
|
|
||||||
WHERE (
|
|
||||||
(:switchTabsEnabled AND t.open_count > 0) OR
|
|
||||||
${lazy.PAGES_FRECENCY_FIELD} <> 0
|
|
||||||
@@ -63,7 +65,7 @@ function defaultQuery(conditions = "") {
|
|
||||||
:matchBehavior, :searchBehavior, NULL)
|
|
||||||
ELSE
|
|
||||||
AUTOCOMPLETE_MATCH(:searchString, h.url,
|
|
||||||
- h.title, '',
|
|
||||||
+ IFNULL(zp.title, h.title), '',
|
|
||||||
h.visit_count, h.typed,
|
|
||||||
0, t.open_count,
|
|
||||||
:matchBehavior, :searchBehavior, NULL)
|
|
||||||
@@ -1176,11 +1178,13 @@ class Search {
|
|
||||||
? lazy.PlacesUtils.toDate(lastVisitPRTime).getTime()
|
|
||||||
: undefined;
|
|
||||||
let tabGroup = row.getResultByName("groupId");
|
|
||||||
+ let pinnedTitle = row.getResultByIndex(12);
|
|
||||||
+ let pinnedUrl = row.getResultByIndex("pinned_url");
|
|
||||||
|
|
||||||
let match = {
|
|
||||||
placeId,
|
|
||||||
- value: url,
|
|
||||||
- comment: bookmarkTitle || historyTitle,
|
|
||||||
+ value: pinnedUrl || url,
|
|
||||||
+ comment: pinnedTitle || bookmarkTitle || historyTitle,
|
|
||||||
icon: UrlbarUtils.getIconForUrl(url),
|
|
||||||
frecency: frecency || FRECENCY_DEFAULT,
|
|
||||||
userContextId,
|
|
||||||
@@ -13,3 +13,4 @@
|
|||||||
category app-startup nsBrowserGlue @mozilla.org/browser/browserglue;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
category app-startup nsBrowserGlue @mozilla.org/browser/browserglue;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
||||||
|
|
||||||
#include common/Components.manifest
|
#include common/Components.manifest
|
||||||
|
#include sessionstore/SessionComponents.manifest
|
||||||
|
|||||||
547
src/zen/common/ZenDragAndDrop.js
Normal file
547
src/zen/common/ZenDragAndDrop.js
Normal file
@@ -0,0 +1,547 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Wrap in a block to prevent leaking to window scope.
|
||||||
|
{
|
||||||
|
const isTab = (element) => gBrowser.isTab(element);
|
||||||
|
const isTabGroupLabel = (element) => gBrowser.isTabGroupLabel(element);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The elements in the tab strip from `this.ariaFocusableItems` that contain
|
||||||
|
* logical information are:
|
||||||
|
*
|
||||||
|
* - <tab> (.tabbrowser-tab)
|
||||||
|
* - <tab-group> label element (.tab-group-label)
|
||||||
|
*
|
||||||
|
* The elements in the tab strip that contain the space inside of the <tabs>
|
||||||
|
* element are:
|
||||||
|
*
|
||||||
|
* - <tab> (.tabbrowser-tab)
|
||||||
|
* - <tab-group> label element wrapper (.tab-group-label-container)
|
||||||
|
*
|
||||||
|
* When working with tab strip items, if you need logical information, you
|
||||||
|
* can get it directly, e.g. `element.elementIndex` or `element._tPos`. If
|
||||||
|
* you need spatial information like position or dimensions, then you should
|
||||||
|
* call this function. For example, `elementToMove(element).getBoundingClientRect()`
|
||||||
|
* or `elementToMove(element).style.top`.
|
||||||
|
*
|
||||||
|
* @param {MozTabbrowserTab|typeof MozTabbrowserTabGroup.labelElement} element
|
||||||
|
* @returns {MozTabbrowserTab|vbox}
|
||||||
|
*/
|
||||||
|
const elementToMove = (element) => {
|
||||||
|
if (element.classList.contains('zen-current-workspace-indicator')) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
if (element.group?.hasAttribute('split-view-group')) {
|
||||||
|
return element.group;
|
||||||
|
}
|
||||||
|
if (isTab(element)) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
if (isTabGroupLabel(element)) {
|
||||||
|
return element.closest('.tab-group-label-container');
|
||||||
|
}
|
||||||
|
throw new Error(`Element "${element.tagName}" is not expected to move`);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.ZenDragAndDrop = class extends window.TabDragAndDrop {
|
||||||
|
#dragOverBackground = null;
|
||||||
|
#lastDropTarget = null;
|
||||||
|
|
||||||
|
constructor(tabbrowserTabs) {
|
||||||
|
super(tabbrowserTabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
startTabDrag(event, tab, ...args) {
|
||||||
|
super.startTabDrag(event, tab, ...args);
|
||||||
|
let dt = event.dataTransfer;
|
||||||
|
|
||||||
|
const { offsetX, offsetY } = this.#getDragImageOffset(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
_animateTabMove(event) {
|
||||||
|
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||||
|
let dragData = draggedTab._dragData;
|
||||||
|
let movingTabs = dragData.movingTabs;
|
||||||
|
let movingTabsSet = dragData.movingTabsSet;
|
||||||
|
|
||||||
|
dragData.animLastScreenPos ??= this._tabbrowserTabs.verticalMode
|
||||||
|
? dragData.screenY
|
||||||
|
: dragData.screenX;
|
||||||
|
let allTabs = this._tabbrowserTabs.ariaFocusableItems;
|
||||||
|
let numEssentials = gBrowser._numZenEssentials;
|
||||||
|
let isEssential = draggedTab.hasAttribute('zen-essential');
|
||||||
|
let tabs = allTabs.slice(
|
||||||
|
isEssential ? 0 : numEssentials,
|
||||||
|
isEssential ? numEssentials : undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
let screen = this._tabbrowserTabs.verticalMode ? event.screenY : event.screenX;
|
||||||
|
if (screen == dragData.animLastScreenPos) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let screenForward = screen > dragData.animLastScreenPos;
|
||||||
|
dragData.animLastScreenPos = screen;
|
||||||
|
|
||||||
|
this._clearDragOverGroupingTimer();
|
||||||
|
|
||||||
|
if (this._rtlMode) {
|
||||||
|
tabs.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
let bounds = (ele) => window.windowUtils.getBoundsWithoutFlushing(ele);
|
||||||
|
let logicalForward = screenForward != this._rtlMode;
|
||||||
|
let screenAxis = this._tabbrowserTabs.verticalMode ? 'screenY' : 'screenX';
|
||||||
|
let size = this._tabbrowserTabs.verticalMode ? 'height' : 'width';
|
||||||
|
let { width: tabWidth, height: tabHeight } = bounds(draggedTab);
|
||||||
|
let tabSize = this._tabbrowserTabs.verticalMode ? tabHeight : tabWidth;
|
||||||
|
let translateX = event.screenX - dragData.screenX;
|
||||||
|
let translateY = event.screenY - dragData.screenY;
|
||||||
|
|
||||||
|
dragData.tabWidth = tabWidth;
|
||||||
|
dragData.tabHeight = tabHeight;
|
||||||
|
dragData.translateX = translateX;
|
||||||
|
dragData.translateY = translateY;
|
||||||
|
|
||||||
|
// Move the dragged tab based on the mouse position.
|
||||||
|
let periphery = document.getElementById('tabbrowser-arrowscrollbox-periphery');
|
||||||
|
let lastMovingTab = movingTabs.at(-1);
|
||||||
|
let firstMovingTab = movingTabs[0];
|
||||||
|
let endEdge = (ele) => ele[screenAxis] + bounds(ele)[size];
|
||||||
|
let lastMovingTabScreen = endEdge(lastMovingTab);
|
||||||
|
let firstMovingTabScreen = firstMovingTab[screenAxis];
|
||||||
|
let shiftSize = lastMovingTabScreen - firstMovingTabScreen;
|
||||||
|
let translate = screen - dragData[screenAxis];
|
||||||
|
|
||||||
|
// Constrain the range over which the moving tabs can move between the edge of the tabstrip and periphery.
|
||||||
|
// Add 1 to periphery so we don't overlap it.
|
||||||
|
let startBound = this._rtlMode
|
||||||
|
? endEdge(periphery) + 1 - firstMovingTabScreen
|
||||||
|
: this._tabbrowserTabs[screenAxis] - firstMovingTabScreen;
|
||||||
|
let endBound = this._rtlMode
|
||||||
|
? endEdge(this._tabbrowserTabs) - lastMovingTabScreen
|
||||||
|
: periphery[screenAxis] - 1 - lastMovingTabScreen;
|
||||||
|
let firstTab = tabs.at(this._rtlMode ? -1 : 0);
|
||||||
|
let lastTab = tabs.at(this._rtlMode ? 0 : -1);
|
||||||
|
startBound = firstTab[screenAxis] - firstMovingTabScreen;
|
||||||
|
endBound = endEdge(lastTab) - lastMovingTabScreen;
|
||||||
|
translate = Math.min(Math.max(translate, startBound), endBound);
|
||||||
|
|
||||||
|
// Center the tab under the cursor if the tab is not under the cursor while dragging
|
||||||
|
let draggedTabScreenAxis = draggedTab[screenAxis] + translate;
|
||||||
|
if (
|
||||||
|
(screen < draggedTabScreenAxis || screen > draggedTabScreenAxis + tabSize) &&
|
||||||
|
draggedTabScreenAxis + tabSize < endBound &&
|
||||||
|
draggedTabScreenAxis > startBound
|
||||||
|
) {
|
||||||
|
translate = screen - draggedTab[screenAxis] - tabSize / 2;
|
||||||
|
// Ensure, after the above calculation, we are still within bounds
|
||||||
|
translate = Math.min(Math.max(translate, startBound), endBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gBrowser.pinnedTabCount && !this._dragToPinPromoCard.shouldRender) {
|
||||||
|
let pinnedDropIndicatorMargin = parseFloat(
|
||||||
|
window.getComputedStyle(this._pinnedDropIndicator).marginInline
|
||||||
|
);
|
||||||
|
this._checkWithinPinnedContainerBounds({
|
||||||
|
firstMovingTabScreen,
|
||||||
|
lastMovingTabScreen,
|
||||||
|
pinnedTabsStartEdge: this._rtlMode
|
||||||
|
? endEdge(this._tabbrowserTabs.arrowScrollbox) + pinnedDropIndicatorMargin
|
||||||
|
: this[screenAxis],
|
||||||
|
pinnedTabsEndEdge: this._rtlMode
|
||||||
|
? endEdge(this._tabbrowserTabs)
|
||||||
|
: this._tabbrowserTabs.arrowScrollbox[screenAxis] - pinnedDropIndicatorMargin,
|
||||||
|
translate,
|
||||||
|
draggedTab,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dragData.translatePos = translate;
|
||||||
|
|
||||||
|
tabs = tabs.filter((t) => !movingTabsSet.has(t) || t == draggedTab);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the `draggedTab` is just starting to move, the `draggedTab` is in
|
||||||
|
* its original location and the `dropElementIndex == draggedTab.elementIndex`.
|
||||||
|
* Any tabs or tab group labels passed in as `item` will result in a 0 shift
|
||||||
|
* because all of those items should also continue to appear in their original
|
||||||
|
* locations.
|
||||||
|
*
|
||||||
|
* Once the `draggedTab` is more "backward" in the tab strip than its original
|
||||||
|
* position, any tabs or tab group labels between the `draggedTab`'s original
|
||||||
|
* `elementIndex` and the current `dropElementIndex` should shift "forward"
|
||||||
|
* out of the way of the dragging tabs.
|
||||||
|
*
|
||||||
|
* When the `draggedTab` is more "forward" in the tab strip than its original
|
||||||
|
* position, any tabs or tab group labels between the `draggedTab`'s original
|
||||||
|
* `elementIndex` and the current `dropElementIndex` should shift "backward"
|
||||||
|
* out of the way of the dragging tabs.
|
||||||
|
*
|
||||||
|
* @param {MozTabbrowserTab|MozTabbrowserTabGroup.label} item
|
||||||
|
* @param {number} dropElementIndex
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
let getTabShift = (item, dropElementIndex) => {
|
||||||
|
if (item.elementIndex < draggedTab.elementIndex && item.elementIndex >= dropElementIndex) {
|
||||||
|
return this._rtlMode ? -shiftSize : shiftSize;
|
||||||
|
}
|
||||||
|
if (item.elementIndex > draggedTab.elementIndex && item.elementIndex < dropElementIndex) {
|
||||||
|
return this._rtlMode ? shiftSize : -shiftSize;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
let oldDropElementIndex = dragData.animDropElementIndex ?? movingTabs[0].elementIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the higher % by which one element overlaps another
|
||||||
|
* in the tab strip.
|
||||||
|
*
|
||||||
|
* When element 1 is further forward in the tab strip:
|
||||||
|
*
|
||||||
|
* p1 p2 p1+s1 p2+s2
|
||||||
|
* | | | |
|
||||||
|
* ---------------------------------
|
||||||
|
* ========================
|
||||||
|
* s1
|
||||||
|
* ===================
|
||||||
|
* s2
|
||||||
|
* ==========
|
||||||
|
* overlap
|
||||||
|
*
|
||||||
|
* When element 2 is further forward in the tab strip:
|
||||||
|
*
|
||||||
|
* p2 p1 p2+s2 p1+s1
|
||||||
|
* | | | |
|
||||||
|
* ---------------------------------
|
||||||
|
* ========================
|
||||||
|
* s2
|
||||||
|
* ===================
|
||||||
|
* s1
|
||||||
|
* ==========
|
||||||
|
* overlap
|
||||||
|
*
|
||||||
|
* @param {number} p1
|
||||||
|
* Position (x or y value in screen coordinates) of element 1.
|
||||||
|
* @param {number} s1
|
||||||
|
* Size (width or height) of element 1.
|
||||||
|
* @param {number} p2
|
||||||
|
* Position (x or y value in screen coordinates) of element 2.
|
||||||
|
* @param {number} s2
|
||||||
|
* Size (width or height) of element 1.
|
||||||
|
* @returns {number}
|
||||||
|
* Percent between 0.0 and 1.0 (inclusive) of element 1 or element 2
|
||||||
|
* that is overlapped by the other element. If the elements have
|
||||||
|
* different sizes, then this returns the larger overlap percentage.
|
||||||
|
*/
|
||||||
|
function greatestOverlap(p1, s1, p2, s2) {
|
||||||
|
let overlapSize;
|
||||||
|
if (p1 < p2) {
|
||||||
|
// element 1 starts first
|
||||||
|
overlapSize = p1 + s1 - p2;
|
||||||
|
} else {
|
||||||
|
// element 2 starts first
|
||||||
|
overlapSize = p2 + s2 - p1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No overlap if size is <= 0
|
||||||
|
if (overlapSize <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the overlap fraction from each element's perspective.
|
||||||
|
let overlapPercent = Math.max(overlapSize / s1, overlapSize / s2);
|
||||||
|
|
||||||
|
return Math.min(overlapPercent, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine what tab/tab group label we're dragging over.
|
||||||
|
*
|
||||||
|
* When dragging right or downwards, the reference point for overlap is
|
||||||
|
* the right or bottom edge of the most forward moving tab.
|
||||||
|
*
|
||||||
|
* When dragging left or upwards, the reference point for overlap is the
|
||||||
|
* left or top edge of the most backward moving tab.
|
||||||
|
*
|
||||||
|
* @returns {Element|null}
|
||||||
|
* The tab or tab group label that should be used to visually shift tab
|
||||||
|
* strip elements out of the way of the dragged tab(s) during a drag
|
||||||
|
* operation. Note: this is not used to determine where the dragged
|
||||||
|
* tab(s) will be dropped, it is only used for visual animation at this
|
||||||
|
* time.
|
||||||
|
*/
|
||||||
|
let getOverlappedElement = () => {
|
||||||
|
let point = (screenForward ? lastMovingTabScreen : firstMovingTabScreen) + translate;
|
||||||
|
let low = 0;
|
||||||
|
let high = tabs.length - 1;
|
||||||
|
while (low <= high) {
|
||||||
|
let mid = Math.floor((low + high) / 2);
|
||||||
|
if (tabs[mid] == draggedTab && ++mid > high) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let element = tabs[mid];
|
||||||
|
let elementForSize = elementToMove(element);
|
||||||
|
screen = elementForSize[screenAxis] + getTabShift(element, oldDropElementIndex);
|
||||||
|
|
||||||
|
if (screen > point) {
|
||||||
|
high = mid - 1;
|
||||||
|
} else if (screen + bounds(elementForSize)[size] < point) {
|
||||||
|
low = mid + 1;
|
||||||
|
} else {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
let dropElement = getOverlappedElement();
|
||||||
|
|
||||||
|
let newDropElementIndex;
|
||||||
|
if (dropElement) {
|
||||||
|
newDropElementIndex = dropElement.elementIndex;
|
||||||
|
} else {
|
||||||
|
// When the dragged element(s) moves past a tab strip item, the dragged
|
||||||
|
// element's leading edge starts dragging over empty space, resulting in
|
||||||
|
// no overlapping `dropElement`. In these cases, try to fall back to the
|
||||||
|
// previous animation drop element index to avoid unstable animations
|
||||||
|
// (tab strip items snapping back and forth to shift out of the way of
|
||||||
|
// the dragged element(s)).
|
||||||
|
newDropElementIndex = oldDropElementIndex;
|
||||||
|
|
||||||
|
// We always want to have a `dropElement` so that we can determine where to
|
||||||
|
// logically drop the dragged element(s).
|
||||||
|
//
|
||||||
|
// It's tempting to set `dropElement` to
|
||||||
|
// `this.ariaFocusableItems.at(oldDropElementIndex)`, and that is correct
|
||||||
|
// for most cases, but there are edge cases:
|
||||||
|
//
|
||||||
|
// 1) the drop element index range needs to be one larger than the number of
|
||||||
|
// items that can move in the tab strip. The simplest example is when all
|
||||||
|
// tabs are ungrouped and unpinned: for 5 tabs, the drop element index needs
|
||||||
|
// to be able to go from 0 (become the first tab) to 5 (become the last tab).
|
||||||
|
// `this.ariaFocusableItems.at(5)` would be `undefined` when dragging to the
|
||||||
|
// end of the tab strip. In this specific case, it works to fall back to
|
||||||
|
// setting the drop element to the last tab.
|
||||||
|
//
|
||||||
|
// 2) the `elementIndex` values of the tab strip items do not change during
|
||||||
|
// the drag operation. When dragging the last tab or multiple tabs at the end
|
||||||
|
// of the tab strip, having `dropElement` fall back to the last tab makes the
|
||||||
|
// drop element one of the moving tabs. This can have some unexpected behavior
|
||||||
|
// if not careful. Falling back to the last tab that's not moving (instead of
|
||||||
|
// just the last tab) helps ensure that `dropElement` is always a stable target
|
||||||
|
// to drop next to.
|
||||||
|
//
|
||||||
|
// 3) all of the elements in the tab strip are moving, in which case there can't
|
||||||
|
// be a drop element and it should stay `undefined`.
|
||||||
|
//
|
||||||
|
// 4) we just started dragging and the `oldDropElementIndex` has its default
|
||||||
|
// valuë of `movingTabs[0].elementIndex`. In this case, the drop element
|
||||||
|
// shouldn't be a moving tab, so keep it `undefined`.
|
||||||
|
let lastPossibleDropElement = this._rtlMode
|
||||||
|
? tabs.find((t) => t != draggedTab)
|
||||||
|
: tabs.findLast((t) => t != draggedTab);
|
||||||
|
let maxElementIndexForDropElement = lastPossibleDropElement?.elementIndex;
|
||||||
|
if (Number.isInteger(maxElementIndexForDropElement)) {
|
||||||
|
let index = Math.min(oldDropElementIndex, maxElementIndexForDropElement);
|
||||||
|
let oldDropElementCandidate = this._tabbrowserTabs.ariaFocusableItems.at(index);
|
||||||
|
if (!movingTabsSet.has(oldDropElementCandidate)) {
|
||||||
|
dropElement = oldDropElementCandidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let moveOverThreshold;
|
||||||
|
let overlapPercent;
|
||||||
|
let dropBefore;
|
||||||
|
if (dropElement) {
|
||||||
|
let dropElementForOverlap = elementToMove(dropElement);
|
||||||
|
|
||||||
|
let dropElementScreen = dropElementForOverlap[screenAxis];
|
||||||
|
let dropElementPos = dropElementScreen + getTabShift(dropElement, oldDropElementIndex);
|
||||||
|
let dropElementSize = bounds(dropElementForOverlap)[size];
|
||||||
|
let firstMovingTabPos = firstMovingTabScreen + translate;
|
||||||
|
overlapPercent = greatestOverlap(
|
||||||
|
firstMovingTabPos,
|
||||||
|
shiftSize,
|
||||||
|
dropElementPos,
|
||||||
|
dropElementSize
|
||||||
|
);
|
||||||
|
|
||||||
|
moveOverThreshold = gBrowser._tabGroupsEnabled
|
||||||
|
? Services.prefs.getIntPref('browser.tabs.dragDrop.moveOverThresholdPercent') / 100
|
||||||
|
: 0.5;
|
||||||
|
moveOverThreshold = Math.min(1, Math.max(0, moveOverThreshold));
|
||||||
|
let shouldMoveOver = overlapPercent > moveOverThreshold;
|
||||||
|
if (logicalForward && shouldMoveOver) {
|
||||||
|
newDropElementIndex++;
|
||||||
|
} else if (!logicalForward && !shouldMoveOver) {
|
||||||
|
newDropElementIndex++;
|
||||||
|
if (newDropElementIndex > oldDropElementIndex) {
|
||||||
|
// FIXME: Not quite sure what's going on here, but this check
|
||||||
|
// prevents jittery back-and-forth movement of background tabs
|
||||||
|
// in certain cases.
|
||||||
|
newDropElementIndex = oldDropElementIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recalculate the overlap with the updated drop index for when the
|
||||||
|
// drop element moves over.
|
||||||
|
dropElementPos = dropElementScreen + getTabShift(dropElement, newDropElementIndex);
|
||||||
|
overlapPercent = greatestOverlap(
|
||||||
|
firstMovingTabPos,
|
||||||
|
shiftSize,
|
||||||
|
dropElementPos,
|
||||||
|
dropElementSize
|
||||||
|
);
|
||||||
|
dropBefore = firstMovingTabPos < dropElementPos;
|
||||||
|
if (this._rtlMode) {
|
||||||
|
dropBefore = !dropBefore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._tabbrowserTabs.removeAttribute('movingtab-group');
|
||||||
|
this._resetGroupTarget(document.querySelector('[dragover-groupTarget]'));
|
||||||
|
|
||||||
|
delete dragData.shouldDropIntoCollapsedTabGroup;
|
||||||
|
|
||||||
|
// Default to dropping into `dropElement`'s tab group, if it exists.
|
||||||
|
let dropElementGroup = dropElement?.group;
|
||||||
|
let colorCode = dropElementGroup?.color;
|
||||||
|
|
||||||
|
let lastUnmovingTabInGroup = dropElementGroup?.tabs.findLast((t) => !movingTabsSet.has(t));
|
||||||
|
if (
|
||||||
|
isTab(dropElement) &&
|
||||||
|
dropElementGroup &&
|
||||||
|
dropElement == lastUnmovingTabInGroup &&
|
||||||
|
!dropBefore
|
||||||
|
) {
|
||||||
|
// Dragging tab over the last tab of a tab group, but not enough
|
||||||
|
// for it to drop into the tab group. Drop it after the tab group instead.
|
||||||
|
dropElement = dropElementGroup;
|
||||||
|
colorCode = undefined;
|
||||||
|
} else if (isTabGroupLabel(dropElement)) {
|
||||||
|
// Dropping right before the first tab in the tab group.
|
||||||
|
dropElement = dropElementGroup.tabs[0];
|
||||||
|
dropBefore = true;
|
||||||
|
}
|
||||||
|
this._setDragOverGroupColor(colorCode);
|
||||||
|
this._tabbrowserTabs.toggleAttribute('movingtab-addToGroup', colorCode);
|
||||||
|
this._tabbrowserTabs.toggleAttribute('movingtab-ungroup', !colorCode);
|
||||||
|
|
||||||
|
this.#applyDragoverIndicator(event, tabs, movingTabs, overlapPercent);
|
||||||
|
|
||||||
|
if (
|
||||||
|
newDropElementIndex == oldDropElementIndex &&
|
||||||
|
dropBefore == dragData.dropBefore &&
|
||||||
|
dropElement == dragData.dropElement
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dragData.dropElement = dropElement;
|
||||||
|
dragData.dropBefore = dropBefore;
|
||||||
|
dragData.animDropElementIndex = newDropElementIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_dragend(event) {
|
||||||
|
super.handle_dragend(event);
|
||||||
|
this.#removeDragOverBackground();
|
||||||
|
gZenPinnedTabManager.removeTabContainersDragoverClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
#applyDragOverBackground(element) {
|
||||||
|
if (this.#dragOverBackground && this.#lastDropTarget === element) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const margin = 2;
|
||||||
|
const rect = window.windowUtils.getBoundsWithoutFlushing(element);
|
||||||
|
this.#dragOverBackground = document.createElement('div');
|
||||||
|
this.#dragOverBackground.id = 'zen-dragover-background';
|
||||||
|
this.#dragOverBackground.style.height = `${rect.height - margin * 2}px`;
|
||||||
|
this.#dragOverBackground.style.top = `${rect.top + margin}px`;
|
||||||
|
gNavToolbox.appendChild(this.#dragOverBackground);
|
||||||
|
this.#lastDropTarget = element;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#removeDragOverBackground() {
|
||||||
|
if (this.#dragOverBackground) {
|
||||||
|
this.#dragOverBackground.remove();
|
||||||
|
this.#dragOverBackground = null;
|
||||||
|
this.#lastDropTarget = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#applyDragoverIndicator(event, tabs, movingTabs, overlapPercent) {
|
||||||
|
const separation = 4;
|
||||||
|
const dropZoneSelector = ':is(.tabbrowser-tab, .zen-drop-target, .tab-group-label)';
|
||||||
|
let shouldPlayHapticFeedback = false;
|
||||||
|
let dropElement = event.target.closest(dropZoneSelector);
|
||||||
|
if (!dropElement) {
|
||||||
|
const numEssentials = gBrowser._numZenEssentials;
|
||||||
|
const numPinned = gBrowser.pinnedTabCount - numEssentials;
|
||||||
|
const tabToUse = event.target.closest(dropZoneSelector);
|
||||||
|
if (!tabToUse) {
|
||||||
|
this.#removeDragOverBackground();
|
||||||
|
gZenPinnedTabManager.removeTabContainersDragoverClass();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isPinned = tabToUse.pinned;
|
||||||
|
const relativeTabs = tabs.slice(isPinned ? 0 : numPinned, isPinned ? numPinned : undefined);
|
||||||
|
const draggedTabRect = elementToMove(tabToUse).getBoundingClientRect();
|
||||||
|
dropElement = event.clientY > draggedTabRect.top ? relativeTabs.at(-1) : relativeTabs[0];
|
||||||
|
}
|
||||||
|
dropElement = elementToMove(dropElement);
|
||||||
|
if (this.#lastDropTarget !== dropElement) {
|
||||||
|
shouldPlayHapticFeedback = this.#lastDropTarget !== null;
|
||||||
|
this.#removeDragOverBackground();
|
||||||
|
}
|
||||||
|
let canHightlightGroup =
|
||||||
|
gZenFolders.highlightGroupOnDragOver(dropElement.parentElement, movingTabs) ||
|
||||||
|
!dropElement.parentElement?.isZenFolder;
|
||||||
|
if (isTab(dropElement)) {
|
||||||
|
const indicator = gZenPinnedTabManager.dragIndicator;
|
||||||
|
let rect = dropElement.getBoundingClientRect();
|
||||||
|
let top = 0;
|
||||||
|
const threshold =
|
||||||
|
Services.prefs.getIntPref('browser.tabs.dragDrop.moveOverThresholdPercent') / 100;
|
||||||
|
if (overlapPercent > threshold) {
|
||||||
|
top = Math.round(rect.top + rect.height) + 'px';
|
||||||
|
} else {
|
||||||
|
top = Math.round(rect.top) + 'px';
|
||||||
|
}
|
||||||
|
if (indicator.style.top !== top) {
|
||||||
|
shouldPlayHapticFeedback = true;
|
||||||
|
}
|
||||||
|
indicator.setAttribute('orientation', 'horizontal');
|
||||||
|
indicator.style.setProperty('--indicator-left', rect.left + separation / 2 + 'px');
|
||||||
|
indicator.style.setProperty('--indicator-width', rect.width - separation + 'px');
|
||||||
|
indicator.style.top = top;
|
||||||
|
indicator.style.removeProperty('left');
|
||||||
|
} else if (dropElement.classList.contains('zen-drop-target') && canHightlightGroup) {
|
||||||
|
// removeTabContainersDragoverClass Already calls a new haptic feedback
|
||||||
|
shouldPlayHapticFeedback =
|
||||||
|
this.#applyDragOverBackground(dropElement) && !gZenPinnedTabManager._dragIndicator;
|
||||||
|
gZenPinnedTabManager.removeTabContainersDragoverClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldPlayHapticFeedback) {
|
||||||
|
Services.zen.playHapticFeedback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#getDragImageOffset(tab) {
|
||||||
|
const { offsetX, offsetY } = tab._dragData;
|
||||||
|
const rect = tab.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
offsetX: offsetX - rect.left,
|
||||||
|
offsetY: offsetY - rect.top,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -11,4 +11,6 @@
|
|||||||
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenMods.mjs", { global: "current" });
|
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenMods.mjs", { global: "current" });
|
||||||
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenKeyboardShortcuts.mjs", { global: "current" });
|
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenKeyboardShortcuts.mjs", { global: "current" });
|
||||||
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenSessionStore.mjs", { global: "current" });
|
ChromeUtils.importESModule("chrome://browser/content/zen-components/ZenSessionStore.mjs", { global: "current" });
|
||||||
|
|
||||||
|
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenDragAndDrop.js", this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
content/browser/zen-components/ZenSessionStore.mjs (../../zen/common/modules/ZenSessionStore.mjs)
|
content/browser/zen-components/ZenSessionStore.mjs (../../zen/common/modules/ZenSessionStore.mjs)
|
||||||
content/browser/zen-components/ZenHasPolyfill.mjs (../../zen/common/modules/ZenHasPolyfill.mjs)
|
content/browser/zen-components/ZenHasPolyfill.mjs (../../zen/common/modules/ZenHasPolyfill.mjs)
|
||||||
content/browser/zen-components/ZenSidebarNotification.mjs (../../zen/common/modules/ZenSidebarNotification.mjs)
|
content/browser/zen-components/ZenSidebarNotification.mjs (../../zen/common/modules/ZenSidebarNotification.mjs)
|
||||||
|
content/browser/zen-components/ZenDragAndDrop.js (../../zen/common/ZenDragAndDrop.js)
|
||||||
|
|
||||||
content/browser/zen-components/ZenEmojisData.min.mjs (../../zen/common/emojis/ZenEmojisData.min.mjs)
|
content/browser/zen-components/ZenEmojisData.min.mjs (../../zen/common/emojis/ZenEmojisData.min.mjs)
|
||||||
content/browser/zen-components/ZenEmojiPicker.mjs (../../zen/common/emojis/ZenEmojiPicker.mjs)
|
content/browser/zen-components/ZenEmojiPicker.mjs (../../zen/common/emojis/ZenEmojiPicker.mjs)
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export class nsZenMultiWindowFeature {
|
|||||||
if (!nsZenMultiWindowFeature.isActiveWindow) {
|
if (!nsZenMultiWindowFeature.isActiveWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return this.forEachWindow(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
async forEachWindow(callback) {
|
||||||
for (const browser of nsZenMultiWindowFeature.browsers) {
|
for (const browser of nsZenMultiWindowFeature.browsers) {
|
||||||
try {
|
try {
|
||||||
if (browser.closed) continue;
|
if (browser.closed) continue;
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ class ZenSessionStore extends nsZenPreloadedFeature {
|
|||||||
if (tabData.zenWorkspace) {
|
if (tabData.zenWorkspace) {
|
||||||
tab.setAttribute('zen-workspace-id', tabData.zenWorkspace);
|
tab.setAttribute('zen-workspace-id', tabData.zenWorkspace);
|
||||||
}
|
}
|
||||||
if (tabData.zenPinnedId) {
|
// Keep for now, for backward compatibility for window sync to work.
|
||||||
tab.setAttribute('zen-pin-id', tabData.zenPinnedId);
|
if (tabData.zenSyncId || tabData.zenPinnedId) {
|
||||||
|
tab.setAttribute('id', tabData.zenSyncId || tabData.zenPinnedId);
|
||||||
}
|
}
|
||||||
if (tabData.zenHasStaticLabel) {
|
if (tabData.zenHasStaticLabel) {
|
||||||
tab.setAttribute('zen-has-static-label', 'true');
|
tab.setAttribute('zen-has-static-label', 'true');
|
||||||
@@ -32,6 +33,9 @@ class ZenSessionStore extends nsZenPreloadedFeature {
|
|||||||
if (tabData.zenPinnedEntry) {
|
if (tabData.zenPinnedEntry) {
|
||||||
tab.setAttribute('zen-pinned-entry', tabData.zenPinnedEntry);
|
tab.setAttribute('zen-pinned-entry', tabData.zenPinnedEntry);
|
||||||
}
|
}
|
||||||
|
if (tabData._zenPinnedInitialState) {
|
||||||
|
tab._zenPinnedInitialState = tabData._zenPinnedInitialState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #waitAndCleanup() {
|
async #waitAndCleanup() {
|
||||||
|
|||||||
@@ -12,12 +12,7 @@ class ZenStartup {
|
|||||||
|
|
||||||
isReady = false;
|
isReady = false;
|
||||||
|
|
||||||
async init() {
|
init() {
|
||||||
// important: We do this to ensure that some firefox components
|
|
||||||
// are initialized before we start our own initialization.
|
|
||||||
// please, do not remove this line and if you do, make sure to
|
|
||||||
// test the startup process.
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
||||||
this.openWatermark();
|
this.openWatermark();
|
||||||
this.#initBrowserBackground();
|
this.#initBrowserBackground();
|
||||||
this.#changeSidebarLocation();
|
this.#changeSidebarLocation();
|
||||||
@@ -97,6 +92,7 @@ class ZenStartup {
|
|||||||
// Just in case we didn't get the right size.
|
// Just in case we didn't get the right size.
|
||||||
gZenUIManager.updateTabsToolbar();
|
gZenUIManager.updateTabsToolbar();
|
||||||
this.closeWatermark();
|
this.closeWatermark();
|
||||||
|
document.getElementById('tabbrowser-arrowscrollbox').setAttribute('orient', 'vertical');
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -811,7 +811,6 @@ window.gZenVerticalTabsManager = {
|
|||||||
!aItem.isConnected ||
|
!aItem.isConnected ||
|
||||||
gZenUIManager.testingEnabled ||
|
gZenUIManager.testingEnabled ||
|
||||||
!gZenStartup.isReady ||
|
!gZenStartup.isReady ||
|
||||||
!gZenPinnedTabManager.hasInitializedPins ||
|
|
||||||
aItem.group?.hasAttribute('split-view-group')
|
aItem.group?.hasAttribute('split-view-group')
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
@@ -1310,14 +1309,6 @@ window.gZenVerticalTabsManager = {
|
|||||||
} else {
|
} else {
|
||||||
gBrowser.setTabTitle(this._tabEdited);
|
gBrowser.setTabTitle(this._tabEdited);
|
||||||
}
|
}
|
||||||
if (this._tabEdited.getAttribute('zen-pin-id')) {
|
|
||||||
// Update pin title in storage
|
|
||||||
await gZenPinnedTabManager.updatePinTitle(
|
|
||||||
this._tabEdited,
|
|
||||||
this._tabEdited.label,
|
|
||||||
!!newName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maybe add some confetti here?!?
|
// Maybe add some confetti here?!?
|
||||||
gZenUIManager.motion.animate(
|
gZenUIManager.motion.animate(
|
||||||
|
|||||||
@@ -60,3 +60,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zen-pseudo-browser-image {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
opacity: 0.4;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser[zen-pseudo-hidden='true'] {
|
||||||
|
-moz-subtree-hidden-only-visually: 1 !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -231,6 +231,13 @@
|
|||||||
--toolbox-textcolor: currentColor !important;
|
--toolbox-textcolor: currentColor !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[zen-unsynced-window='true'] {
|
||||||
|
--zen-main-browser-background: linear-gradient(130deg, light-dark(rgb(240, 230, 200), rgb(30, 25, 20)) 0%, light-dark(rgb(220, 200, 150), rgb(50, 45, 40)) 100%);
|
||||||
|
--zen-main-browser-background-toolbar: var(--zen-main-browser-background);
|
||||||
|
--zen-primary-color: light-dark(rgb(200, 100, 20), rgb(220, 120, 30)) !important;
|
||||||
|
--toolbox-textcolor: currentColor !important;
|
||||||
|
}
|
||||||
|
|
||||||
--toolbar-field-background-color: var(--zen-colors-input-bg) !important;
|
--toolbar-field-background-color: var(--zen-colors-input-bg) !important;
|
||||||
--arrowpanel-background: var(--zen-dialog-background) !important;
|
--arrowpanel-background: var(--zen-dialog-background) !important;
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ export const ZenCustomizableUI = new (class {
|
|||||||
#initCreateNewButton(window) {
|
#initCreateNewButton(window) {
|
||||||
const button = window.document.getElementById('zen-create-new-button');
|
const button = window.document.getElementById('zen-create-new-button');
|
||||||
button.addEventListener('command', (event) => {
|
button.addEventListener('command', (event) => {
|
||||||
|
if (window.gZenWorkspaces.privateWindowOrDisabled) {
|
||||||
|
return window.document.getElementById('cmd_newNavigatorTab').doCommand();
|
||||||
|
}
|
||||||
if (button.hasAttribute('open')) {
|
if (button.hasAttribute('open')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,138 +6,135 @@ document.addEventListener(
|
|||||||
'MozBeforeInitialXULLayout',
|
'MozBeforeInitialXULLayout',
|
||||||
() => {
|
() => {
|
||||||
// <commandset id="mainCommandSet"> defined in browser-sets.inc
|
// <commandset id="mainCommandSet"> defined in browser-sets.inc
|
||||||
document
|
document.getElementById('zenCommandSet').addEventListener('command', (event) => {
|
||||||
.getElementById('zenCommandSet')
|
switch (event.target.id) {
|
||||||
|
case 'cmd_zenCompactModeToggle':
|
||||||
.addEventListener('command', (event) => {
|
gZenCompactModeManager.toggle();
|
||||||
switch (event.target.id) {
|
break;
|
||||||
case 'cmd_zenCompactModeToggle':
|
case 'cmd_zenCompactModeShowSidebar':
|
||||||
gZenCompactModeManager.toggle();
|
gZenCompactModeManager.toggleSidebar();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenCompactModeShowSidebar':
|
case 'cmd_toggleCompactModeIgnoreHover':
|
||||||
gZenCompactModeManager.toggleSidebar();
|
gZenCompactModeManager.toggle(true);
|
||||||
break;
|
break;
|
||||||
case 'cmd_toggleCompactModeIgnoreHover':
|
case 'cmd_zenWorkspaceForward':
|
||||||
gZenCompactModeManager.toggle(true);
|
gZenWorkspaces.changeWorkspaceShortcut();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenWorkspaceForward':
|
case 'cmd_zenWorkspaceBackward':
|
||||||
gZenWorkspaces.changeWorkspaceShortcut();
|
gZenWorkspaces.changeWorkspaceShortcut(-1);
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenWorkspaceBackward':
|
case 'cmd_zenSplitViewGrid':
|
||||||
gZenWorkspaces.changeWorkspaceShortcut(-1);
|
gZenViewSplitter.toggleShortcut('grid');
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewGrid':
|
case 'cmd_zenSplitViewVertical':
|
||||||
gZenViewSplitter.toggleShortcut('grid');
|
gZenViewSplitter.toggleShortcut('vsep');
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewVertical':
|
case 'cmd_zenSplitViewHorizontal':
|
||||||
gZenViewSplitter.toggleShortcut('vsep');
|
gZenViewSplitter.toggleShortcut('hsep');
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewHorizontal':
|
case 'cmd_zenSplitViewUnsplit':
|
||||||
gZenViewSplitter.toggleShortcut('hsep');
|
gZenViewSplitter.toggleShortcut('unsplit');
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewUnsplit':
|
case 'cmd_zenSplitViewContextMenu':
|
||||||
gZenViewSplitter.toggleShortcut('unsplit');
|
gZenViewSplitter.contextSplitTabs();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewContextMenu':
|
case 'cmd_zenCopyCurrentURLMarkdown':
|
||||||
gZenViewSplitter.contextSplitTabs();
|
gZenCommonActions.copyCurrentURLAsMarkdownToClipboard();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenCopyCurrentURLMarkdown':
|
case 'cmd_zenCopyCurrentURL':
|
||||||
gZenCommonActions.copyCurrentURLAsMarkdownToClipboard();
|
gZenCommonActions.copyCurrentURLToClipboard();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenCopyCurrentURL':
|
case 'cmd_zenPinnedTabReset':
|
||||||
gZenCommonActions.copyCurrentURLToClipboard();
|
gZenPinnedTabManager.resetPinnedTab(gBrowser.selectedTab);
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenPinnedTabReset':
|
case 'cmd_zenPinnedTabResetNoTab':
|
||||||
gZenPinnedTabManager.resetPinnedTab(gBrowser.selectedTab);
|
gZenPinnedTabManager.resetPinnedTab();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenPinnedTabResetNoTab':
|
case 'cmd_zenToggleSidebar':
|
||||||
gZenPinnedTabManager.resetPinnedTab();
|
gZenVerticalTabsManager.toggleExpand();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenToggleSidebar':
|
case 'cmd_zenOpenZenThemePicker':
|
||||||
gZenVerticalTabsManager.toggleExpand();
|
gZenThemePicker.openThemePicker(event);
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenOpenZenThemePicker':
|
case 'cmd_zenChangeWorkspaceTab':
|
||||||
gZenThemePicker.openThemePicker(event);
|
gZenWorkspaces.changeTabWorkspace(
|
||||||
break;
|
event.sourceEvent.target.getAttribute('zen-workspace-id')
|
||||||
case 'cmd_zenChangeWorkspaceTab':
|
);
|
||||||
gZenWorkspaces.changeTabWorkspace(
|
break;
|
||||||
event.sourceEvent.target.getAttribute('zen-workspace-id')
|
case 'cmd_zenToggleTabsOnRight':
|
||||||
);
|
gZenVerticalTabsManager.toggleTabsOnRight();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenToggleTabsOnRight':
|
case 'cmd_zenSplitViewLinkInNewTab':
|
||||||
gZenVerticalTabsManager.toggleTabsOnRight();
|
gZenViewSplitter.splitLinkInNewTab();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenSplitViewLinkInNewTab':
|
case 'cmd_zenNewEmptySplit':
|
||||||
gZenViewSplitter.splitLinkInNewTab();
|
setTimeout(() => {
|
||||||
break;
|
gZenViewSplitter.createEmptySplit();
|
||||||
case 'cmd_zenNewEmptySplit':
|
}, 0);
|
||||||
setTimeout(() => {
|
break;
|
||||||
gZenViewSplitter.createEmptySplit();
|
case 'cmd_zenReplacePinnedUrlWithCurrent':
|
||||||
}, 0);
|
gZenPinnedTabManager.replacePinnedUrlWithCurrent();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenReplacePinnedUrlWithCurrent':
|
case 'cmd_contextZenAddToEssentials':
|
||||||
gZenPinnedTabManager.replacePinnedUrlWithCurrent();
|
gZenPinnedTabManager.addToEssentials();
|
||||||
break;
|
break;
|
||||||
case 'cmd_contextZenAddToEssentials':
|
case 'cmd_contextZenRemoveFromEssentials':
|
||||||
gZenPinnedTabManager.addToEssentials();
|
gZenPinnedTabManager.removeEssentials();
|
||||||
break;
|
break;
|
||||||
case 'cmd_contextZenRemoveFromEssentials':
|
case 'cmd_zenCtxDeleteWorkspace':
|
||||||
gZenPinnedTabManager.removeEssentials();
|
gZenWorkspaces.contextDeleteWorkspace(event);
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenCtxDeleteWorkspace':
|
case 'cmd_zenChangeWorkspaceName':
|
||||||
gZenWorkspaces.contextDeleteWorkspace(event);
|
gZenVerticalTabsManager.renameTabStart({
|
||||||
break;
|
target: gZenWorkspaces.activeWorkspaceIndicator.querySelector(
|
||||||
case 'cmd_zenChangeWorkspaceName':
|
'.zen-current-workspace-indicator-name'
|
||||||
gZenVerticalTabsManager.renameTabStart({
|
),
|
||||||
target: gZenWorkspaces.activeWorkspaceIndicator.querySelector(
|
});
|
||||||
'.zen-current-workspace-indicator-name'
|
break;
|
||||||
),
|
case 'cmd_zenChangeWorkspaceIcon':
|
||||||
});
|
gZenWorkspaces.changeWorkspaceIcon();
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenChangeWorkspaceIcon':
|
case 'cmd_zenReorderWorkspaces':
|
||||||
gZenWorkspaces.changeWorkspaceIcon();
|
gZenUIManager.showToast('zen-workspaces-how-to-reorder-title', {
|
||||||
break;
|
timeout: 9000,
|
||||||
case 'cmd_zenReorderWorkspaces':
|
descriptionId: 'zen-workspaces-how-to-reorder-desc',
|
||||||
gZenUIManager.showToast('zen-workspaces-how-to-reorder-title', {
|
});
|
||||||
timeout: 9000,
|
break;
|
||||||
descriptionId: 'zen-workspaces-how-to-reorder-desc',
|
case 'cmd_zenOpenWorkspaceCreation':
|
||||||
});
|
gZenWorkspaces.openWorkspaceCreation(event);
|
||||||
break;
|
break;
|
||||||
case 'cmd_zenOpenWorkspaceCreation':
|
case 'cmd_zenOpenFolderCreation':
|
||||||
gZenWorkspaces.openWorkspaceCreation(event);
|
gZenFolders.createFolder([], {
|
||||||
break;
|
renameFolder: true,
|
||||||
case 'cmd_zenOpenFolderCreation':
|
});
|
||||||
gZenFolders.createFolder([], {
|
break;
|
||||||
renameFolder: true,
|
case 'cmd_zenTogglePinTab': {
|
||||||
});
|
const currentTab = gBrowser.selectedTab;
|
||||||
break;
|
if (currentTab && !currentTab.hasAttribute('zen-empty-tab')) {
|
||||||
case 'cmd_zenTogglePinTab': {
|
if (currentTab.pinned) {
|
||||||
const currentTab = gBrowser.selectedTab;
|
gBrowser.unpinTab(currentTab);
|
||||||
if (currentTab && !currentTab.hasAttribute('zen-empty-tab')) {
|
} else {
|
||||||
if (currentTab.pinned) {
|
gBrowser.pinTab(currentTab);
|
||||||
gBrowser.unpinTab(currentTab);
|
|
||||||
} else {
|
|
||||||
gBrowser.pinTab(currentTab);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'cmd_zenCloseUnpinnedTabs':
|
break;
|
||||||
gZenWorkspaces.closeAllUnpinnedTabs();
|
|
||||||
break;
|
|
||||||
case 'cmd_zenUnloadWorkspace': {
|
|
||||||
gZenWorkspaces.unloadWorkspace();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
gZenGlanceManager.handleMainCommandSet(event);
|
|
||||||
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
|
|
||||||
const index = parseInt(event.target.id.replace('cmd_zenWorkspaceSwitch', ''), 10) - 1;
|
|
||||||
gZenWorkspaces.shortcutSwitchTo(index);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
case 'cmd_zenCloseUnpinnedTabs':
|
||||||
|
gZenWorkspaces.closeAllUnpinnedTabs();
|
||||||
|
break;
|
||||||
|
case 'cmd_zenUnloadWorkspace': {
|
||||||
|
gZenWorkspaces.unloadWorkspace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
gZenGlanceManager.handleMainCommandSet(event);
|
||||||
|
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
|
||||||
|
const index = parseInt(event.target.id.replace('cmd_zenWorkspaceSwitch', ''), 10) - 1;
|
||||||
|
gZenWorkspaces.shortcutSwitchTo(index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class ZenFolder extends MozTabbrowserTabGroup {
|
|||||||
#initialized = false;
|
#initialized = false;
|
||||||
|
|
||||||
static markup = `
|
static markup = `
|
||||||
<hbox class="tab-group-label-container" pack="center">
|
<hbox class="tab-group-label-container zen-drop-target" pack="center">
|
||||||
<html:div class="tab-group-folder-icon"/>
|
<html:div class="tab-group-folder-icon"/>
|
||||||
<label class="tab-group-label" role="button"/>
|
<label class="tab-group-label" role="button"/>
|
||||||
<image class="tab-reset-button reset-icon" role="button" keyNav="false" data-l10n-id="zen-folders-unload-all-tooltip"/>
|
<image class="tab-reset-button reset-icon" role="button" keyNav="false" data-l10n-id="zen-folders-unload-all-tooltip"/>
|
||||||
@@ -150,7 +150,6 @@ class ZenFolder extends MozTabbrowserTabGroup {
|
|||||||
for (let tab of this.allItems.reverse()) {
|
for (let tab of this.allItems.reverse()) {
|
||||||
tab = tab.group.hasAttribute('split-view-group') ? tab.group : tab;
|
tab = tab.group.hasAttribute('split-view-group') ? tab.group : tab;
|
||||||
if (tab.hasAttribute('zen-empty-tab')) {
|
if (tab.hasAttribute('zen-empty-tab')) {
|
||||||
await ZenPinnedTabsStorage.removePin(tab.getAttribute('zen-pin-id'));
|
|
||||||
gBrowser.removeTab(tab);
|
gBrowser.removeTab(tab);
|
||||||
} else {
|
} else {
|
||||||
gBrowser.ungroupTab(tab);
|
gBrowser.ungroupTab(tab);
|
||||||
@@ -160,7 +159,6 @@ class ZenFolder extends MozTabbrowserTabGroup {
|
|||||||
|
|
||||||
async delete() {
|
async delete() {
|
||||||
for (const tab of this.allItemsRecursive) {
|
for (const tab of this.allItemsRecursive) {
|
||||||
await ZenPinnedTabsStorage.removePin(tab.getAttribute('zen-pin-id'));
|
|
||||||
if (tab.hasAttribute('zen-empty-tab')) {
|
if (tab.hasAttribute('zen-empty-tab')) {
|
||||||
// Manually remove the empty tabs as removeTabs() inside removeTabGroup
|
// Manually remove the empty tabs as removeTabs() inside removeTabGroup
|
||||||
// does ignore them.
|
// does ignore them.
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ function formatRelativeTime(timestamp) {
|
|||||||
|
|
||||||
class nsZenFolders extends nsZenDOMOperatedFeature {
|
class nsZenFolders extends nsZenDOMOperatedFeature {
|
||||||
#ZEN_MAX_SUBFOLDERS = Services.prefs.getIntPref('zen.folders.max-subfolders', 5);
|
#ZEN_MAX_SUBFOLDERS = Services.prefs.getIntPref('zen.folders.max-subfolders', 5);
|
||||||
#ZEN_EDGE_ZONE_THRESHOLD =
|
|
||||||
Services.prefs.getIntPref('zen.view.drag-and-drop.edge-zone-threshold', 25) / 100;
|
|
||||||
|
|
||||||
#popup = null;
|
#popup = null;
|
||||||
#popupTimer = null;
|
#popupTimer = null;
|
||||||
@@ -100,21 +98,8 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
.getElementById('context_zenChangeFolderSpace')
|
.getElementById('context_zenChangeFolderSpace')
|
||||||
.querySelector('menupopup');
|
.querySelector('menupopup');
|
||||||
changeFolderSpace.innerHTML = '';
|
changeFolderSpace.innerHTML = '';
|
||||||
for (const workspace of [...gZenWorkspaces._workspaceCache.workspaces].reverse()) {
|
for (const workspace of [...gZenWorkspaces.getWorkspaces()].reverse()) {
|
||||||
const item = document.createXULElement('menuitem');
|
const item = gZenWorkspaces.generateMenuItemForWorkspace(workspace);
|
||||||
item.className = 'zen-workspace-context-menu-item';
|
|
||||||
item.setAttribute('zen-workspace-id', workspace.uuid);
|
|
||||||
item.setAttribute('disabled', workspace.uuid === gZenWorkspaces.activeWorkspace);
|
|
||||||
let name = workspace.name;
|
|
||||||
const iconIsSvg = workspace.icon && workspace.icon.endsWith('.svg');
|
|
||||||
if (workspace.icon && workspace.icon !== '' && !iconIsSvg) {
|
|
||||||
name = `${workspace.icon} ${name}`;
|
|
||||||
}
|
|
||||||
item.setAttribute('label', name);
|
|
||||||
if (iconIsSvg) {
|
|
||||||
item.setAttribute('image', workspace.icon);
|
|
||||||
item.classList.add('zen-workspace-context-icon');
|
|
||||||
}
|
|
||||||
item.addEventListener('command', (event) => {
|
item.addEventListener('command', (event) => {
|
||||||
if (!this.#lastFolderContextMenu) return;
|
if (!this.#lastFolderContextMenu) return;
|
||||||
this.changeFolderToSpace(
|
this.changeFolderToSpace(
|
||||||
@@ -418,7 +403,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
if (selectedTab) {
|
if (selectedTab) {
|
||||||
selectedTab.setAttribute('zen-workspace-id', newWorkspace.uuid);
|
selectedTab.setAttribute('zen-workspace-id', newWorkspace.uuid);
|
||||||
selectedTab.removeAttribute('folder-active');
|
selectedTab.removeAttribute('folder-active');
|
||||||
gZenWorkspaces._lastSelectedWorkspaceTabs[newWorkspace.uuid] = selectedTab;
|
gZenWorkspaces.lastSelectedWorkspaceTabs[newWorkspace.uuid] = selectedTab;
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@@ -434,10 +419,10 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
tab.style.height = '';
|
tab.style.height = '';
|
||||||
}
|
}
|
||||||
gBrowser.TabStateFlusher.flush(tab.linkedBrowser);
|
gBrowser.TabStateFlusher.flush(tab.linkedBrowser);
|
||||||
if (gZenWorkspaces._lastSelectedWorkspaceTabs[currentWorkspace.uuid] === tab) {
|
if (gZenWorkspaces.lastSelectedWorkspaceTabs[currentWorkspace.uuid] === tab) {
|
||||||
// This tab is no longer the last selected tab in the previous workspace because it's being moved to
|
// This tab is no longer the last selected tab in the previous workspace because it's being moved to
|
||||||
// the current workspace
|
// the current workspace
|
||||||
delete gZenWorkspaces._lastSelectedWorkspaceTabs[currentWorkspace.uuid];
|
delete gZenWorkspaces.lastSelectedWorkspaceTabs[currentWorkspace.uuid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,9 +441,9 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
// we may encounter
|
// we may encounter
|
||||||
tab.group.setAttribute('zen-workspace-id', workspaceId);
|
tab.group.setAttribute('zen-workspace-id', workspaceId);
|
||||||
gBrowser.TabStateFlusher.flush(tab.linkedBrowser);
|
gBrowser.TabStateFlusher.flush(tab.linkedBrowser);
|
||||||
if (gZenWorkspaces._lastSelectedWorkspaceTabs[workspaceId] === tab) {
|
if (gZenWorkspaces.lastSelectedWorkspaceTabs[workspaceId] === tab) {
|
||||||
// This tab is no longer the last selected tab in the previous workspace because it's being moved to a new workspace
|
// This tab is no longer the last selected tab in the previous workspace because it's being moved to a new workspace
|
||||||
delete gZenWorkspaces._lastSelectedWorkspaceTabs[workspaceId];
|
delete gZenWorkspaces.lastSelectedWorkspaceTabs[workspaceId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
folder.dispatchEvent(new CustomEvent('ZenFolderChangedWorkspace', { bubbles: true }));
|
folder.dispatchEvent(new CustomEvent('ZenFolderChangedWorkspace', { bubbles: true }));
|
||||||
@@ -506,9 +491,6 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
tabs = [emptyTab, ...filteredTabs];
|
tabs = [emptyTab, ...filteredTabs];
|
||||||
|
|
||||||
const folder = this._createFolderNode(options);
|
const folder = this._createFolderNode(options);
|
||||||
if (options.initialPinId) {
|
|
||||||
folder.setAttribute('zen-pin-id', options.initialPinId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.insertAfter) {
|
if (options.insertAfter) {
|
||||||
options.insertAfter.after(folder);
|
options.insertAfter.after(folder);
|
||||||
@@ -860,7 +842,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
.open(group.icon, { onlySvgIcons: true })
|
.open(group.icon, { onlySvgIcons: true })
|
||||||
.then((icon) => {
|
.then((icon) => {
|
||||||
this.setFolderUserIcon(group, icon);
|
this.setFolderUserIcon(group, icon);
|
||||||
group.dispatchEvent(new CustomEvent('ZenFolderIconChanged', { bubbles: true }));
|
group.dispatchEvent(new CustomEvent('TabGroupUpdate', { bubbles: true }));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -938,7 +920,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
if (!parentFolder && folder.hasAttribute('split-view-group')) continue;
|
if (!parentFolder && folder.hasAttribute('split-view-group')) continue;
|
||||||
const emptyFolderTabs = folder.tabs
|
const emptyFolderTabs = folder.tabs
|
||||||
.filter((tab) => tab.hasAttribute('zen-empty-tab'))
|
.filter((tab) => tab.hasAttribute('zen-empty-tab'))
|
||||||
.map((tab) => tab.getAttribute('zen-pin-id'));
|
.map((tab) => tab.getAttribute('id'));
|
||||||
|
|
||||||
let prevSiblingInfo = null;
|
let prevSiblingInfo = null;
|
||||||
const prevSibling = folder.previousElementSibling;
|
const prevSibling = folder.previousElementSibling;
|
||||||
@@ -947,9 +929,8 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
if (prevSibling) {
|
if (prevSibling) {
|
||||||
if (gBrowser.isTabGroup(prevSibling)) {
|
if (gBrowser.isTabGroup(prevSibling)) {
|
||||||
prevSiblingInfo = { type: 'group', id: prevSibling.id };
|
prevSiblingInfo = { type: 'group', id: prevSibling.id };
|
||||||
} else if (gBrowser.isTab(prevSibling) && prevSibling.hasAttribute('zen-pin-id')) {
|
} else if (gBrowser.isTab(prevSibling) && prevSibling.hasAttribute('id')) {
|
||||||
const zenPinId = prevSibling.getAttribute('zen-pin-id');
|
prevSiblingInfo = { type: 'tab', id: prevSibling.getAttribute('id') };
|
||||||
prevSiblingInfo = { type: 'tab', id: zenPinId };
|
|
||||||
} else {
|
} else {
|
||||||
prevSiblingInfo = { type: 'start', id: null };
|
prevSiblingInfo = { type: 'start', id: null };
|
||||||
}
|
}
|
||||||
@@ -967,7 +948,6 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
prevSiblingInfo: prevSiblingInfo,
|
prevSiblingInfo: prevSiblingInfo,
|
||||||
emptyTabIds: emptyFolderTabs,
|
emptyTabIds: emptyFolderTabs,
|
||||||
userIcon: userIcon?.getAttribute('href'),
|
userIcon: userIcon?.getAttribute('href'),
|
||||||
pinId: folder.getAttribute('zen-pin-id'),
|
|
||||||
// note: We shouldn't be using the workspace-id anywhere, we are just
|
// note: We shouldn't be using the workspace-id anywhere, we are just
|
||||||
// remembering it for the pinned tabs manager to use it later.
|
// remembering it for the pinned tabs manager to use it later.
|
||||||
workspaceId: folder.getAttribute('zen-workspace-id'),
|
workspaceId: folder.getAttribute('zen-workspace-id'),
|
||||||
@@ -994,10 +974,8 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
tabFolderWorkingData.set(folderData.id, workingData);
|
tabFolderWorkingData.set(folderData.id, workingData);
|
||||||
|
|
||||||
const oldGroup = document.getElementById(folderData.id);
|
const oldGroup = document.getElementById(folderData.id);
|
||||||
folderData.emptyTabIds.forEach((zenPinId) => {
|
folderData.emptyTabIds.forEach((id) => {
|
||||||
oldGroup
|
oldGroup?.querySelector(`tab[id="${id}"]`)?.setAttribute('zen-empty-tab', true);
|
||||||
?.querySelector(`tab[zen-pin-id="${zenPinId}"]`)
|
|
||||||
?.setAttribute('zen-empty-tab', true);
|
|
||||||
});
|
});
|
||||||
if (oldGroup) {
|
if (oldGroup) {
|
||||||
if (!folderData.splitViewGroup) {
|
if (!folderData.splitViewGroup) {
|
||||||
@@ -1009,7 +987,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
saveOnWindowClose: folderData.saveOnWindowClose,
|
saveOnWindowClose: folderData.saveOnWindowClose,
|
||||||
workspaceId: folderData.workspaceId,
|
workspaceId: folderData.workspaceId,
|
||||||
});
|
});
|
||||||
folder.setAttribute('zen-pin-id', folderData.pinId);
|
folder.setAttribute('id', folderData.id);
|
||||||
workingData.node = folder;
|
workingData.node = folder;
|
||||||
oldGroup.before(folder);
|
oldGroup.before(folder);
|
||||||
} else {
|
} else {
|
||||||
@@ -1041,9 +1019,7 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
if (parentWorkingData && parentWorkingData.node) {
|
if (parentWorkingData && parentWorkingData.node) {
|
||||||
switch (stateData?.prevSiblingInfo?.type) {
|
switch (stateData?.prevSiblingInfo?.type) {
|
||||||
case 'tab': {
|
case 'tab': {
|
||||||
const tab = parentWorkingData.node.querySelector(
|
const tab = document.getElementById(stateData.prevSiblingInfo.id);
|
||||||
`[zen-pin-id="${stateData.prevSiblingInfo.id}"]`
|
|
||||||
);
|
|
||||||
tab.after(node);
|
tab.after(node);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1087,18 +1063,16 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
* @param {Array<MozTabbrowserTab>|null} movingTabs The tabs being moved.
|
* @param {Array<MozTabbrowserTab>|null} movingTabs The tabs being moved.
|
||||||
*/
|
*/
|
||||||
highlightGroupOnDragOver(folder, movingTabs) {
|
highlightGroupOnDragOver(folder, movingTabs) {
|
||||||
if (folder === this.#lastHighlightedGroup) return;
|
if (folder === this.#lastHighlightedGroup) return true;
|
||||||
const tab = movingTabs ? movingTabs[0] : null;
|
const tab = movingTabs ? movingTabs[0] : null;
|
||||||
if (this.#lastHighlightedGroup && this.#lastHighlightedGroup !== folder) {
|
if (this.#lastHighlightedGroup && this.#lastHighlightedGroup !== folder) {
|
||||||
this.#lastHighlightedGroup.removeAttribute('selected');
|
|
||||||
if (this.#lastHighlightedGroup.collapsed) {
|
if (this.#lastHighlightedGroup.collapsed) {
|
||||||
this.updateFolderIcon(this.#lastHighlightedGroup, 'close');
|
this.updateFolderIcon(this.#lastHighlightedGroup, 'close');
|
||||||
}
|
}
|
||||||
this.#lastHighlightedGroup = null;
|
this.#lastHighlightedGroup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
folder &&
|
folder?.isZenFolder &&
|
||||||
(!folder.hasAttribute('split-view-group') || !folder.hasAttribute('selected')) &&
|
(!folder.hasAttribute('split-view-group') || !folder.hasAttribute('selected')) &&
|
||||||
folder !== tab?.group &&
|
folder !== tab?.group &&
|
||||||
!(
|
!(
|
||||||
@@ -1106,13 +1080,13 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
movingTabs?.some((t) => gBrowser.isTabGroupLabel(t))
|
movingTabs?.some((t) => gBrowser.isTabGroupLabel(t))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
folder.setAttribute('selected', 'true');
|
|
||||||
folder.style.transform = '';
|
|
||||||
if (folder.collapsed) {
|
if (folder.collapsed) {
|
||||||
this.updateFolderIcon(folder, 'open');
|
this.updateFolderIcon(folder, 'open');
|
||||||
}
|
}
|
||||||
this.#lastHighlightedGroup = folder;
|
this.#lastHighlightedGroup = folder;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1125,54 +1099,6 @@ class nsZenFolders extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the dragover logic when dragging a tab or tab group label over another tab group label.
|
|
||||||
* This function determines where the dragged item should be visually dropped (before/after the group, or inside it)
|
|
||||||
* and updates related styling and highlighting.
|
|
||||||
*
|
|
||||||
* @param {MozTabbrowserTabGroupLabel} currentDropElement The tab group label currently being dragged over.
|
|
||||||
* @param {MozTabbrowserTab|MozTabbrowserTabGroupLabel} draggedTab The tab or tab group label being dragged.
|
|
||||||
* @param {number} overlapPercent The percentage of overlap between the dragged item and the drop target.
|
|
||||||
* @param {Array<MozTabbrowserTab>} movingTabs An array of tabs that are currently being dragged together.
|
|
||||||
* @param {boolean} currentDropBefore Indicates if the current drop position is before the middle of the drop element.
|
|
||||||
* @param {string|undefined} currentColorCode The current color code for dragover highlighting.
|
|
||||||
* @returns {{dropElement: MozTabbrowserTabGroup|MozTabbrowserTab|MozTabbrowserTabGroupLabel, colorCode: string|undefined, dropBefore: boolean}}
|
|
||||||
* An object containing the updated drop element, color code for highlighting, and drop position.
|
|
||||||
*/
|
|
||||||
handleDragOverTabGroupLabel(
|
|
||||||
currentDropElement,
|
|
||||||
draggedTab,
|
|
||||||
overlapPercent,
|
|
||||||
movingTabs,
|
|
||||||
currentDropBefore,
|
|
||||||
currentColorCode
|
|
||||||
) {
|
|
||||||
let dropElement = currentDropElement;
|
|
||||||
let dropBefore = currentDropBefore;
|
|
||||||
let colorCode = currentColorCode;
|
|
||||||
|
|
||||||
const dropElementGroup = dropElement?.isZenFolder ? dropElement : dropElement?.group;
|
|
||||||
const isSplitGroup = dropElement?.group?.hasAttribute('split-view-group');
|
|
||||||
let firstGroupElem = dropElementGroup.querySelector('.zen-tab-group-start').nextElementSibling;
|
|
||||||
if (gBrowser.isTabGroup(firstGroupElem)) firstGroupElem = firstGroupElem.labelElement;
|
|
||||||
|
|
||||||
const isInMiddleZone =
|
|
||||||
overlapPercent >= this.#ZEN_EDGE_ZONE_THRESHOLD &&
|
|
||||||
overlapPercent <= 1 - this.#ZEN_EDGE_ZONE_THRESHOLD;
|
|
||||||
const shouldDropInside = isInMiddleZone && !isSplitGroup;
|
|
||||||
|
|
||||||
if (shouldDropInside) {
|
|
||||||
dropElement = firstGroupElem;
|
|
||||||
dropBefore = true;
|
|
||||||
this.highlightGroupOnDragOver(dropElementGroup, movingTabs);
|
|
||||||
} else {
|
|
||||||
colorCode = undefined;
|
|
||||||
this.highlightGroupOnDragOver(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { dropElement, colorCode, dropBefore };
|
|
||||||
}
|
|
||||||
|
|
||||||
#normalizeGroupItems(items) {
|
#normalizeGroupItems(items) {
|
||||||
return items
|
return items
|
||||||
.filter((item) => !item.hasAttribute('zen-empty-tab'))
|
.filter((item) => !item.hasAttribute('zen-empty-tab'))
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ DIRS += [
|
|||||||
"tests",
|
"tests",
|
||||||
"urlbar",
|
"urlbar",
|
||||||
"toolkit",
|
"toolkit",
|
||||||
|
"sessionstore",
|
||||||
]
|
]
|
||||||
|
|||||||
10
src/zen/sessionstore/SessionComponents.manifest
Normal file
10
src/zen/sessionstore/SessionComponents.manifest
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# Browser global components initializing before UI startup
|
||||||
|
category browser-before-ui-startup resource:///modules/zen/ZenSessionManager.sys.mjs ZenSessionStore.init
|
||||||
|
category browser-before-ui-startup resource:///modules/zen/ZenWindowSync.sys.mjs ZenWindowSync.init
|
||||||
|
|
||||||
|
# App shutdown consumers
|
||||||
|
category browser-quit-application-granted resource:///modules/zen/ZenWindowSync.sys.mjs ZenWindowSync.uninit
|
||||||
367
src/zen/sessionstore/ZenSessionManager.sys.mjs
Normal file
367
src/zen/sessionstore/ZenSessionManager.sys.mjs
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import { JSONFile } from 'resource://gre/modules/JSONFile.sys.mjs';
|
||||||
|
import { XPCOMUtils } from 'resource://gre/modules/XPCOMUtils.sys.mjs';
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
|
||||||
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
PrivateBrowsingUtils: 'resource://gre/modules/PrivateBrowsingUtils.sys.mjs',
|
||||||
|
BrowserWindowTracker: 'resource:///modules/BrowserWindowTracker.sys.mjs',
|
||||||
|
TabGroupState: 'resource:///modules/sessionstore/TabGroupState.sys.mjs',
|
||||||
|
SessionStore: 'resource:///modules/sessionstore/SessionStore.sys.mjs',
|
||||||
|
SessionSaver: 'resource:///modules/sessionstore/SessionSaver.sys.mjs',
|
||||||
|
setTimeout: 'resource://gre/modules/Timer.sys.mjs',
|
||||||
|
});
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'gShouldLog', 'zen.session-store.log', true);
|
||||||
|
|
||||||
|
// Note that changing this hidden pref will make the previous session file
|
||||||
|
// unused, causing a new session file to be created on next write.
|
||||||
|
const SHOULD_COMPRESS_FILE = Services.prefs.getBoolPref('zen.session-store.compress-file', true);
|
||||||
|
const SHOULD_BACKUP_FILE = Services.prefs.getBoolPref('zen.session-store.backup-file', true);
|
||||||
|
|
||||||
|
const FILE_NAME = SHOULD_COMPRESS_FILE ? 'zen-sessions.jsonlz4' : 'zen-sessions.json';
|
||||||
|
const MIGRATION_PREF = 'zen.ui.migration.session-manager-restore';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing the sidebar object stored in the session file.
|
||||||
|
* This object holds all the data related to tabs, groups, folders
|
||||||
|
* and split view state.
|
||||||
|
*/
|
||||||
|
class nsZenSidebarObject {
|
||||||
|
#sidebar = {};
|
||||||
|
|
||||||
|
get data() {
|
||||||
|
return Cu.cloneInto(this.#sidebar, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
set data(data) {
|
||||||
|
this.#sidebar = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class nsZenSessionManager {
|
||||||
|
/**
|
||||||
|
* The JSON file instance used to read/write session data.
|
||||||
|
* @type {JSONFile}
|
||||||
|
*/
|
||||||
|
#file = null;
|
||||||
|
/**
|
||||||
|
* The sidebar object holding tabs, groups, folders and split view data.
|
||||||
|
* @type {nsZenSidebarObject}
|
||||||
|
*/
|
||||||
|
#sidebarObject = new nsZenSidebarObject();
|
||||||
|
|
||||||
|
// Called from SessionComponents.manifest on app-startup
|
||||||
|
init() {
|
||||||
|
let profileDir = Services.dirsvc.get('ProfD', Ci.nsIFile).path;
|
||||||
|
let backupFile = null;
|
||||||
|
if (SHOULD_BACKUP_FILE) {
|
||||||
|
backupFile = PathUtils.join(profileDir, 'zen-sessions-backup', FILE_NAME);
|
||||||
|
}
|
||||||
|
let filePath = PathUtils.join(profileDir, FILE_NAME);
|
||||||
|
this.#file = new JSONFile({
|
||||||
|
path: filePath,
|
||||||
|
compression: SHOULD_COMPRESS_FILE ? 'lz4' : undefined,
|
||||||
|
backupFile,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
log(...args) {
|
||||||
|
if (lazy.gShouldLog) {
|
||||||
|
console.info('ZenSessionManager:', ...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the spaces data from the Places database for migration.
|
||||||
|
* This is only called once during the first run after updating
|
||||||
|
* to a version that uses the new session manager.
|
||||||
|
*/
|
||||||
|
async #getSpacesFromDBForMigration() {
|
||||||
|
try {
|
||||||
|
const { PlacesUtils } = ChromeUtils.importESModule(
|
||||||
|
'resource://gre/modules/PlacesUtils.sys.mjs'
|
||||||
|
);
|
||||||
|
const db = await PlacesUtils.promiseDBConnection();
|
||||||
|
const rows = await db.executeCached('SELECT * FROM zen_workspaces ORDER BY created_at ASC');
|
||||||
|
this._migrationSpaceData = rows.map((row) => ({
|
||||||
|
uuid: row.getResultByName('uuid'),
|
||||||
|
name: row.getResultByName('name'),
|
||||||
|
icon: row.getResultByName('icon'),
|
||||||
|
containerTabId: row.getResultByName('container_id') ?? 0,
|
||||||
|
position: row.getResultByName('position'),
|
||||||
|
theme: row.getResultByName('theme_type')
|
||||||
|
? {
|
||||||
|
type: row.getResultByName('theme_type'),
|
||||||
|
gradientColors: JSON.parse(row.getResultByName('theme_colors')),
|
||||||
|
opacity: row.getResultByName('theme_opacity'),
|
||||||
|
rotation: row.getResultByName('theme_rotation'),
|
||||||
|
texture: row.getResultByName('theme_texture'),
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
}));
|
||||||
|
} catch {
|
||||||
|
/* ignore errors during migration */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the session file and populates the sidebar object.
|
||||||
|
* This should be only called once at startup.
|
||||||
|
* @see SessionFileInternal.read
|
||||||
|
*/
|
||||||
|
async readFile() {
|
||||||
|
try {
|
||||||
|
let promises = [];
|
||||||
|
promises.push(this.#file.load());
|
||||||
|
if (!Services.prefs.getBoolPref(MIGRATION_PREF, false)) {
|
||||||
|
promises.push(this.#getSpacesFromDBForMigration());
|
||||||
|
}
|
||||||
|
await Promise.all(promises);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('ZenSessionManager: Failed to read session file', e);
|
||||||
|
}
|
||||||
|
this.#sidebar = this.#file.data || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the session file is read. Restores the sidebar data
|
||||||
|
* into all windows.
|
||||||
|
*
|
||||||
|
* @param initialState
|
||||||
|
* The initial session state read from the session file.
|
||||||
|
*/
|
||||||
|
onFileRead(initialState) {
|
||||||
|
// For the first time after migration, we restore the tabs
|
||||||
|
// That where going to be restored by SessionStore. The sidebar
|
||||||
|
// object will always be empty after migration because we haven't
|
||||||
|
// gotten the opportunity to save the session yet.
|
||||||
|
if (!Services.prefs.getBoolPref(MIGRATION_PREF, false)) {
|
||||||
|
Services.prefs.setBoolPref(MIGRATION_PREF, true);
|
||||||
|
for (const winData of initialState.windows || []) {
|
||||||
|
winData.spaces = this._migrationSpaceData || [];
|
||||||
|
}
|
||||||
|
delete this._migrationSpaceData;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If there's no initial state, nothing to restore. This would
|
||||||
|
// happen if the file is empty or corrupted.
|
||||||
|
if (!initialState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If there are no windows, we create an empty one. By default,
|
||||||
|
// firefox would create simply a new empty window, but we want
|
||||||
|
// to make sure that the sidebar object is properly initialized.
|
||||||
|
// This would happen on first run after having a single private window
|
||||||
|
// open when quitting the app, for example.
|
||||||
|
if (!initialState.windows?.length) {
|
||||||
|
initialState.windows = [{}];
|
||||||
|
}
|
||||||
|
// Restore all windows with the same sidebar object, this will
|
||||||
|
// guarantee that all tabs, groups, folders and split view data
|
||||||
|
// are properly synced across all windows.
|
||||||
|
this.log(`Restoring Zen session data into ${initialState.windows?.length || 0} windows`);
|
||||||
|
for (const winData of initialState.windows || []) {
|
||||||
|
this.#restoreWindowData(winData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get #sidebar() {
|
||||||
|
return this.#sidebarObject.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
set #sidebar(data) {
|
||||||
|
this.#sidebarObject.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the current session state. Collects data and writes to disk.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* The current session state.
|
||||||
|
*/
|
||||||
|
saveState(state) {
|
||||||
|
if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing || !state?.windows?.length) {
|
||||||
|
// Don't save (or even collect) anything in permanent private
|
||||||
|
// browsing mode. We also don't want to save if there are no windows.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.#collectWindowData(state);
|
||||||
|
// This would save the data to disk asynchronously or when
|
||||||
|
// quitting the app.
|
||||||
|
this.#file.data = this.#sidebar;
|
||||||
|
this.#file.saveSoon();
|
||||||
|
this.log(`Saving Zen session data with ${this.#sidebar.tabs?.length || 0} tabs`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the session data for a closed window if it meets the criteria.
|
||||||
|
* See SessionStoreInternal.maybeSaveClosedWindow for more details.
|
||||||
|
*
|
||||||
|
* @param aWinData - The window data object to save.
|
||||||
|
* @param isLastWindow - Whether this is the last saveable window.
|
||||||
|
*/
|
||||||
|
maybeSaveClosedWindow(aWinData, isLastWindow) {
|
||||||
|
// We only want to save the *last* normal window that is closed.
|
||||||
|
// If its not the last window, we can still update the sidebar object
|
||||||
|
// based on other open windows.
|
||||||
|
if (aWinData.isPopup || aWinData.isTaskbarTab || aWinData.isZenUnsynced || !isLastWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.log('Saving closed window session data into Zen session store');
|
||||||
|
this.saveState({ windows: [aWinData] });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects session data for a given window.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* The current session state.
|
||||||
|
*/
|
||||||
|
#collectWindowData(state) {
|
||||||
|
let sidebarData = this.#sidebar;
|
||||||
|
if (!sidebarData) {
|
||||||
|
sidebarData = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
sidebarData.lastCollected = Date.now();
|
||||||
|
this.#collectTabsData(sidebarData, state);
|
||||||
|
this.#sidebar = sidebarData;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filterUnusedTabs(tabs) {
|
||||||
|
return tabs.filter((tab) => {
|
||||||
|
// We need to ignore empty tabs with no group association
|
||||||
|
// as they are not useful to restore.
|
||||||
|
return !(tab.zenIsEmpty && !tab.groupId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects session data for all tabs in a given window.
|
||||||
|
*
|
||||||
|
* @param sidebarData
|
||||||
|
* The sidebar data object to populate.
|
||||||
|
* @param state
|
||||||
|
* The current session state.
|
||||||
|
*/
|
||||||
|
#collectTabsData(sidebarData, state) {
|
||||||
|
const tabIdRelationMap = new Map();
|
||||||
|
for (const window of state.windows) {
|
||||||
|
// Only accept the tabs with `_zenIsActiveTab` set to true from
|
||||||
|
// every window. We do this to avoid collecting tabs with invalid
|
||||||
|
// state when multiple windows are open. Note that if we a tab without
|
||||||
|
// this flag set in any other window, we just add it anyway.
|
||||||
|
for (const tabData of window.tabs) {
|
||||||
|
if (!tabIdRelationMap.has(tabData.zenSyncId) || tabData._zenIsActiveTab) {
|
||||||
|
tabIdRelationMap.set(tabData.zenSyncId, tabData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sidebarData.tabs = this.#filterUnusedTabs(Array.from(tabIdRelationMap.values()));
|
||||||
|
|
||||||
|
sidebarData.folders = state.windows[0].folders;
|
||||||
|
sidebarData.splitViewData = state.windows[0].splitViewData;
|
||||||
|
sidebarData.groups = state.windows[0].groups;
|
||||||
|
sidebarData.spaces = state.windows[0].spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores the sidebar data into a given window data object.
|
||||||
|
* We do this in order to make sure all new window objects
|
||||||
|
* have the same sidebar data.
|
||||||
|
*
|
||||||
|
* @param aWindowData
|
||||||
|
* The window data object to restore into.
|
||||||
|
*/
|
||||||
|
#restoreWindowData(aWindowData) {
|
||||||
|
const sidebar = this.#sidebar;
|
||||||
|
if (!sidebar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aWindowData.tabs = sidebar.tabs || [];
|
||||||
|
aWindowData.splitViewData = sidebar.splitViewData;
|
||||||
|
aWindowData.folders = sidebar.folders;
|
||||||
|
aWindowData.groups = sidebar.groups;
|
||||||
|
aWindowData.spaces = sidebar.spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores a new window with Zen session data. This should be called
|
||||||
|
* not at startup, but when a new window is opened by the user.
|
||||||
|
*
|
||||||
|
* @param aWindow
|
||||||
|
* The window to restore.
|
||||||
|
* @param SessionStoreInternal
|
||||||
|
* The SessionStore module instance.
|
||||||
|
* @param resolvePromise
|
||||||
|
* The promise resolver to call when done. We use a promise
|
||||||
|
* here because out workspace manager always waits for SessionStore
|
||||||
|
* to restore all the windows before initializing, but when opening
|
||||||
|
* a new window, that promise is always resolved, meaning it may run
|
||||||
|
* into a race condition if we try to restore the window synchronously
|
||||||
|
* here.
|
||||||
|
*/
|
||||||
|
restoreNewWindow(aWindow, SessionStoreInternal) {
|
||||||
|
if (aWindow.gZenWorkspaces?.privateWindowOrDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.log('Restoring new window with Zen session data');
|
||||||
|
const state = lazy.SessionStore.getCurrentState(true);
|
||||||
|
const windows = (state.windows || []).filter(
|
||||||
|
(win) => !win.isPrivate && !win.isPopup && !win.isTaskbarTab && !win.isZenUnsynced
|
||||||
|
);
|
||||||
|
let windowToClone = windows[0] || {};
|
||||||
|
let newWindow = Cu.cloneInto(windowToClone, {});
|
||||||
|
if (windows.length < 2) {
|
||||||
|
// We only want to restore the sidebar object if we found
|
||||||
|
// only one normal window to clone from (which is the one
|
||||||
|
// we are opening).
|
||||||
|
this.log('Restoring sidebar data into new window');
|
||||||
|
this.#restoreWindowData(newWindow);
|
||||||
|
}
|
||||||
|
newWindow.tabs = this.#filterUnusedTabs(newWindow.tabs || []);
|
||||||
|
|
||||||
|
// These are window-specific from the previous window state that
|
||||||
|
// we don't want to restore into the new window. Otherwise, new
|
||||||
|
// windows would appear overlapping the previous one, or with
|
||||||
|
// the same size and position, which should be decided by the
|
||||||
|
// window manager.
|
||||||
|
delete newWindow.selected;
|
||||||
|
delete newWindow.screenX;
|
||||||
|
delete newWindow.screenY;
|
||||||
|
delete newWindow.width;
|
||||||
|
delete newWindow.height;
|
||||||
|
delete newWindow.sizemode;
|
||||||
|
delete newWindow.sizemodeBeforeMinimized;
|
||||||
|
delete newWindow.zIndex;
|
||||||
|
|
||||||
|
const newState = { windows: [newWindow] };
|
||||||
|
this.log(`Cloning window with ${newWindow.tabs.length} tabs`);
|
||||||
|
|
||||||
|
SessionStoreInternal._deferredInitialState = newState;
|
||||||
|
SessionStoreInternal.initializeWindow(aWindow, newState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cloned spaces data from the sidebar object.
|
||||||
|
* This is used during migration to restore spaces into
|
||||||
|
* the initial session state.
|
||||||
|
*
|
||||||
|
* @returns {Array} The cloned spaces data.
|
||||||
|
*/
|
||||||
|
getClonedSpaces() {
|
||||||
|
const sidebar = this.#sidebar;
|
||||||
|
if (!sidebar || !sidebar.spaces) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return Cu.cloneInto(sidebar.spaces, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZenSessionStore = new nsZenSessionManager();
|
||||||
1030
src/zen/sessionstore/ZenWindowSync.sys.mjs
Normal file
1030
src/zen/sessionstore/ZenWindowSync.sys.mjs
Normal file
File diff suppressed because it is too large
Load Diff
8
src/zen/sessionstore/moz.build
Normal file
8
src/zen/sessionstore/moz.build
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
EXTRA_JS_MODULES.zen += [
|
||||||
|
"ZenSessionManager.sys.mjs",
|
||||||
|
"ZenWindowSync.sys.mjs",
|
||||||
|
]
|
||||||
@@ -202,6 +202,7 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
this.resetTabState(tab, forUnsplit);
|
this.resetTabState(tab, forUnsplit);
|
||||||
if (tab.group && tab.group.hasAttribute('split-view-group')) {
|
if (tab.group && tab.group.hasAttribute('split-view-group')) {
|
||||||
gBrowser.ungroupTab(tab);
|
gBrowser.ungroupTab(tab);
|
||||||
|
this.#dispatchItemEvent('ZenTabRemovedFromSplit', tab);
|
||||||
}
|
}
|
||||||
if (group.tabs.length < 2) {
|
if (group.tabs.length < 2) {
|
||||||
// We need to remove all remaining tabs from the group when unsplitting
|
// We need to remove all remaining tabs from the group when unsplitting
|
||||||
@@ -895,6 +896,21 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches a custom event on a tab.
|
||||||
|
*
|
||||||
|
* @param {string} eventName - The name of the event to dispatch.
|
||||||
|
* @param {HTMLElement} item - The item on which to dispatch the event.
|
||||||
|
*/
|
||||||
|
#dispatchItemEvent(eventName, item) {
|
||||||
|
const event = new CustomEvent(eventName, {
|
||||||
|
detail: { item },
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: false,
|
||||||
|
});
|
||||||
|
item.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a group.
|
* Removes a group.
|
||||||
*
|
*
|
||||||
@@ -905,6 +921,7 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
for (const tab of group.tabs.reverse()) {
|
for (const tab of group.tabs.reverse()) {
|
||||||
if (tab.group?.hasAttribute('split-view-group')) {
|
if (tab.group?.hasAttribute('split-view-group')) {
|
||||||
gBrowser.ungroupTab(tab);
|
gBrowser.ungroupTab(tab);
|
||||||
|
this.#dispatchItemEvent('ZenTabRemovedFromSplit', tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.currentView === groupIndex) {
|
if (this.currentView === groupIndex) {
|
||||||
@@ -1067,9 +1084,13 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
*
|
*
|
||||||
* @param {Tab[]} tabs - The tabs to split.
|
* @param {Tab[]} tabs - The tabs to split.
|
||||||
* @param {string|undefined} gridType - The type of grid layout.
|
* @param {string|undefined} gridType - The type of grid layout.
|
||||||
|
* @param {number} initialIndex - The index of the initially active tab.
|
||||||
|
* use -1 to avoid selecting any tab.
|
||||||
|
* @return {object|undefined} The split view data or undefined if the split was not performed.
|
||||||
*/
|
*/
|
||||||
splitTabs(tabs, gridType, initialIndex = 0) {
|
splitTabs(tabs, gridType, initialIndex = 0) {
|
||||||
this.#withoutSplitViewTransition(() => {
|
const tabIndexToUse = Math.max(0, initialIndex);
|
||||||
|
return this.#withoutSplitViewTransition(() => {
|
||||||
// TODO: Add support for splitting essential tabs
|
// TODO: Add support for splitting essential tabs
|
||||||
tabs = tabs.filter((t) => !t.hidden && !t.hasAttribute('zen-empty-tab'));
|
tabs = tabs.filter((t) => !t.hidden && !t.hasAttribute('zen-empty-tab'));
|
||||||
if (tabs.length < 2 || tabs.length > this.MAX_TABS) {
|
if (tabs.length < 2 || tabs.length > this.MAX_TABS) {
|
||||||
@@ -1078,7 +1099,7 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
|
|
||||||
const existingSplitTab = tabs.find((tab) => tab.splitView);
|
const existingSplitTab = tabs.find((tab) => tab.splitView);
|
||||||
if (existingSplitTab) {
|
if (existingSplitTab) {
|
||||||
this._moveTabsToContainer(tabs, tabs[initialIndex]);
|
this._moveTabsToContainer(tabs, tabs[tabIndexToUse]);
|
||||||
const groupIndex = this._data.findIndex((group) => group.tabs.includes(existingSplitTab));
|
const groupIndex = this._data.findIndex((group) => group.tabs.includes(existingSplitTab));
|
||||||
const group = this._data[groupIndex];
|
const group = this._data[groupIndex];
|
||||||
const gridTypeChange = gridType && group.gridType !== gridType;
|
const gridTypeChange = gridType && group.gridType !== gridType;
|
||||||
@@ -1105,7 +1126,8 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.activateSplitView(group, true);
|
this.activateSplitView(group, true);
|
||||||
return;
|
this.#dispatchItemEvent('ZenSplitViewTabsSplit', group);
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are here if none of the tabs have been previously split
|
// We are here if none of the tabs have been previously split
|
||||||
@@ -1132,8 +1154,8 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
layoutTree: this.calculateLayoutTree(tabs, gridType),
|
layoutTree: this.calculateLayoutTree(tabs, gridType),
|
||||||
};
|
};
|
||||||
this._data.push(splitData);
|
this._data.push(splitData);
|
||||||
if (!this._sessionRestoring) {
|
if (!this._sessionRestoring && initialIndex >= 0) {
|
||||||
window.gBrowser.selectedTab = tabs[initialIndex] ?? tabs[0];
|
window.gBrowser.selectedTab = tabs[tabIndexToUse] ?? tabs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add tabs to the split view group
|
// Add tabs to the split view group
|
||||||
@@ -1150,6 +1172,8 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.activateSplitView(splitData);
|
this.activateSplitView(splitData);
|
||||||
|
this.#dispatchItemEvent('ZenSplitViewTabsSplit', splitGroup);
|
||||||
|
return splitData;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1855,9 +1879,10 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can't create an empty group, so only create if we have tabs
|
// We can't create an empty group, so only create if we have tabs
|
||||||
|
let group = null;
|
||||||
if (tabs?.length) {
|
if (tabs?.length) {
|
||||||
// Create a new group with the initial tabs
|
// Create a new group with the initial tabs
|
||||||
gBrowser.addTabGroup(tabs, {
|
group = gBrowser.addTabGroup(tabs, {
|
||||||
label: '',
|
label: '',
|
||||||
showCreateUI: false,
|
showCreateUI: false,
|
||||||
insertBefore: tabs[0],
|
insertBefore: tabs[0],
|
||||||
@@ -1865,7 +1890,7 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
storeDataForSessionStore() {
|
storeDataForSessionStore() {
|
||||||
@@ -1936,7 +1961,7 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
|||||||
#withoutSplitViewTransition(callback) {
|
#withoutSplitViewTransition(callback) {
|
||||||
this.tabBrowserPanel.classList.add('zen-split-view-no-transition');
|
this.tabBrowserPanel.classList.add('zen-split-view-no-transition');
|
||||||
try {
|
try {
|
||||||
callback();
|
return callback();
|
||||||
} finally {
|
} finally {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.tabBrowserPanel.classList.remove('zen-split-view-no-transition');
|
this.tabBrowserPanel.classList.remove('zen-split-view-no-transition');
|
||||||
|
|||||||
@@ -7,23 +7,7 @@ import { nsZenDOMOperatedFeature } from 'chrome://browser/content/zen-components
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
class ZenPinnedTabsObserver {
|
class ZenPinnedTabsObserver {
|
||||||
static ALL_EVENTS = [
|
static ALL_EVENTS = ['TabPinned', 'TabUnpinned'];
|
||||||
'TabPinned',
|
|
||||||
'TabUnpinned',
|
|
||||||
'TabMove',
|
|
||||||
'TabGroupCreate',
|
|
||||||
'TabGroupRemoved',
|
|
||||||
'TabGroupMoved',
|
|
||||||
'ZenFolderRenamed',
|
|
||||||
'ZenFolderIconChanged',
|
|
||||||
'TabGroupCollapse',
|
|
||||||
'TabGroupExpand',
|
|
||||||
'TabGrouped',
|
|
||||||
'TabUngrouped',
|
|
||||||
'ZenFolderChangedWorkspace',
|
|
||||||
'TabAddedToEssentials',
|
|
||||||
'TabRemovedFromEssentials',
|
|
||||||
];
|
|
||||||
|
|
||||||
#listeners = [];
|
#listeners = [];
|
||||||
|
|
||||||
@@ -76,12 +60,11 @@ class ZenPinnedTabsObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
||||||
hasInitializedPins = false;
|
|
||||||
promiseInitializedPinned = new Promise((resolve) => {
|
promiseInitializedPinned = new Promise((resolve) => {
|
||||||
this._resolvePinnedInitializedInternal = resolve;
|
this._resolvePinnedInitializedInternal = resolve;
|
||||||
});
|
});
|
||||||
|
|
||||||
async init() {
|
init() {
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -103,43 +86,16 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onTabIconChanged(tab, url = null) {
|
onTabIconChanged(tab, url = null) {
|
||||||
|
tab.dispatchEvent(new CustomEvent('ZenTabIconChanged', { bubbles: true, detail: { tab } }));
|
||||||
const iconUrl = url ?? tab.iconImage.src;
|
const iconUrl = url ?? tab.iconImage.src;
|
||||||
if (!iconUrl && tab.hasAttribute('zen-pin-id')) {
|
if (tab.hasAttribute('zen-essential')) {
|
||||||
try {
|
tab.style.setProperty('--zen-essential-tab-icon', `url(${iconUrl})`);
|
||||||
setTimeout(async () => {
|
|
||||||
const favicon = await this.getFaviconAsBase64(tab.linkedBrowser.currentURI);
|
|
||||||
if (favicon) {
|
|
||||||
gBrowser.setIcon(tab, favicon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
// Handle error
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tab.hasAttribute('zen-essential')) {
|
|
||||||
tab.style.setProperty('--zen-essential-tab-icon', `url(${iconUrl})`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onTabResetPinButton(event, tab) {
|
_onTabResetPinButton(event, tab) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const pin = this._pinsCache?.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
this._resetTabToStoredState(tab);
|
||||||
if (!pin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let userContextId;
|
|
||||||
if (tab.hasAttribute('usercontextid')) {
|
|
||||||
userContextId = tab.getAttribute('usercontextid');
|
|
||||||
}
|
|
||||||
const pinnedUrl = Services.io.newURI(pin.url);
|
|
||||||
const browser = tab.linkedBrowser;
|
|
||||||
browser.loadURI(pinnedUrl, {
|
|
||||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
|
|
||||||
userContextId,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
this.resetPinChangedUrl(tab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get enabled() {
|
get enabled() {
|
||||||
@@ -150,260 +106,6 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
return lazy.zenTabsEssentialsMax;
|
return lazy.zenTabsEssentialsMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshPinnedTabs({ init = false } = {}) {
|
|
||||||
if (!this.enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await ZenPinnedTabsStorage.promiseInitialized;
|
|
||||||
await this.#initializePinsCache();
|
|
||||||
setTimeout(async () => {
|
|
||||||
// Execute in a separate task to avoid blocking the main thread
|
|
||||||
await SessionStore.promiseAllWindowsRestored;
|
|
||||||
await gZenWorkspaces.promiseInitialized;
|
|
||||||
await this.#initializePinnedTabs(init);
|
|
||||||
if (init) {
|
|
||||||
this._hasFinishedLoading = true;
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
async #initializePinsCache() {
|
|
||||||
try {
|
|
||||||
// Get pin data
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
|
|
||||||
// Enhance pins with favicons
|
|
||||||
this._pinsCache = await Promise.all(
|
|
||||||
pins.map(async (pin) => {
|
|
||||||
try {
|
|
||||||
if (pin.isGroup) {
|
|
||||||
return pin; // Skip groups for now
|
|
||||||
}
|
|
||||||
const image = await this.getFaviconAsBase64(Services.io.newURI(pin.url));
|
|
||||||
return {
|
|
||||||
...pin,
|
|
||||||
iconUrl: image || null,
|
|
||||||
};
|
|
||||||
} catch {
|
|
||||||
// If favicon fetch fails, continue without icon
|
|
||||||
return {
|
|
||||||
...pin,
|
|
||||||
iconUrl: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
} catch (ex) {
|
|
||||||
console.error('Failed to initialize pins cache:', ex);
|
|
||||||
this._pinsCache = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log(`Initialized pins cache with ${this._pinsCache.length} pins`);
|
|
||||||
return this._pinsCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
#finishedInitializingPins() {
|
|
||||||
if (this.hasInitializedPins) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._resolvePinnedInitializedInternal();
|
|
||||||
delete this._resolvePinnedInitializedInternal;
|
|
||||||
this.hasInitializedPins = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async #initializePinnedTabs(init = false) {
|
|
||||||
const pins = this._pinsCache;
|
|
||||||
if (!pins?.length || !init) {
|
|
||||||
this.#finishedInitializingPins();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const pinnedTabsByUUID = new Map();
|
|
||||||
const pinsToCreate = new Set(pins.map((p) => p.uuid));
|
|
||||||
|
|
||||||
// First pass: identify existing tabs and remove those without pins
|
|
||||||
for (let tab of gZenWorkspaces.allStoredTabs) {
|
|
||||||
const pinId = tab.getAttribute('zen-pin-id');
|
|
||||||
if (!pinId) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pinsToCreate.has(pinId)) {
|
|
||||||
// This is a valid pinned tab that matches a pin
|
|
||||||
pinnedTabsByUUID.set(pinId, tab);
|
|
||||||
pinsToCreate.delete(pinId);
|
|
||||||
|
|
||||||
if (lazy.zenPinnedTabRestorePinnedTabsToPinnedUrl && init) {
|
|
||||||
this._resetTabToStoredState(tab);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// This is a pinned tab that no longer has a corresponding pin
|
|
||||||
gBrowser.removeTab(tab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const group of gZenWorkspaces.allTabGroups) {
|
|
||||||
const pinId = group.getAttribute('zen-pin-id');
|
|
||||||
if (!pinId) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pinsToCreate.has(pinId)) {
|
|
||||||
// This is a valid pinned group that matches a pin
|
|
||||||
pinsToCreate.delete(pinId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Second pass: For every existing tab, update its label
|
|
||||||
// and set 'zen-has-static-label' attribute if it's been edited
|
|
||||||
for (let pin of pins) {
|
|
||||||
const tab = pinnedTabsByUUID.get(pin.uuid);
|
|
||||||
if (!tab) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
tab.removeAttribute('zen-has-static-label'); // So we can set it again
|
|
||||||
if (pin.title && pin.editedTitle) {
|
|
||||||
gBrowser._setTabLabel(tab, pin.title, { beforeTabOpen: true });
|
|
||||||
tab.setAttribute('zen-has-static-label', 'true');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const groups = new Map();
|
|
||||||
const pendingTabsInsideGroups = {};
|
|
||||||
|
|
||||||
// Third pass: create new tabs for pins that don't have tabs
|
|
||||||
for (let pin of pins) {
|
|
||||||
try {
|
|
||||||
if (!pinsToCreate.has(pin.uuid)) {
|
|
||||||
continue; // Skip pins that already have tabs
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pin.isGroup) {
|
|
||||||
const tabs = [];
|
|
||||||
// If there's already existing tabs, let's use them
|
|
||||||
for (const [uuid, existingTab] of pinnedTabsByUUID) {
|
|
||||||
const pinObject = this._pinsCache.find((p) => p.uuid === uuid);
|
|
||||||
if (pinObject && pinObject.parentUuid === pin.uuid) {
|
|
||||||
tabs.push(existingTab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// We still need to iterate through pending tabs since the database
|
|
||||||
// query doesn't guarantee the order of insertion
|
|
||||||
for (const [parentUuid, folderTabs] of Object.entries(pendingTabsInsideGroups)) {
|
|
||||||
if (parentUuid === pin.uuid) {
|
|
||||||
tabs.push(...folderTabs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const group = gZenFolders.createFolder(tabs, {
|
|
||||||
label: pin.title,
|
|
||||||
collapsed: pin.isFolderCollapsed,
|
|
||||||
initialPinId: pin.uuid,
|
|
||||||
workspaceId: pin.workspaceUuid,
|
|
||||||
insertAfter:
|
|
||||||
groups.get(pin.parentUuid)?.querySelector('.tab-group-container')?.lastChild || null,
|
|
||||||
});
|
|
||||||
gZenFolders.setFolderUserIcon(group, pin.folderIcon);
|
|
||||||
groups.set(pin.uuid, group);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
skipAnimation: true,
|
|
||||||
allowInheritPrincipal: false,
|
|
||||||
skipBackgroundNotify: true,
|
|
||||||
userContextId: pin.containerTabId || 0,
|
|
||||||
createLazyBrowser: true,
|
|
||||||
skipLoad: true,
|
|
||||||
noInitialLabel: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create and initialize the tab
|
|
||||||
let newTab = gBrowser.addTrustedTab(pin.url, params);
|
|
||||||
newTab.setAttribute('zenDefaultUserContextId', true);
|
|
||||||
|
|
||||||
// Set initial label/title
|
|
||||||
if (pin.title) {
|
|
||||||
gBrowser.setInitialTabTitle(newTab, pin.title);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the icon if we have it cached
|
|
||||||
if (pin.iconUrl) {
|
|
||||||
gBrowser.setIcon(newTab, pin.iconUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
newTab.setAttribute('zen-pin-id', pin.uuid);
|
|
||||||
|
|
||||||
if (pin.workspaceUuid) {
|
|
||||||
newTab.setAttribute('zen-workspace-id', pin.workspaceUuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pin.isEssential) {
|
|
||||||
newTab.setAttribute('zen-essential', 'true');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pin.editedTitle) {
|
|
||||||
newTab.setAttribute('zen-has-static-label', 'true');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize browser state if needed
|
|
||||||
if (!newTab.linkedBrowser._remoteAutoRemoved) {
|
|
||||||
let state = {
|
|
||||||
entries: [
|
|
||||||
{
|
|
||||||
url: pin.url,
|
|
||||||
title: pin.title,
|
|
||||||
triggeringPrincipal_base64: E10SUtils.SERIALIZED_SYSTEMPRINCIPAL,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
userContextId: pin.containerTabId || 0,
|
|
||||||
image: pin.iconUrl,
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionStore.setTabState(newTab, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log(`Created new pinned tab for pin ${pin.uuid} (isEssential: ${pin.isEssential})`);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
if (pin.parentUuid) {
|
|
||||||
const parentGroup = groups.get(pin.parentUuid);
|
|
||||||
if (parentGroup) {
|
|
||||||
parentGroup.querySelector('.tab-group-container').appendChild(newTab);
|
|
||||||
} else {
|
|
||||||
if (pendingTabsInsideGroups[pin.parentUuid]) {
|
|
||||||
pendingTabsInsideGroups[pin.parentUuid].push(newTab);
|
|
||||||
} else {
|
|
||||||
pendingTabsInsideGroups[pin.parentUuid] = [newTab];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!pin.isEssential) {
|
|
||||||
const container = gZenWorkspaces.workspaceElement(
|
|
||||||
pin.workspaceUuid
|
|
||||||
)?.pinnedTabsContainer;
|
|
||||||
if (container) {
|
|
||||||
container.insertBefore(newTab, container.lastChild);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gZenWorkspaces.getEssentialsSection(pin.containerTabId).appendChild(newTab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gBrowser.tabContainer._invalidateCachedTabs();
|
|
||||||
newTab.initialize();
|
|
||||||
} catch (ex) {
|
|
||||||
console.error('Failed to initialize pinned tabs:', ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.#finishedInitializingPins();
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
gBrowser._updateTabBarForPinnedTabs();
|
|
||||||
gZenUIManager.updateTabsToolbar();
|
|
||||||
}
|
|
||||||
|
|
||||||
_onPinnedTabEvent(action, event) {
|
_onPinnedTabEvent(action, event) {
|
||||||
if (!this.enabled) return;
|
if (!this.enabled) return;
|
||||||
const tab = event.target;
|
const tab = event.target;
|
||||||
@@ -413,236 +115,24 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'TabPinned':
|
case 'TabPinned':
|
||||||
case 'TabAddedToEssentials':
|
|
||||||
tab._zenClickEventListener = this._zenClickEventListener;
|
tab._zenClickEventListener = this._zenClickEventListener;
|
||||||
tab.addEventListener('click', tab._zenClickEventListener);
|
tab.addEventListener('click', tab._zenClickEventListener);
|
||||||
this._setPinnedAttributes(tab);
|
|
||||||
break;
|
break;
|
||||||
case 'TabRemovedFromEssentials':
|
|
||||||
if (tab.pinned) {
|
|
||||||
this.#onTabMove(tab);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// [Fall through]
|
// [Fall through]
|
||||||
case 'TabUnpinned':
|
case 'TabUnpinned':
|
||||||
this._removePinnedAttributes(tab);
|
|
||||||
if (tab._zenClickEventListener) {
|
if (tab._zenClickEventListener) {
|
||||||
tab.removeEventListener('click', tab._zenClickEventListener);
|
tab.removeEventListener('click', tab._zenClickEventListener);
|
||||||
delete tab._zenClickEventListener;
|
delete tab._zenClickEventListener;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'TabMove':
|
|
||||||
this.#onTabMove(tab);
|
|
||||||
break;
|
|
||||||
case 'TabGroupCreate':
|
|
||||||
this.#onTabGroupCreate(event);
|
|
||||||
break;
|
|
||||||
case 'TabGroupRemoved':
|
|
||||||
this.#onTabGroupRemoved(event);
|
|
||||||
break;
|
|
||||||
case 'TabGroupMoved':
|
|
||||||
this.#onTabGroupMoved(event);
|
|
||||||
break;
|
|
||||||
case 'ZenFolderRenamed':
|
|
||||||
case 'ZenFolderIconChanged':
|
|
||||||
case 'TabGroupCollapse':
|
|
||||||
case 'TabGroupExpand':
|
|
||||||
case 'ZenFolderChangedWorkspace':
|
|
||||||
this.#updateGroupInfo(event.originalTarget, action);
|
|
||||||
break;
|
|
||||||
case 'TabGrouped':
|
|
||||||
this.#onTabGrouped(event);
|
|
||||||
break;
|
|
||||||
case 'TabUngrouped':
|
|
||||||
this.#onTabUngrouped(event);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
console.warn('ZenPinnedTabManager: Unhandled tab event', action);
|
console.warn('ZenPinnedTabManager: Unhandled tab event', action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async #onTabGroupCreate(event) {
|
#getTabState(tab) {
|
||||||
const group = event.originalTarget;
|
return JSON.parse(SessionStore.getTabState(tab));
|
||||||
if (!group.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (group.hasAttribute('zen-pin-id')) {
|
|
||||||
return; // Group already exists in storage
|
|
||||||
}
|
|
||||||
const workspaceId = group.getAttribute('zen-workspace-id');
|
|
||||||
let id = await ZenPinnedTabsStorage.createGroup(
|
|
||||||
group.name,
|
|
||||||
group.iconURL,
|
|
||||||
group.collapsed,
|
|
||||||
workspaceId,
|
|
||||||
group.getAttribute('zen-pin-id'),
|
|
||||||
group._pPos
|
|
||||||
);
|
|
||||||
group.setAttribute('zen-pin-id', id);
|
|
||||||
for (const tab of group.tabs) {
|
|
||||||
// Only add it if the tab is directly under the group
|
|
||||||
if (
|
|
||||||
tab.pinned &&
|
|
||||||
tab.hasAttribute('zen-pin-id') &&
|
|
||||||
tab.group === group &&
|
|
||||||
this.hasInitializedPins
|
|
||||||
) {
|
|
||||||
const tabPinId = tab.getAttribute('zen-pin-id');
|
|
||||||
await ZenPinnedTabsStorage.addTabToGroup(tabPinId, id, /* position */ tab._pPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await this.refreshPinnedTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onTabGrouped(event) {
|
|
||||||
const tab = event.detail;
|
|
||||||
const group = tab.group;
|
|
||||||
if (!group.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pinId = group.getAttribute('zen-pin-id');
|
|
||||||
const tabPinId = tab.getAttribute('zen-pin-id');
|
|
||||||
const tabPin = this._pinsCache?.find((p) => p.uuid === tabPinId);
|
|
||||||
if (!tabPin || !tabPin.group) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ZenPinnedTabsStorage.addTabToGroup(tabPinId, pinId, /* position */ tab._pPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onTabUngrouped(event) {
|
|
||||||
const tab = event.detail;
|
|
||||||
const group = tab.group;
|
|
||||||
if (!group?.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const tabPinId = tab.getAttribute('zen-pin-id');
|
|
||||||
const tabPin = this._pinsCache?.find((p) => p.uuid === tabPinId);
|
|
||||||
if (!tabPin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ZenPinnedTabsStorage.removeTabFromGroup(tabPinId, /* position */ tab._pPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
async #updateGroupInfo(group, action) {
|
|
||||||
if (!group?.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pinId = group.getAttribute('zen-pin-id');
|
|
||||||
const groupPin = this._pinsCache?.find((p) => p.uuid === pinId);
|
|
||||||
if (groupPin) {
|
|
||||||
groupPin.title = group.name;
|
|
||||||
groupPin.folderIcon = group.iconURL;
|
|
||||||
groupPin.isFolderCollapsed = group.collapsed;
|
|
||||||
groupPin.position = group._pPos;
|
|
||||||
groupPin.parentUuid = group.group?.getAttribute('zen-pin-id') || null;
|
|
||||||
groupPin.workspaceUuid = group.getAttribute('zen-workspace-id') || null;
|
|
||||||
await this.savePin(groupPin);
|
|
||||||
switch (action) {
|
|
||||||
case 'ZenFolderRenamed':
|
|
||||||
case 'ZenFolderIconChanged':
|
|
||||||
case 'TabGroupCollapse':
|
|
||||||
case 'TabGroupExpand':
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
for (const item of group.allItems) {
|
|
||||||
if (gBrowser.isTabGroup(item)) {
|
|
||||||
await this.#updateGroupInfo(item, action);
|
|
||||||
} else {
|
|
||||||
await this.#onTabMove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onTabGroupRemoved(event) {
|
|
||||||
const group = event.originalTarget;
|
|
||||||
if (!group.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await ZenPinnedTabsStorage.removePin(group.getAttribute('zen-pin-id'));
|
|
||||||
group.removeAttribute('zen-pin-id');
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onTabGroupMoved(event) {
|
|
||||||
const group = event.originalTarget;
|
|
||||||
if (!group.isZenFolder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const newIndex = group._pPos;
|
|
||||||
const pinId = group.getAttribute('zen-pin-id');
|
|
||||||
if (!pinId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (const tab of group.allItemsRecursive) {
|
|
||||||
if (tab.pinned && tab.getAttribute('zen-pin-id') === pinId) {
|
|
||||||
const pin = this._pinsCache.find((p) => p.uuid === pinId);
|
|
||||||
if (pin) {
|
|
||||||
pin.position = tab._pPos;
|
|
||||||
pin.parentUuid = tab.group?.getAttribute('zen-pin-id') || null;
|
|
||||||
pin.workspaceUuid = group.getAttribute('zen-workspace-id');
|
|
||||||
await this.savePin(pin, false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const groupPin = this._pinsCache?.find((p) => p.uuid === pinId);
|
|
||||||
if (groupPin) {
|
|
||||||
groupPin.position = newIndex;
|
|
||||||
groupPin.parentUuid = group.group?.getAttribute('zen-pin-id');
|
|
||||||
groupPin.workspaceUuid = group.getAttribute('zen-workspace-id');
|
|
||||||
await this.savePin(groupPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onTabMove(tab) {
|
|
||||||
if (!tab.pinned || !this._pinsCache) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const allTabs = [...gBrowser.tabs, ...gBrowser.tabGroups];
|
|
||||||
for (let i = 0; i < allTabs.length; i++) {
|
|
||||||
const otherTab = allTabs[i];
|
|
||||||
if (
|
|
||||||
otherTab.pinned &&
|
|
||||||
otherTab.getAttribute('zen-pin-id') !== tab.getAttribute('zen-pin-id')
|
|
||||||
) {
|
|
||||||
const actualPin = this._pinsCache.find(
|
|
||||||
(pin) => pin.uuid === otherTab.getAttribute('zen-pin-id')
|
|
||||||
);
|
|
||||||
if (!actualPin) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
actualPin.position = otherTab._pPos;
|
|
||||||
actualPin.workspaceUuid = otherTab.getAttribute('zen-workspace-id');
|
|
||||||
actualPin.parentUuid = otherTab.group?.getAttribute('zen-pin-id') || null;
|
|
||||||
await this.savePin(actualPin, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const actualPin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
|
||||||
|
|
||||||
if (!actualPin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
actualPin.position = tab._pPos;
|
|
||||||
actualPin.isEssential = tab.hasAttribute('zen-essential');
|
|
||||||
actualPin.parentUuid = tab.group?.getAttribute('zen-pin-id') || null;
|
|
||||||
actualPin.workspaceUuid = tab.getAttribute('zen-workspace-id') || null;
|
|
||||||
|
|
||||||
// There was a bug where the title and hasStaticLabel attribute were not being set
|
|
||||||
// This is a workaround to fix that
|
|
||||||
if (tab.hasAttribute('zen-has-static-label')) {
|
|
||||||
actualPin.editedTitle = true;
|
|
||||||
actualPin.title = tab.label;
|
|
||||||
}
|
|
||||||
await this.savePin(actualPin);
|
|
||||||
tab.dispatchEvent(
|
|
||||||
new CustomEvent('ZenPinnedTabMoved', {
|
|
||||||
detail: { tab },
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onTabClick(e) {
|
async _onTabClick(e) {
|
||||||
@@ -668,110 +158,15 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
|
|
||||||
async replacePinnedUrlWithCurrent(tab = undefined) {
|
async replacePinnedUrlWithCurrent(tab = undefined) {
|
||||||
tab ??= TabContextMenu.contextTab;
|
tab ??= TabContextMenu.contextTab;
|
||||||
if (!tab || !tab.pinned || !tab.getAttribute('zen-pin-id')) {
|
if (!tab || !tab.pinned) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const browser = tab.linkedBrowser;
|
window.gZenWindowSync.setPinnedTabState(tab);
|
||||||
|
|
||||||
const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
|
||||||
|
|
||||||
if (!pin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const userContextId = tab.getAttribute('usercontextid');
|
|
||||||
|
|
||||||
pin.title = tab.label || browser.contentTitle;
|
|
||||||
pin.url = browser.currentURI.spec;
|
|
||||||
pin.workspaceUuid = tab.getAttribute('zen-workspace-id');
|
|
||||||
pin.userContextId = userContextId ? parseInt(userContextId, 10) : 0;
|
|
||||||
|
|
||||||
await this.savePin(pin);
|
|
||||||
this.resetPinChangedUrl(tab);
|
this.resetPinChangedUrl(tab);
|
||||||
await this.refreshPinnedTabs();
|
|
||||||
gZenUIManager.showToast('zen-pinned-tab-replaced');
|
gZenUIManager.showToast('zen-pinned-tab-replaced');
|
||||||
}
|
}
|
||||||
|
|
||||||
async _setPinnedAttributes(tab) {
|
|
||||||
if (
|
|
||||||
tab.hasAttribute('zen-pin-id') ||
|
|
||||||
!this._hasFinishedLoading ||
|
|
||||||
tab.hasAttribute('zen-empty-tab')
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log(`Setting pinned attributes for tab ${tab.linkedBrowser.currentURI.spec}`);
|
|
||||||
const browser = tab.linkedBrowser;
|
|
||||||
|
|
||||||
const uuid = gZenUIManager.generateUuidv4();
|
|
||||||
const userContextId = tab.getAttribute('usercontextid');
|
|
||||||
|
|
||||||
let entry = null;
|
|
||||||
|
|
||||||
if (tab.getAttribute('zen-pinned-entry')) {
|
|
||||||
entry = JSON.parse(tab.getAttribute('zen-pinned-entry'));
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.savePin({
|
|
||||||
uuid,
|
|
||||||
title: entry?.title || tab.label || browser.contentTitle,
|
|
||||||
url: entry?.url || browser.currentURI.spec,
|
|
||||||
containerTabId: userContextId ? parseInt(userContextId, 10) : 0,
|
|
||||||
workspaceUuid: tab.getAttribute('zen-workspace-id'),
|
|
||||||
isEssential: tab.getAttribute('zen-essential') === 'true',
|
|
||||||
parentUuid: tab.group?.getAttribute('zen-pin-id') || null,
|
|
||||||
position: tab._pPos,
|
|
||||||
});
|
|
||||||
|
|
||||||
tab.setAttribute('zen-pin-id', uuid);
|
|
||||||
tab.dispatchEvent(
|
|
||||||
new CustomEvent('ZenPinnedTabCreated', {
|
|
||||||
detail: { tab },
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// This is used while migrating old pins to new system - we don't want to refresh when migrating
|
|
||||||
if (tab.getAttribute('zen-pinned-entry')) {
|
|
||||||
tab.removeAttribute('zen-pinned-entry');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.onLocationChange(browser);
|
|
||||||
await this.refreshPinnedTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
async _removePinnedAttributes(tab, isClosing = false) {
|
|
||||||
tab.removeAttribute('zen-has-static-label');
|
|
||||||
if (!tab.getAttribute('zen-pin-id') || this._temporarilyUnpiningEssential) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Services.startup.shuttingDown || window.skipNextCanClose) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log(`Removing pinned attributes for tab ${tab.getAttribute('zen-pin-id')}`);
|
|
||||||
await ZenPinnedTabsStorage.removePin(tab.getAttribute('zen-pin-id'));
|
|
||||||
this.resetPinChangedUrl(tab);
|
|
||||||
|
|
||||||
if (!isClosing) {
|
|
||||||
tab.removeAttribute('zen-pin-id');
|
|
||||||
tab.removeAttribute('zen-essential'); // Just in case
|
|
||||||
|
|
||||||
if (!tab.hasAttribute('zen-workspace-id') && gZenWorkspaces.workspaceEnabled) {
|
|
||||||
const workspace = await gZenWorkspaces.getActiveWorkspace();
|
|
||||||
tab.setAttribute('zen-workspace-id', workspace.uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await this.refreshPinnedTabs();
|
|
||||||
tab.dispatchEvent(
|
|
||||||
new CustomEvent('ZenPinnedTabRemoved', {
|
|
||||||
detail: { tab },
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_initClosePinnedTabShortcut() {
|
_initClosePinnedTabShortcut() {
|
||||||
let cmdClose = document.getElementById('cmd_close');
|
let cmdClose = document.getElementById('cmd_close');
|
||||||
|
|
||||||
@@ -780,21 +175,6 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async savePin(pin, notifyObservers = true) {
|
|
||||||
if (!this.hasInitializedPins && !gZenUIManager.testingEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const existingPin = this._pinsCache.find((p) => p.uuid === pin.uuid);
|
|
||||||
if (existingPin) {
|
|
||||||
Object.assign(existingPin, pin);
|
|
||||||
} else {
|
|
||||||
// We shouldn't need it, but just in case there's
|
|
||||||
// a race condition while making new pinned tabs.
|
|
||||||
this._pinsCache.push(pin);
|
|
||||||
}
|
|
||||||
await ZenPinnedTabsStorage.savePin(pin, notifyObservers);
|
|
||||||
}
|
|
||||||
|
|
||||||
async onCloseTabShortcut(
|
async onCloseTabShortcut(
|
||||||
event,
|
event,
|
||||||
selectedTab = gBrowser.selectedTab,
|
selectedTab = gBrowser.selectedTab,
|
||||||
@@ -841,7 +221,6 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
switch (behavior) {
|
switch (behavior) {
|
||||||
case 'close': {
|
case 'close': {
|
||||||
for (const tab of pinnedTabs) {
|
for (const tab of pinnedTabs) {
|
||||||
this._removePinnedAttributes(tab, true);
|
|
||||||
gBrowser.removeTab(tab, { animate: true });
|
gBrowser.removeTab(tab, { animate: true });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -943,35 +322,14 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_resetTabToStoredState(tab) {
|
_resetTabToStoredState(tab) {
|
||||||
const id = tab.getAttribute('zen-pin-id');
|
const state = this.#getTabState(tab);
|
||||||
if (!id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const pin = this._pinsCache.find((pin) => pin.uuid === id);
|
const initialState = tab._zenPinnedInitialState;
|
||||||
if (!pin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabState = SessionStore.getTabState(tab);
|
// Remove everything except the entry we want to keep
|
||||||
const state = JSON.parse(tabState);
|
state.entries = [initialState.entry];
|
||||||
|
|
||||||
const foundEntryIndex = state.entries?.findIndex((entry) => entry.url === pin.url);
|
state.image = initialState.image;
|
||||||
if (foundEntryIndex === -1) {
|
|
||||||
state.entries = [
|
|
||||||
{
|
|
||||||
url: pin.url,
|
|
||||||
title: pin.title,
|
|
||||||
triggeringPrincipal_base64: lazy.E10SUtils.SERIALIZED_SYSTEMPRINCIPAL,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
// Remove everything except the entry we want to keep
|
|
||||||
const existingEntry = state.entries[foundEntryIndex];
|
|
||||||
existingEntry.title = pin.title;
|
|
||||||
state.entries = [existingEntry];
|
|
||||||
}
|
|
||||||
state.image = pin.iconUrl || state.image;
|
|
||||||
state.index = 0;
|
state.index = 0;
|
||||||
|
|
||||||
SessionStore.setTabState(tab, state);
|
SessionStore.setTabState(tab, state);
|
||||||
@@ -1016,22 +374,15 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
if (tab.hasAttribute('zen-workspace-id')) {
|
if (tab.hasAttribute('zen-workspace-id')) {
|
||||||
tab.removeAttribute('zen-workspace-id');
|
tab.removeAttribute('zen-workspace-id');
|
||||||
}
|
}
|
||||||
if (tab.pinned && tab.hasAttribute('zen-pin-id')) {
|
if (tab.pinned) {
|
||||||
const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
|
||||||
if (pin) {
|
|
||||||
pin.isEssential = true;
|
|
||||||
pin.workspaceUuid = null;
|
|
||||||
this.savePin(pin);
|
|
||||||
}
|
|
||||||
gBrowser.zenHandleTabMove(tab, () => {
|
gBrowser.zenHandleTabMove(tab, () => {
|
||||||
if (tab.ownerGlobal !== window) {
|
if (tab.ownerGlobal !== window) {
|
||||||
tab = gBrowser.adoptTab(tab, {
|
tab = gBrowser.adoptTab(tab, {
|
||||||
selectTab: tab.selected,
|
selectTab: tab.selected,
|
||||||
});
|
});
|
||||||
tab.setAttribute('zen-essential', 'true');
|
tab.setAttribute('zen-essential', 'true');
|
||||||
} else {
|
|
||||||
section.appendChild(tab);
|
|
||||||
}
|
}
|
||||||
|
section.appendChild(tab);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
@@ -1124,8 +475,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
||||||
const zenAddEssential = document.getElementById('context_zen-add-essential');
|
const zenAddEssential = document.getElementById('context_zen-add-essential');
|
||||||
document.getElementById('context_zen-reset-pinned-tab').hidden =
|
document.getElementById('context_zen-reset-pinned-tab').hidden = !isVisible;
|
||||||
!isVisible || !contextTab.getAttribute('zen-pin-id');
|
|
||||||
document.getElementById('context_zen-replace-pinned-url-with-current').hidden = !isVisible;
|
document.getElementById('context_zen-replace-pinned-url-with-current').hidden = !isVisible;
|
||||||
zenAddEssential.hidden = contextTab.getAttribute('zen-essential') || !!contextTab.group;
|
zenAddEssential.hidden = contextTab.getAttribute('zen-essential') || !!contextTab.group;
|
||||||
zenAddEssential.setAttribute(
|
zenAddEssential.setAttribute(
|
||||||
@@ -1153,15 +503,16 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveToAnotherTabContainerIfNecessary(event, movingTabs) {
|
moveToAnotherTabContainerIfNecessary(event, movingTabs) {
|
||||||
|
movingTabs = [...movingTabs];
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
movingTabs = [...movingTabs];
|
|
||||||
try {
|
try {
|
||||||
const pinnedTabsTarget =
|
const pinnedTabsTarget = event.target.closest(
|
||||||
event.target.closest('.zen-current-workspace-indicator') || this._isGoingToPinnedTabs;
|
':is(.zen-current-workspace-indicator, .zen-workspace-pinned-tabs-section)'
|
||||||
|
);
|
||||||
const essentialTabsTarget = event.target.closest('.zen-essentials-container');
|
const essentialTabsTarget = event.target.closest('.zen-essentials-container');
|
||||||
const tabsTarget = !this._isGoingToPinnedTabs;
|
const tabsTarget = !pinnedTabsTarget;
|
||||||
|
|
||||||
// TODO: Solve the issue of adding a tab between two groups
|
// TODO: Solve the issue of adding a tab between two groups
|
||||||
// Remove group labels from the moving tabs and replace it
|
// Remove group labels from the moving tabs and replace it
|
||||||
@@ -1261,24 +612,25 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onLocationChange(browser) {
|
onLocationChange(browser) {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
if (!tab || !tab.pinned || tab.hasAttribute('zen-essential') || !this._pinsCache) {
|
if (
|
||||||
return;
|
!tab ||
|
||||||
}
|
!tab.pinned ||
|
||||||
const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
tab.hasAttribute('zen-essential') ||
|
||||||
if (!pin) {
|
!tab._zenPinnedInitialState?.entry
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Remove # and ? from the URL
|
// Remove # and ? from the URL
|
||||||
const pinUrl = pin.url.split('#')[0];
|
const pinUrl = tab._zenPinnedInitialState.entry.url.split('#')[0];
|
||||||
const currentUrl = browser.currentURI.spec.split('#')[0];
|
const currentUrl = browser.currentURI.spec.split('#')[0];
|
||||||
// Add an indicator that the pin has been changed
|
// Add an indicator that the pin has been changed
|
||||||
if (pinUrl === currentUrl) {
|
if (pinUrl === currentUrl) {
|
||||||
this.resetPinChangedUrl(tab);
|
this.resetPinChangedUrl(tab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.pinHasChangedUrl(tab, pin);
|
this.pinHasChangedUrl(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPinChangedUrl(tab) {
|
resetPinChangedUrl(tab) {
|
||||||
@@ -1290,7 +642,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
tab.style.removeProperty('--zen-original-tab-icon');
|
tab.style.removeProperty('--zen-original-tab-icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
pinHasChangedUrl(tab, pin) {
|
pinHasChangedUrl(tab) {
|
||||||
if (tab.hasAttribute('zen-pinned-changed')) {
|
if (tab.hasAttribute('zen-pinned-changed')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1299,7 +651,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
} else {
|
} else {
|
||||||
tab.setAttribute('zen-pinned-changed', 'true');
|
tab.setAttribute('zen-pinned-changed', 'true');
|
||||||
}
|
}
|
||||||
tab.style.setProperty('--zen-original-tab-icon', `url(${pin.iconUrl?.spec})`);
|
tab.style.setProperty('--zen-original-tab-icon', `url(${tab._zenPinnedInitialState.image})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTabContainersDragoverClass(hideIndicator = true) {
|
removeTabContainersDragoverClass(hideIndicator = true) {
|
||||||
@@ -1352,56 +704,6 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
: [separator];
|
: [separator];
|
||||||
}
|
}
|
||||||
|
|
||||||
animateSeparatorMove(movingTabs, dropElement, isPinned) {
|
|
||||||
let draggedTab = movingTabs[0];
|
|
||||||
if (gBrowser.isTabGroupLabel(draggedTab) && draggedTab.group.isZenFolder) {
|
|
||||||
this._isGoingToPinnedTabs = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (draggedTab?.group?.hasAttribute('split-view-group')) {
|
|
||||||
draggedTab = draggedTab.group;
|
|
||||||
}
|
|
||||||
const itemsToCheck = this.dragShiftableItems;
|
|
||||||
let translate = movingTabs[isPinned ? movingTabs.length - 1 : 0].getBoundingClientRect().top;
|
|
||||||
if (isPinned) {
|
|
||||||
const rect = draggedTab.getBoundingClientRect();
|
|
||||||
translate += rect.height;
|
|
||||||
}
|
|
||||||
const draggingTabHeight = movingTabs.reduce((acc, item) => {
|
|
||||||
return acc + window.windowUtils.getBoundsWithoutFlushing(item).height;
|
|
||||||
}, 0);
|
|
||||||
if (typeof this._topToNormalTabs === 'undefined') {
|
|
||||||
const rects = itemsToCheck.map((item) => window.windowUtils.getBoundsWithoutFlushing(item));
|
|
||||||
this._topToNormalTabs = rects[0].top + rects.at(-1).height / (isPinned ? 2 : 4);
|
|
||||||
}
|
|
||||||
let topToNormalTabs = this._topToNormalTabs;
|
|
||||||
const isGoingToPinnedTabs =
|
|
||||||
translate < topToNormalTabs && gBrowser.pinnedTabCount - gBrowser._numZenEssentials > 0;
|
|
||||||
const multiplier = isGoingToPinnedTabs !== isPinned ? (isGoingToPinnedTabs ? 1 : -1) : 0;
|
|
||||||
this._isGoingToPinnedTabs = isGoingToPinnedTabs;
|
|
||||||
if (!dropElement) {
|
|
||||||
itemsToCheck.forEach((item) => {
|
|
||||||
item.style.transform = `translateY(${draggingTabHeight * multiplier}px)`;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getLastTabBound(lastBound, lastTab, isDraggingFolder = false) {
|
|
||||||
if (!lastTab.pinned || isDraggingFolder) {
|
|
||||||
return lastBound;
|
|
||||||
}
|
|
||||||
const shiftedItems = this.dragShiftableItems;
|
|
||||||
let totalHeight = shiftedItems.reduce((acc, item) => {
|
|
||||||
return acc + window.windowUtils.getBoundsWithoutFlushing(item).height;
|
|
||||||
}, 0);
|
|
||||||
if (shiftedItems.length === 1) {
|
|
||||||
// Means the new tab button is not at the top or not visible
|
|
||||||
const lastTabRect = window.windowUtils.getBoundsWithoutFlushing(lastTab);
|
|
||||||
totalHeight += lastTabRect.height;
|
|
||||||
}
|
|
||||||
return lastBound + totalHeight + 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
get dragIndicator() {
|
get dragIndicator() {
|
||||||
if (!this._dragIndicator) {
|
if (!this._dragIndicator) {
|
||||||
this._dragIndicator = document.createElement('div');
|
this._dragIndicator = document.createElement('div');
|
||||||
@@ -1415,39 +717,13 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
return document.documentElement.getAttribute('zen-sidebar-expanded') === 'true';
|
return document.documentElement.getAttribute('zen-sidebar-expanded') === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
async updatePinTitle(tab, newTitle, isEdited = true, notifyObservers = true) {
|
async updatePinTitle(tab, newTitle, isEdited = true) {
|
||||||
const uuid = tab.getAttribute('zen-pin-id');
|
tab.removeAttribute('zen-has-static-label');
|
||||||
await ZenPinnedTabsStorage.updatePinTitle(uuid, newTitle, isEdited, notifyObservers);
|
if (isEdited) {
|
||||||
|
gBrowser._setTabLabel(tab, newTitle);
|
||||||
await this.refreshPinnedTabs();
|
tab.setAttribute('zen-has-static-label', 'true');
|
||||||
|
} else {
|
||||||
const browsers = Services.wm.getEnumerator('navigator:browser');
|
gBrowser.setTabTitle(tab);
|
||||||
|
|
||||||
// update the label for the same pin across all windows
|
|
||||||
for (const browser of browsers) {
|
|
||||||
const tabs = browser.gBrowser.tabs;
|
|
||||||
// Fix pinned cache for the browser
|
|
||||||
const browserCache = browser.gZenPinnedTabManager?._pinsCache;
|
|
||||||
if (browserCache) {
|
|
||||||
const pin = browserCache.find((pin) => pin.uuid === uuid);
|
|
||||||
if (pin) {
|
|
||||||
pin.title = newTitle;
|
|
||||||
pin.editedTitle = isEdited;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let i = 0; i < tabs.length; i++) {
|
|
||||||
const tabToEdit = tabs[i];
|
|
||||||
if (tabToEdit.getAttribute('zen-pin-id') === uuid && tabToEdit !== tab) {
|
|
||||||
tabToEdit.removeAttribute('zen-has-static-label');
|
|
||||||
if (isEdited) {
|
|
||||||
gBrowser._setTabLabel(tabToEdit, newTitle);
|
|
||||||
tabToEdit.setAttribute('zen-has-static-label', 'true');
|
|
||||||
} else {
|
|
||||||
gBrowser.setTabTitle(tabToEdit);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1563,19 +839,8 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onTabLabelChanged(tab) {
|
onTabLabelChanged(tab) {
|
||||||
if (!this._pinsCache) {
|
tab.dispatchEvent(new CustomEvent('ZenTabLabelChanged', { bubbles: true, detail: { tab } }));
|
||||||
return;
|
|
||||||
}
|
|
||||||
// If our current pin in the cache point to about:blank, we need to update the entry
|
|
||||||
const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
|
|
||||||
if (!pin) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pin.url === 'about:blank' && tab.linkedBrowser.currentURI.spec !== 'about:blank') {
|
|
||||||
await this.replacePinnedUrlWithCurrent(tab);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,660 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
window.ZenPinnedTabsStorage = {
|
|
||||||
_saveCache: [],
|
|
||||||
|
|
||||||
async init() {
|
|
||||||
await this._ensureTable();
|
|
||||||
},
|
|
||||||
|
|
||||||
async _ensureTable() {
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage._ensureTable', async (db) => {
|
|
||||||
// Create the pins table if it doesn't exist
|
|
||||||
await db.execute(`
|
|
||||||
CREATE TABLE IF NOT EXISTS zen_pins (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
uuid TEXT UNIQUE NOT NULL,
|
|
||||||
title TEXT NOT NULL,
|
|
||||||
url TEXT,
|
|
||||||
container_id INTEGER,
|
|
||||||
workspace_uuid TEXT,
|
|
||||||
position INTEGER NOT NULL DEFAULT 0,
|
|
||||||
is_essential BOOLEAN NOT NULL DEFAULT 0,
|
|
||||||
is_group BOOLEAN NOT NULL DEFAULT 0,
|
|
||||||
created_at INTEGER NOT NULL,
|
|
||||||
updated_at INTEGER NOT NULL
|
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
const columns = await db.execute(`PRAGMA table_info(zen_pins)`);
|
|
||||||
const columnNames = columns.map((row) => row.getResultByName('name'));
|
|
||||||
|
|
||||||
// Helper function to add column if it doesn't exist
|
|
||||||
const addColumnIfNotExists = async (columnName, definition) => {
|
|
||||||
if (!columnNames.includes(columnName)) {
|
|
||||||
await db.execute(`ALTER TABLE zen_pins ADD COLUMN ${columnName} ${definition}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
await addColumnIfNotExists('edited_title', 'BOOLEAN NOT NULL DEFAULT 0');
|
|
||||||
await addColumnIfNotExists('is_folder_collapsed', 'BOOLEAN NOT NULL DEFAULT 0');
|
|
||||||
await addColumnIfNotExists('folder_icon', 'TEXT DEFAULT NULL');
|
|
||||||
await addColumnIfNotExists('folder_parent_uuid', 'TEXT DEFAULT NULL');
|
|
||||||
|
|
||||||
await db.execute(`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_zen_pins_uuid ON zen_pins(uuid)
|
|
||||||
`);
|
|
||||||
|
|
||||||
await db.execute(`
|
|
||||||
CREATE TABLE IF NOT EXISTS zen_pins_changes (
|
|
||||||
uuid TEXT PRIMARY KEY,
|
|
||||||
timestamp INTEGER NOT NULL
|
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
await db.execute(`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_zen_pins_changes_uuid ON zen_pins_changes(uuid)
|
|
||||||
`);
|
|
||||||
|
|
||||||
this._resolveInitialized();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private helper method to notify observers with a list of changed UUIDs.
|
|
||||||
* @param {string} event - The observer event name.
|
|
||||||
* @param {Array<string>} uuids - Array of changed workspace UUIDs.
|
|
||||||
*/
|
|
||||||
_notifyPinsChanged(event, uuids) {
|
|
||||||
if (uuids.length === 0) return; // No changes to notify
|
|
||||||
|
|
||||||
// Convert the array of UUIDs to a JSON string
|
|
||||||
const data = JSON.stringify(uuids);
|
|
||||||
|
|
||||||
Services.obs.notifyObservers(null, event, data);
|
|
||||||
},
|
|
||||||
|
|
||||||
async savePin(pin, notifyObservers = true) {
|
|
||||||
// If we find the exact same pin in the cache, skip saving
|
|
||||||
const existingIndex = this._saveCache.findIndex((cachedPin) => cachedPin.uuid === pin.uuid);
|
|
||||||
const copy = { ...pin };
|
|
||||||
if (existingIndex !== -1) {
|
|
||||||
const existingPin = this._saveCache[existingIndex];
|
|
||||||
const isSame = Object.keys(pin).every((key) => pin[key] === existingPin[key]);
|
|
||||||
if (isSame) {
|
|
||||||
return; // No changes, skip saving
|
|
||||||
} else {
|
|
||||||
// Update the cached pin
|
|
||||||
this._saveCache[existingIndex] = { ...copy };
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Add to cache
|
|
||||||
this._saveCache.push(copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.savePin', async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
let newPosition;
|
|
||||||
if ('position' in pin && Number.isFinite(pin.position)) {
|
|
||||||
newPosition = pin.position;
|
|
||||||
} else {
|
|
||||||
// Get the maximum position within the same parent group (or null for root level)
|
|
||||||
const maxPositionResult = await db.execute(
|
|
||||||
`
|
|
||||||
SELECT MAX("position") as max_position
|
|
||||||
FROM zen_pins
|
|
||||||
WHERE COALESCE(folder_parent_uuid, '') = COALESCE(:folder_parent_uuid, '')
|
|
||||||
`,
|
|
||||||
{ folder_parent_uuid: pin.parentUuid || null }
|
|
||||||
);
|
|
||||||
const maxPosition = maxPositionResult[0].getResultByName('max_position') || 0;
|
|
||||||
newPosition = maxPosition + 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert or replace the pin
|
|
||||||
await db.executeCached(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins (
|
|
||||||
uuid, title, url, container_id, workspace_uuid, position,
|
|
||||||
is_essential, is_group, folder_parent_uuid, edited_title, created_at,
|
|
||||||
updated_at, is_folder_collapsed, folder_icon
|
|
||||||
) VALUES (
|
|
||||||
:uuid, :title, :url, :container_id, :workspace_uuid, :position,
|
|
||||||
:is_essential, :is_group, :folder_parent_uuid, :edited_title,
|
|
||||||
COALESCE((SELECT created_at FROM zen_pins WHERE uuid = :uuid), :now),
|
|
||||||
:now, :is_folder_collapsed, :folder_icon
|
|
||||||
)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: pin.uuid,
|
|
||||||
title: pin.title,
|
|
||||||
url: pin.isGroup ? '' : pin.url,
|
|
||||||
container_id: pin.containerTabId || null,
|
|
||||||
workspace_uuid: pin.workspaceUuid || null,
|
|
||||||
position: newPosition,
|
|
||||||
is_essential: pin.isEssential || false,
|
|
||||||
is_group: pin.isGroup || false,
|
|
||||||
folder_parent_uuid: pin.parentUuid || null,
|
|
||||||
edited_title: pin.editedTitle || false,
|
|
||||||
now,
|
|
||||||
folder_icon: pin.folderIcon || null,
|
|
||||||
is_folder_collapsed: pin.isFolderCollapsed || false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: pin.uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(pin.uuid);
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async getPins() {
|
|
||||||
const db = await PlacesUtils.promiseDBConnection();
|
|
||||||
const rows = await db.executeCached(`
|
|
||||||
SELECT * FROM zen_pins
|
|
||||||
ORDER BY position ASC
|
|
||||||
`);
|
|
||||||
return rows.map((row) => ({
|
|
||||||
uuid: row.getResultByName('uuid'),
|
|
||||||
title: row.getResultByName('title'),
|
|
||||||
url: row.getResultByName('url'),
|
|
||||||
containerTabId: row.getResultByName('container_id'),
|
|
||||||
workspaceUuid: row.getResultByName('workspace_uuid'),
|
|
||||||
position: row.getResultByName('position'),
|
|
||||||
isEssential: Boolean(row.getResultByName('is_essential')),
|
|
||||||
isGroup: Boolean(row.getResultByName('is_group')),
|
|
||||||
parentUuid: row.getResultByName('folder_parent_uuid'),
|
|
||||||
editedTitle: Boolean(row.getResultByName('edited_title')),
|
|
||||||
folderIcon: row.getResultByName('folder_icon'),
|
|
||||||
isFolderCollapsed: Boolean(row.getResultByName('is_folder_collapsed')),
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new group
|
|
||||||
* @param {string} title - The title of the group
|
|
||||||
* @param {string} workspaceUuid - The workspace UUID (optional)
|
|
||||||
* @param {string} parentUuid - The parent group UUID (optional, null for root level)
|
|
||||||
* @param {number} position - The position of the group (optional, will auto-calculate if not provided)
|
|
||||||
* @param {boolean} notifyObservers - Whether to notify observers (default: true)
|
|
||||||
* @returns {Promise<string>} The UUID of the created group
|
|
||||||
*/
|
|
||||||
async createGroup(
|
|
||||||
title,
|
|
||||||
icon = null,
|
|
||||||
isCollapsed = false,
|
|
||||||
workspaceUuid = null,
|
|
||||||
parentUuid = null,
|
|
||||||
position = null,
|
|
||||||
notifyObservers = true
|
|
||||||
) {
|
|
||||||
if (!title || typeof title !== 'string') {
|
|
||||||
throw new Error('Group title is required and must be a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
const groupUuid = gZenUIManager.generateUuidv4();
|
|
||||||
|
|
||||||
const groupPin = {
|
|
||||||
uuid: groupUuid,
|
|
||||||
title,
|
|
||||||
folderIcon: icon || null,
|
|
||||||
isFolderCollapsed: isCollapsed || false,
|
|
||||||
workspaceUuid,
|
|
||||||
parentUuid,
|
|
||||||
position,
|
|
||||||
isGroup: true,
|
|
||||||
isEssential: false,
|
|
||||||
editedTitle: true, // Group titles are always considered edited
|
|
||||||
};
|
|
||||||
|
|
||||||
await this.savePin(groupPin, notifyObservers);
|
|
||||||
return groupUuid;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an existing tab/pin to a group
|
|
||||||
* @param {string} tabUuid - The UUID of the tab to add to the group
|
|
||||||
* @param {string} groupUuid - The UUID of the target group
|
|
||||||
* @param {number} position - The position within the group (optional, will append if not provided)
|
|
||||||
* @param {boolean} notifyObservers - Whether to notify observers (default: true)
|
|
||||||
*/
|
|
||||||
async addTabToGroup(tabUuid, groupUuid, position = null, notifyObservers = true) {
|
|
||||||
if (!tabUuid || !groupUuid) {
|
|
||||||
throw new Error('Both tabUuid and groupUuid are required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.addTabToGroup', async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
// Verify the group exists and is actually a group
|
|
||||||
const groupCheck = await db.execute(
|
|
||||||
`SELECT is_group FROM zen_pins WHERE uuid = :groupUuid`,
|
|
||||||
{ groupUuid }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (groupCheck.length === 0) {
|
|
||||||
throw new Error(`Group with UUID ${groupUuid} does not exist`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!groupCheck[0].getResultByName('is_group')) {
|
|
||||||
throw new Error(`Pin with UUID ${groupUuid} is not a group`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabCheck = await db.execute(`SELECT uuid FROM zen_pins WHERE uuid = :tabUuid`, {
|
|
||||||
tabUuid,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tabCheck.length === 0) {
|
|
||||||
throw new Error(`Tab with UUID ${tabUuid} does not exist`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = Date.now();
|
|
||||||
let newPosition;
|
|
||||||
|
|
||||||
if (position !== null && Number.isFinite(position)) {
|
|
||||||
newPosition = position;
|
|
||||||
} else {
|
|
||||||
// Get the maximum position within the group
|
|
||||||
const maxPositionResult = await db.execute(
|
|
||||||
`SELECT MAX("position") as max_position FROM zen_pins WHERE folder_parent_uuid = :groupUuid`,
|
|
||||||
{ groupUuid }
|
|
||||||
);
|
|
||||||
const maxPosition = maxPositionResult[0].getResultByName('max_position') || 0;
|
|
||||||
newPosition = maxPosition + 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_pins
|
|
||||||
SET folder_parent_uuid = :groupUuid,
|
|
||||||
position = :newPosition,
|
|
||||||
updated_at = :now
|
|
||||||
WHERE uuid = :tabUuid
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
tabUuid,
|
|
||||||
groupUuid,
|
|
||||||
newPosition,
|
|
||||||
now,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(tabUuid);
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: tabUuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a tab from its group (move to root level)
|
|
||||||
* @param {string} tabUuid - The UUID of the tab to remove from its group
|
|
||||||
* @param {number} newPosition - The new position at root level (optional, will append if not provided)
|
|
||||||
* @param {boolean} notifyObservers - Whether to notify observers (default: true)
|
|
||||||
*/
|
|
||||||
async removeTabFromGroup(tabUuid, newPosition = null, notifyObservers = true) {
|
|
||||||
if (!tabUuid) {
|
|
||||||
throw new Error('tabUuid is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenPinnedTabsStorage.removeTabFromGroup',
|
|
||||||
async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
// Verify the tab exists and is in a group
|
|
||||||
const tabCheck = await db.execute(
|
|
||||||
`SELECT folder_parent_uuid FROM zen_pins WHERE uuid = :tabUuid`,
|
|
||||||
{ tabUuid }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (tabCheck.length === 0) {
|
|
||||||
throw new Error(`Tab with UUID ${tabUuid} does not exist`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tabCheck[0].getResultByName('folder_parent_uuid')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = Date.now();
|
|
||||||
let finalPosition;
|
|
||||||
|
|
||||||
if (newPosition !== null && Number.isFinite(newPosition)) {
|
|
||||||
finalPosition = newPosition;
|
|
||||||
} else {
|
|
||||||
// Get the maximum position at root level (where folder_parent_uuid is null)
|
|
||||||
const maxPositionResult = await db.execute(
|
|
||||||
`SELECT MAX("position") as max_position FROM zen_pins WHERE folder_parent_uuid IS NULL`
|
|
||||||
);
|
|
||||||
const maxPosition = maxPositionResult[0].getResultByName('max_position') || 0;
|
|
||||||
finalPosition = maxPosition + 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the tab to be at root level
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_pins
|
|
||||||
SET folder_parent_uuid = NULL,
|
|
||||||
position = :newPosition,
|
|
||||||
updated_at = :now
|
|
||||||
WHERE uuid = :tabUuid
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
tabUuid,
|
|
||||||
newPosition: finalPosition,
|
|
||||||
now,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(tabUuid);
|
|
||||||
|
|
||||||
// Record the change
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: tabUuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async removePin(uuid, notifyObservers = true) {
|
|
||||||
const cachedIndex = this._saveCache.findIndex((cachedPin) => cachedPin.uuid === uuid);
|
|
||||||
if (cachedIndex !== -1) {
|
|
||||||
this._saveCache.splice(cachedIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedUUIDs = [uuid];
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.removePin', async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
// Get all child UUIDs first for change tracking
|
|
||||||
const children = await db.execute(
|
|
||||||
`SELECT uuid FROM zen_pins WHERE folder_parent_uuid = :uuid`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add child UUIDs to changedUUIDs array
|
|
||||||
for (const child of children) {
|
|
||||||
changedUUIDs.push(child.getResultByName('uuid'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the pin/group itself
|
|
||||||
await db.execute(`DELETE FROM zen_pins WHERE uuid = :uuid`, { uuid });
|
|
||||||
|
|
||||||
// Record the changes
|
|
||||||
const now = Math.floor(Date.now() / 1000);
|
|
||||||
for (const changedUuid of changedUUIDs) {
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: changedUuid,
|
|
||||||
timestamp: now,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyPinsChanged('zen-pin-removed', changedUUIDs);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async wipeAllPins() {
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.wipeAllPins', async (db) => {
|
|
||||||
await db.execute(`DELETE FROM zen_pins`);
|
|
||||||
await db.execute(`DELETE FROM zen_pins_changes`);
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
async markChanged(uuid) {
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.markChanged', async (db) => {
|
|
||||||
const now = Date.now();
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
async getChangedIDs() {
|
|
||||||
const db = await PlacesUtils.promiseDBConnection();
|
|
||||||
const rows = await db.execute(`
|
|
||||||
SELECT uuid, timestamp FROM zen_pins_changes
|
|
||||||
`);
|
|
||||||
const changes = {};
|
|
||||||
for (const row of rows) {
|
|
||||||
changes[row.getResultByName('uuid')] = row.getResultByName('timestamp');
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
},
|
|
||||||
|
|
||||||
async clearChangedIDs() {
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.clearChangedIDs', async (db) => {
|
|
||||||
await db.execute(`DELETE FROM zen_pins_changes`);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
shouldReorderPins(before, current, after) {
|
|
||||||
const minGap = 1; // Minimum allowed gap between positions
|
|
||||||
return (
|
|
||||||
(before !== null && current - before < minGap) || (after !== null && after - current < minGap)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async reorderAllPins(db, changedUUIDs) {
|
|
||||||
const pins = await db.execute(`
|
|
||||||
SELECT uuid
|
|
||||||
FROM zen_pins
|
|
||||||
ORDER BY position ASC
|
|
||||||
`);
|
|
||||||
|
|
||||||
for (let i = 0; i < pins.length; i++) {
|
|
||||||
const newPosition = (i + 1) * 1000; // Use large increments
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_pins
|
|
||||||
SET position = :newPosition
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{ newPosition, uuid: pins[i].getResultByName('uuid') }
|
|
||||||
);
|
|
||||||
changedUUIDs.add(pins[i].getResultByName('uuid'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async updateLastChangeTimestamp(db) {
|
|
||||||
const now = Date.now();
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO moz_meta (key, value)
|
|
||||||
VALUES ('zen_pins_last_change', :now)
|
|
||||||
`,
|
|
||||||
{ now }
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async getLastChangeTimestamp() {
|
|
||||||
const db = await PlacesUtils.promiseDBConnection();
|
|
||||||
const result = await db.executeCached(`
|
|
||||||
SELECT value FROM moz_meta WHERE key = 'zen_pins_last_change'
|
|
||||||
`);
|
|
||||||
return result.length ? parseInt(result[0].getResultByName('value'), 10) : 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
async updatePinPositions(pins) {
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenPinnedTabsStorage.updatePinPositions',
|
|
||||||
async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
for (let i = 0; i < pins.length; i++) {
|
|
||||||
const pin = pins[i];
|
|
||||||
const newPosition = (i + 1) * 1000;
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_pins
|
|
||||||
SET position = :newPosition
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{ newPosition, uuid: pin.uuid }
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(pin.uuid);
|
|
||||||
|
|
||||||
// Record the change
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: pin.uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
|
||||||
},
|
|
||||||
|
|
||||||
async updatePinTitle(uuid, newTitle, isEdited = true, notifyObservers = true) {
|
|
||||||
if (!uuid || typeof newTitle !== 'string') {
|
|
||||||
throw new Error('Invalid parameters: uuid and newTitle are required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.updatePinTitle', async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
// Update the pin's title and edited_title flag
|
|
||||||
const result = await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_pins
|
|
||||||
SET title = :newTitle,
|
|
||||||
edited_title = :isEdited,
|
|
||||||
updated_at = :now
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
newTitle,
|
|
||||||
isEdited,
|
|
||||||
now,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Only proceed with change tracking if a row was actually updated
|
|
||||||
if (result.rowsAffected > 0) {
|
|
||||||
changedUUIDs.add(uuid);
|
|
||||||
|
|
||||||
// Record the change
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notifyObservers && changedUUIDs.size > 0) {
|
|
||||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async __dropTables() {
|
|
||||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.__dropTables', async (db) => {
|
|
||||||
await db.execute(`DROP TABLE IF EXISTS zen_pins`);
|
|
||||||
await db.execute(`DROP TABLE IF EXISTS zen_pins_changes`);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
ZenPinnedTabsStorage.promiseInitialized = new Promise((resolve) => {
|
|
||||||
ZenPinnedTabsStorage._resolveInitialized = resolve;
|
|
||||||
ZenPinnedTabsStorage.init();
|
|
||||||
});
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
content/browser/zen-components/ZenPinnedTabsStorage.mjs (../../zen/tabs/ZenPinnedTabsStorage.mjs)
|
|
||||||
content/browser/zen-components/ZenPinnedTabManager.mjs (../../zen/tabs/ZenPinnedTabManager.mjs)
|
content/browser/zen-components/ZenPinnedTabManager.mjs (../../zen/tabs/ZenPinnedTabManager.mjs)
|
||||||
* content/browser/zen-styles/zen-tabs.css (../../zen/tabs/zen-tabs.css)
|
* content/browser/zen-styles/zen-tabs.css (../../zen/tabs/zen-tabs.css)
|
||||||
content/browser/zen-styles/zen-tabs/vertical-tabs.css (../../zen/tabs/zen-tabs/vertical-tabs.css)
|
content/browser/zen-styles/zen-tabs/vertical-tabs.css (../../zen/tabs/zen-tabs/vertical-tabs.css)
|
||||||
@@ -1281,9 +1281,9 @@
|
|||||||
width: calc(var(--indicator-width) - 2 * var(--zen-drag-indicator-height) - 4px);
|
width: calc(var(--indicator-width) - 2 * var(--zen-drag-indicator-height) - 4px);
|
||||||
height: var(--zen-drag-indicator-height);
|
height: var(--zen-drag-indicator-height);
|
||||||
transition:
|
transition:
|
||||||
top 0.1s ease-out,
|
top 0.05s ease-out,
|
||||||
left 0.1s ease-out,
|
left 0.05s ease-out,
|
||||||
width 0.1s ease-out;
|
width 0.05s ease-out;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
left: calc(-2 * var(--zen-drag-indicator-height));
|
left: calc(-2 * var(--zen-drag-indicator-height));
|
||||||
@@ -1370,3 +1370,13 @@
|
|||||||
.tab-group-label-container[zen-dragtarget] {
|
.tab-group-label-container[zen-dragtarget] {
|
||||||
z-index: 9 !important;
|
z-index: 9 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#zen-dragover-background {
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
/* Extra width to cover the sidebar splitter */
|
||||||
|
width: calc(100% + var(--zen-toolbox-padding));
|
||||||
|
left: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
background: var(--zen-primary-color);
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
add_task(async function test_Container_Essentials_Auto_Swithc() {
|
add_task(async function test_Container_Essentials_Auto_Swithc() {
|
||||||
await gZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
await gZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
||||||
const workspaces = await gZenWorkspaces._workspaces();
|
const workspaces = await gZenWorkspaces._workspaces();
|
||||||
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
|
ok(workspaces.length === 2, 'Two workspaces should exist.');
|
||||||
|
|
||||||
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
|
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
|
||||||
skipAnimation: true,
|
skipAnimation: true,
|
||||||
@@ -27,11 +27,11 @@ add_task(async function test_Container_Essentials_Auto_Swithc() {
|
|||||||
const newWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
const newWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
gZenWorkspaces.activeWorkspace,
|
gZenWorkspaces.activeWorkspace,
|
||||||
workspaces.workspaces[1].uuid,
|
workspaces[1].uuid,
|
||||||
'The new workspace should be active.'
|
'The new workspace should be active.'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Change to the original workspace, there should be no essential tabs
|
// Change to the original workspace, there should be no essential tabs
|
||||||
await gZenWorkspaces.changeWorkspace(workspaces.workspaces[0]);
|
await gZenWorkspaces.changeWorkspace(workspaces[0]);
|
||||||
await gZenWorkspaces.removeWorkspace(newWorkspaceUUID);
|
await gZenWorkspaces.removeWorkspace(newWorkspaceUUID);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
add_task(async function test_Check_Creation() {
|
add_task(async function test_Check_Creation() {
|
||||||
await gZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
await gZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
||||||
const workspaces = await gZenWorkspaces._workspaces();
|
const workspaces = await gZenWorkspaces._workspaces();
|
||||||
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
|
ok(workspaces.length === 2, 'Two workspaces should exist.');
|
||||||
|
|
||||||
await gZenWorkspaces.changeWorkspace(workspaces.workspaces[1]);
|
await gZenWorkspaces.changeWorkspace(workspaces[1]);
|
||||||
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
|
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
|
||||||
skipAnimation: true,
|
skipAnimation: true,
|
||||||
userContextId: 1,
|
userContextId: 1,
|
||||||
@@ -28,7 +28,7 @@ add_task(async function test_Check_Creation() {
|
|||||||
const newWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
const newWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
||||||
|
|
||||||
// Change to the original workspace, there should be no essential tabs
|
// Change to the original workspace, there should be no essential tabs
|
||||||
await gZenWorkspaces.changeWorkspace(workspaces.workspaces[0]);
|
await gZenWorkspaces.changeWorkspace(workspaces[0]);
|
||||||
ok(
|
ok(
|
||||||
!gBrowser.tabs.find(
|
!gBrowser.tabs.find(
|
||||||
(t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1
|
(t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1
|
||||||
|
|||||||
@@ -31,9 +31,6 @@ add_task(async function test_Duplicate_Tab_Inside_Folder() {
|
|||||||
|
|
||||||
for (const t of folder.tabs) {
|
for (const t of folder.tabs) {
|
||||||
ok(t.pinned, 'All tabs in the folder should be pinned');
|
ok(t.pinned, 'All tabs in the folder should be pinned');
|
||||||
if (!t.hasAttribute('zen-empty-tab')) {
|
|
||||||
ok(t.hasAttribute('zen-pin-id'), 'All non-empty tabs should have a zen-pinned-id attribute');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gBrowser.selectedTab = selectedTab;
|
gBrowser.selectedTab = selectedTab;
|
||||||
|
|||||||
@@ -13,14 +13,9 @@ prefs = ["zen.workspaces.separate-essentials=false"]
|
|||||||
["browser_pinned_close.js"]
|
["browser_pinned_close.js"]
|
||||||
["browser_pinned_changed.js"]
|
["browser_pinned_changed.js"]
|
||||||
["browser_pinned_created.js"]
|
["browser_pinned_created.js"]
|
||||||
["browser_pinned_edit_label.js"]
|
|
||||||
["browser_pinned_removed.js"]
|
|
||||||
["browser_pinned_reorder_changed_label.js"]
|
|
||||||
["browser_pinned_reordered.js"]
|
|
||||||
["browser_pinned_to_essential.js"]
|
["browser_pinned_to_essential.js"]
|
||||||
|
|
||||||
["browser_private_mode_no_essentials.js"]
|
["browser_private_mode_no_essentials.js"]
|
||||||
["browser_private_mode_no_ctx_menu.js"]
|
["browser_private_mode_no_ctx_menu.js"]
|
||||||
|
|
||||||
["browser_issue_7654.js"]
|
|
||||||
["browser_issue_8726.js"]
|
["browser_issue_8726.js"]
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(this, {
|
|
||||||
UrlbarTestUtils: 'resource://testing-common/UrlbarTestUtils.sys.mjs',
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_Search_Pinned_Title() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const customLabel = 'ZEN ROCKS';
|
|
||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function () {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
await gZenPinnedTabManager.updatePinTitle(tab, customLabel, true);
|
|
||||||
|
|
||||||
const pinnedTabs = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pinnedTabs.find((pin) => pin.uuid === pinTabID);
|
|
||||||
Assert.equal(pinObject.title, customLabel, 'The pin object should have the correct title');
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/2', true);
|
|
||||||
|
|
||||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
|
||||||
window,
|
|
||||||
value: customLabel,
|
|
||||||
waitForFocus: SimpleTest.waitForFocus,
|
|
||||||
});
|
|
||||||
|
|
||||||
const total = UrlbarTestUtils.getResultCount(window);
|
|
||||||
info(`Found ${total} matches`);
|
|
||||||
|
|
||||||
const result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
|
|
||||||
|
|
||||||
const url = result?.url;
|
|
||||||
Assert.equal(
|
|
||||||
url,
|
|
||||||
'https://example.com/1',
|
|
||||||
`Should have the found result '${url}' in the expected list of entries`
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
result?.title,
|
|
||||||
customLabel,
|
|
||||||
`Should have the found result '${result?.title}' in the expected list of entries`
|
|
||||||
);
|
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
|
||||||
await promise;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -11,27 +11,20 @@ add_task(async function test_Changed_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(tab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
resolvePromise();
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
ok(tab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
resolvePromise();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,20 +15,13 @@ add_task(async function test_Unload_NoReset_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(tab.closing, 'The tab should be closing after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(tab.closing, 'The tab should be closing after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,38 +12,24 @@ add_task(async function test_Create_Pinned() {
|
|||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
const newTab = gBrowser.selectedTab;
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
try {
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.url,
|
|
||||||
'https://example.com/',
|
|
||||||
'The pin object should have the correct URL'
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.workspaceUuid,
|
|
||||||
gZenWorkspaces.activeWorkspace,
|
|
||||||
'The pin object should have the correct workspace UUID'
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
ok(false, 'Error while checking the pin object in ZenPinnedTabsStorage: ' + error);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
gBrowser.pinTab(newTab);
|
||||||
|
|
||||||
|
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pinObject = newTab.__zenPinnedInitialState;
|
||||||
|
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
|
||||||
|
Assert.equal(
|
||||||
|
pinObject.entry.url,
|
||||||
|
'https://example.com/',
|
||||||
|
'The pin object should have the correct URL'
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
ok(false, 'Error while checking the pin object in ZenPinnedTabsStorage: ' + error);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvePromise();
|
||||||
|
|
||||||
await promise;
|
await promise;
|
||||||
await BrowserTestUtils.removeTab(newTab);
|
await BrowserTestUtils.removeTab(newTab);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
add_task(async function test_Create_Pinned() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const customLabel = 'Test Label';
|
|
||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/' }, async (browser) => {
|
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(tab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
await gZenPinnedTabManager.updatePinTitle(tab, customLabel, true);
|
|
||||||
|
|
||||||
const pinnedTabs = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pinnedTabs.find((pin) => pin.uuid === pinTabID);
|
|
||||||
Assert.equal(pinObject.title, customLabel, 'The pin object should have the correct title');
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.url,
|
|
||||||
'https://example.com/',
|
|
||||||
'The pin object should have the correct URL'
|
|
||||||
);
|
|
||||||
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
|
||||||
await promise;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -15,37 +15,26 @@ add_task(async function test_NoUnload_Changed_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should not have a zen-pinned-changed attribute after being closed'
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('discarded'),
|
|
||||||
'The tab should not be discarded after being closed'
|
|
||||||
);
|
|
||||||
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
!tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should not have a zen-pinned-changed attribute after being closed'
|
||||||
|
);
|
||||||
|
ok(!tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
||||||
|
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
add_task(async function test_Remove_Pinned() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabRemoved',
|
|
||||||
async function (event) {
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
ok(
|
|
||||||
!pinObject,
|
|
||||||
'The pin object should not exist in the ZenPinnedTabsStorage after removal'
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!newTab.hasAttribute('zen-pin-id'),
|
|
||||||
'The tab should not have a zen-pin-id attribute after removal'
|
|
||||||
);
|
|
||||||
ok(!newTab.pinned, 'The tab should not be pinned after removal');
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.unpinTab(newTab);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
await BrowserTestUtils.removeTab(newTab);
|
|
||||||
});
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
add_task(async function test_Pinned_Reorder_Changed_Label() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const tabsToRemove = [];
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
gBrowser.pinTab(gBrowser.selectedTab);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
|
|
||||||
const customLabel = 'Test Label';
|
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
await gZenPinnedTabManager.updatePinTitle(newTab, customLabel, true);
|
|
||||||
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabMoved',
|
|
||||||
async function (event) {
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.title,
|
|
||||||
customLabel,
|
|
||||||
'The pin object should have the correct title'
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.position,
|
|
||||||
2,
|
|
||||||
'The pin object should have the correct position after moving'
|
|
||||||
);
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.moveTabTo(newTab, { tabIndex: 2 });
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
for (const tab of tabsToRemove) {
|
|
||||||
await BrowserTestUtils.removeTab(tab);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_Pinned_Reorder_Changed_Label() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const tabsToRemove = [];
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
gBrowser.pinTab(gBrowser.selectedTab);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
|
|
||||||
const customLabel = 'Test Label';
|
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabMoved',
|
|
||||||
async function (event) {
|
|
||||||
await gZenPinnedTabManager.updatePinTitle(newTab, customLabel, true);
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.title,
|
|
||||||
customLabel,
|
|
||||||
'The pin object should have the correct title'
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.position,
|
|
||||||
1,
|
|
||||||
'The pin object should have the correct position after moving'
|
|
||||||
);
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.moveTabTo(newTab, { tabIndex: 1 });
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
for (const tab of tabsToRemove) {
|
|
||||||
await BrowserTestUtils.removeTab(tab);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
add_task(async function test_Create_Pinned() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const tabsToRemove = [];
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
gBrowser.pinTab(gBrowser.selectedTab);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
const startIndex = pinObject.position;
|
|
||||||
Assert.greater(startIndex, 0, 'The pin object should have the correct start index');
|
|
||||||
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
for (const tab of tabsToRemove) {
|
|
||||||
await BrowserTestUtils.removeTab(tab);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_Create_Pinned() {
|
|
||||||
let resolvePromise;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolvePromise = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const tabsToRemove = [];
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
gBrowser.pinTab(gBrowser.selectedTab);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
|
||||||
tabsToRemove.push(gBrowser.selectedTab);
|
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabMoved',
|
|
||||||
async function (event) {
|
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
|
||||||
Assert.equal(
|
|
||||||
pinObject.position,
|
|
||||||
0,
|
|
||||||
'The pin object should have the correct position after moving'
|
|
||||||
);
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.moveTabTo(newTab, { tabIndex: 0 });
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
for (const tab of tabsToRemove) {
|
|
||||||
await BrowserTestUtils.removeTab(tab);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -15,37 +15,26 @@ add_task(async function test_Unload_NoReset_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should not have a zen-pinned-changed attribute after being closed'
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('discarded'),
|
|
||||||
'The tab should not be discarded after being closed'
|
|
||||||
);
|
|
||||||
ok(tab === gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
!tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should not have a zen-pinned-changed attribute after being closed'
|
||||||
|
);
|
||||||
|
ok(!tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
||||||
|
ok(tab === gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,37 +15,26 @@ add_task(async function test_Unload_NoReset_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should not have a zen-pinned-changed attribute after being closed'
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('discarded'),
|
|
||||||
'The tab should not be discarded after being closed'
|
|
||||||
);
|
|
||||||
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should not have a zen-pinned-changed attribute after being closed'
|
||||||
|
);
|
||||||
|
ok(!tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
||||||
|
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,26 +12,18 @@ add_task(async function test_Pinned_To_Essential() {
|
|||||||
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
const newTab = gBrowser.selectedTab;
|
||||||
newTab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
gZenPinnedTabManager.addToEssentials(newTab);
|
|
||||||
ok(
|
|
||||||
newTab.hasAttribute('zen-essential') && newTab.parentNode.getAttribute('container') == '0',
|
|
||||||
'New tab should be marked as essential.'
|
|
||||||
);
|
|
||||||
|
|
||||||
resolvePromise();
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(newTab);
|
gBrowser.pinTab(newTab);
|
||||||
|
|
||||||
|
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
||||||
|
|
||||||
|
gZenPinnedTabManager.addToEssentials(newTab);
|
||||||
|
ok(
|
||||||
|
newTab.hasAttribute('zen-essential') && newTab.parentNode.getAttribute('container') == '0',
|
||||||
|
'New tab should be marked as essential.'
|
||||||
|
);
|
||||||
|
|
||||||
|
resolvePromise();
|
||||||
|
|
||||||
await promise;
|
await promise;
|
||||||
await BrowserTestUtils.removeTab(newTab);
|
await BrowserTestUtils.removeTab(newTab);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,35 +15,27 @@ add_task(async function test_Unload_Changed_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
!tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should not have a zen-pinned-changed attribute after being closed'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
|
||||||
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
!tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should not have a zen-pinned-changed attribute after being closed'
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
||||||
|
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,34 +15,26 @@ add_task(async function test_Unload_NoReset_Pinned() {
|
|||||||
|
|
||||||
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
tab.addEventListener(
|
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
const pinTabID = tab.getAttribute('zen-pin-id');
|
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
|
||||||
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should have a zen-pinned-changed attribute after being pinned'
|
|
||||||
);
|
|
||||||
document.getElementById('cmd_close').doCommand();
|
|
||||||
setTimeout(() => {
|
|
||||||
ok(
|
|
||||||
tab.hasAttribute('zen-pinned-changed'),
|
|
||||||
'The tab should not have a zen-pinned-changed attribute after being closed'
|
|
||||||
);
|
|
||||||
ok(tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
|
||||||
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
|
||||||
resolvePromise();
|
|
||||||
}, 100);
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
|
|
||||||
|
BrowserTestUtils.startLoadingURIString(browser, 'https://example.com/2');
|
||||||
|
await BrowserTestUtils.browserLoaded(browser, false, 'https://example.com/2');
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should have a zen-pinned-changed attribute after being pinned'
|
||||||
|
);
|
||||||
|
document.getElementById('cmd_close').doCommand();
|
||||||
|
setTimeout(() => {
|
||||||
|
ok(
|
||||||
|
tab.hasAttribute('zen-pinned-changed'),
|
||||||
|
'The tab should not have a zen-pinned-changed attribute after being closed'
|
||||||
|
);
|
||||||
|
ok(tab.hasAttribute('discarded'), 'The tab should not be discarded after being closed');
|
||||||
|
ok(tab != gBrowser.selectedTab, 'The tab should not be selected after being closed');
|
||||||
|
resolvePromise();
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,36 +11,29 @@ add_task(async function test_Private_Mode_No_Essentials() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const newTab = gBrowser.selectedTab;
|
const newTab = gBrowser.selectedTab;
|
||||||
newTab.addEventListener(
|
gBrowser.pinTab(newTab);
|
||||||
'ZenPinnedTabCreated',
|
|
||||||
async function (event) {
|
|
||||||
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
|
||||||
|
|
||||||
const pinTabID = newTab.getAttribute('zen-pin-id');
|
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
|
||||||
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const pins = await ZenPinnedTabsStorage.getPins();
|
const pins = await ZenPinnedTabsStorage.getPins();
|
||||||
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
|
||||||
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
|
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
|
||||||
|
|
||||||
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
|
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
|
||||||
private: true,
|
private: true,
|
||||||
});
|
});
|
||||||
await privateWindow.gZenWorkspaces.promiseInitialized;
|
await privateWindow.gZenWorkspaces.promiseInitialized;
|
||||||
ok(
|
ok(
|
||||||
!privateWindow.gBrowser.tabs.some((tab) => tab.pinned),
|
!privateWindow.gBrowser.tabs.some((tab) => tab.pinned),
|
||||||
'Private window should not have any pinned tabs initially'
|
'Private window should not have any pinned tabs initially'
|
||||||
);
|
);
|
||||||
|
|
||||||
await BrowserTestUtils.closeWindow(privateWindow);
|
await BrowserTestUtils.closeWindow(privateWindow);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ok(false, 'Error while checking the pin object in ZenPinnedTabsStorage: ' + error);
|
ok(false, 'Error while checking the pin object in ZenPinnedTabsStorage: ' + error);
|
||||||
}
|
}
|
||||||
resolvePromise();
|
resolvePromise();
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
gZenPinnedTabManager.addToEssentials(newTab);
|
gZenPinnedTabManager.addToEssentials(newTab);
|
||||||
|
|
||||||
await promise;
|
await promise;
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ add_task(async function test_Welcome_Steps() {
|
|||||||
);
|
);
|
||||||
Assert.equal(tab.group, group, 'Pinned tabs should belong to the first tab group');
|
Assert.equal(tab.group, group, 'Pinned tabs should belong to the first tab group');
|
||||||
}
|
}
|
||||||
ok(tab.hasAttribute('zen-pin-id'), 'Pinned tabs should have a zen-pin-id attribute');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group.delete();
|
group.delete();
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ add_task(async function test_Check_Creation() {
|
|||||||
const currentWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
const currentWorkspaceUUID = gZenWorkspaces.activeWorkspace;
|
||||||
await gZenWorkspaces.createAndSaveWorkspace('Test Workspace 2');
|
await gZenWorkspaces.createAndSaveWorkspace('Test Workspace 2');
|
||||||
const workspaces = await gZenWorkspaces._workspaces();
|
const workspaces = await gZenWorkspaces._workspaces();
|
||||||
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
|
ok(workspaces.length === 2, 'Two workspaces should exist.');
|
||||||
ok(
|
ok(
|
||||||
currentWorkspaceUUID !== workspaces.workspaces[1].uuid,
|
currentWorkspaceUUID !== workspaces[1].uuid,
|
||||||
'The new workspace should be different from the current one.'
|
'The new workspace should be different from the current one.'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ add_task(async function test_Check_Creation() {
|
|||||||
const workspacesAfterRemove = await gZenWorkspaces._workspaces();
|
const workspacesAfterRemove = await gZenWorkspaces._workspaces();
|
||||||
ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.');
|
ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.');
|
||||||
ok(
|
ok(
|
||||||
workspacesAfterRemove.workspaces[0].uuid === currentWorkspaceUUID,
|
workspacesAfterRemove[0].uuid === currentWorkspaceUUID,
|
||||||
'The workspace should be the one we started with.'
|
'The workspace should be the one we started with.'
|
||||||
);
|
);
|
||||||
ok(gBrowser.tabs.length === 2, 'There should be one tab.');
|
ok(gBrowser.tabs.length === 2, 'There should be one tab.');
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ add_task(async function test_Change_To_Empty() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const workspacesAfterRemove = await gZenWorkspaces._workspaces();
|
const workspacesAfterRemove = await gZenWorkspaces._workspaces();
|
||||||
ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.');
|
ok(workspacesAfterRemove.length === 1, 'One workspace should exist.');
|
||||||
ok(gBrowser.tabs.length === 2, 'There should be two tabs.');
|
ok(gBrowser.tabs.length === 2, 'There should be two tabs.');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ add_task(async function test_workspace_bookmark() {
|
|||||||
await withBookmarksShowing(async () => {
|
await withBookmarksShowing(async () => {
|
||||||
await gZenWorkspaces.createAndSaveWorkspace('Test Workspace 2');
|
await gZenWorkspaces.createAndSaveWorkspace('Test Workspace 2');
|
||||||
const workspaces = await gZenWorkspaces._workspaces();
|
const workspaces = await gZenWorkspaces._workspaces();
|
||||||
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
|
ok(workspaces.length === 2, 'Two workspaces should exist.');
|
||||||
const firstWorkspace = workspaces.workspaces[0];
|
const firstWorkspace = workspaces[0];
|
||||||
const secondWorkspace = workspaces.workspaces[1];
|
const secondWorkspace = workspaces[1];
|
||||||
ok(
|
ok(
|
||||||
firstWorkspace.uuid !== secondWorkspace.uuid,
|
firstWorkspace.uuid !== secondWorkspace.uuid,
|
||||||
'The new workspace should be different from the current one.'
|
'The new workspace should be different from the current one.'
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const globalActionsTemplate = [
|
|||||||
command: 'cmd_zenWorkspaceForward',
|
command: 'cmd_zenWorkspaceForward',
|
||||||
icon: 'chrome://browser/skin/zen-icons/forward.svg',
|
icon: 'chrome://browser/skin/zen-icons/forward.svg',
|
||||||
isAvailable: (window) => {
|
isAvailable: (window) => {
|
||||||
return window.gZenWorkspaces._workspaceCache.workspaces.length > 1;
|
return window.gZenWorkspaces._workspaceCache.length > 1;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ const globalActionsTemplate = [
|
|||||||
icon: 'chrome://browser/skin/zen-icons/back.svg',
|
icon: 'chrome://browser/skin/zen-icons/back.svg',
|
||||||
isAvailable: (window) => {
|
isAvailable: (window) => {
|
||||||
// This also covers the case of being in private mode
|
// This also covers the case of being in private mode
|
||||||
return window.gZenWorkspaces._workspaceCache.workspaces.length > 1;
|
return window.gZenWorkspaces._workspaceCache.length > 1;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,9 +292,6 @@
|
|||||||
for (const tab of _tabsToPin) {
|
for (const tab of _tabsToPin) {
|
||||||
tab.setAttribute('zen-workspace-id', gZenWorkspaces.activeWorkspace);
|
tab.setAttribute('zen-workspace-id', gZenWorkspaces.activeWorkspace);
|
||||||
gBrowser.pinTab(tab);
|
gBrowser.pinTab(tab);
|
||||||
await new Promise((resolve) => {
|
|
||||||
tab.addEventListener('ZenPinnedTabCreated', resolve, { once: true });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
for (const tab of _tabsToPinEssentials) {
|
for (const tab of _tabsToPinEssentials) {
|
||||||
tab.removeAttribute('pending'); // Make it appear loaded
|
tab.removeAttribute('pending'); // Make it appear loaded
|
||||||
|
|||||||
@@ -1318,7 +1318,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
|||||||
// Use theme from workspace object or passed theme
|
// Use theme from workspace object or passed theme
|
||||||
let workspaceTheme = theme || workspace.theme;
|
let workspaceTheme = theme || workspace.theme;
|
||||||
|
|
||||||
await this.foreachWindowAsActive(async (browser) => {
|
await this.forEachWindow(async (browser) => {
|
||||||
if (!browser.gZenThemePicker?.promiseInitialized) {
|
if (!browser.gZenThemePicker?.promiseInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1332,7 +1332,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do not rebuild if the workspace is not the same as the current one
|
// Do not rebuild if the workspace is not the same as the current one
|
||||||
const windowWorkspace = await browser.gZenWorkspaces.getActiveWorkspace();
|
const windowWorkspace = browser.gZenWorkspaces.getActiveWorkspace();
|
||||||
if (windowWorkspace.uuid !== uuid) {
|
if (windowWorkspace.uuid !== uuid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1630,13 +1630,12 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
const gradient = nsZenThemePicker.getTheme(colors, this.currentOpacity, this.currentTexture);
|
const gradient = nsZenThemePicker.getTheme(colors, this.currentOpacity, this.currentTexture);
|
||||||
let currentWorkspace = await gZenWorkspaces.getActiveWorkspace();
|
let currentWorkspace = gZenWorkspaces.getActiveWorkspace();
|
||||||
|
|
||||||
if (!skipSave) {
|
if (!skipSave) {
|
||||||
await ZenWorkspacesStorage.saveWorkspaceTheme(currentWorkspace.uuid, gradient);
|
currentWorkspace.theme = gradient;
|
||||||
await gZenWorkspaces._propagateWorkspaceData();
|
gZenWorkspaces.saveWorkspace(currentWorkspace);
|
||||||
gZenUIManager.showToast('zen-panel-ui-gradient-generator-saved-message');
|
gZenUIManager.showToast('zen-panel-ui-gradient-generator-saved-message');
|
||||||
currentWorkspace = await gZenWorkspaces.getActiveWorkspace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.onWorkspaceChange(currentWorkspace, skipSave, skipSave ? gradient : null);
|
await this.onWorkspaceChange(currentWorkspace, skipSave, skipSave ? gradient : null);
|
||||||
@@ -1691,7 +1690,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature {
|
|||||||
|
|
||||||
invalidateGradientCache() {
|
invalidateGradientCache() {
|
||||||
this.#gradientsCache = {};
|
this.#gradientsCache = {};
|
||||||
window.dispatchEvent(new Event('ZenGradientCacheChanged'));
|
window.dispatchEvent(new Event('ZenGradientCacheChanged', { bubbles: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
getGradientForWorkspace(workspace) {
|
getGradientForWorkspace(workspace) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
class nsZenWorkspace extends MozXULElement {
|
class nsZenWorkspace extends MozXULElement {
|
||||||
static get markup() {
|
static get markup() {
|
||||||
return `
|
return `
|
||||||
<vbox class="zen-workspace-tabs-section zen-current-workspace-indicator" flex="1" context="zenWorkspaceMoreActions">
|
<vbox class="zen-workspace-tabs-section zen-current-workspace-indicator zen-drop-target" flex="1" context="zenWorkspaceMoreActions">
|
||||||
<hbox class="zen-current-workspace-indicator-icon" />
|
<hbox class="zen-current-workspace-indicator-icon" />
|
||||||
<label class="zen-current-workspace-indicator-name" flex="1" />
|
<label class="zen-current-workspace-indicator-name" flex="1" />
|
||||||
<toolbarbutton class="toolbarbutton-1 chromeclass-toolbar-additional zen-workspaces-actions" context="zenWorkspaceMoreActions" />
|
<toolbarbutton class="toolbarbutton-1 chromeclass-toolbar-additional zen-workspaces-actions" context="zenWorkspaceMoreActions" />
|
||||||
@@ -37,6 +37,14 @@ class nsZenWorkspace extends MozXULElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get moveTabToButtonMarkup() {
|
||||||
|
return `
|
||||||
|
<toolbarbutton class="toolbarbutton-1 chromeclass-toolbar-additional zen-workspaces-actions"
|
||||||
|
tooltip="dynamic-shortcut-tooltip"
|
||||||
|
data-l10n-id="zen-move-tab-to-workspace-button" />
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
static get inheritedAttributes() {
|
static get inheritedAttributes() {
|
||||||
return {
|
return {
|
||||||
'.zen-workspace-tabs-section': 'zen-workspace-id=id',
|
'.zen-workspace-tabs-section': 'zen-workspace-id=id',
|
||||||
@@ -88,6 +96,20 @@ class nsZenWorkspace extends MozXULElement {
|
|||||||
gZenWorkspaces.changeWorkspaceIcon();
|
gZenWorkspaces.changeWorkspaceIcon();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!gZenWorkspaces.currentWindowIsSyncing) {
|
||||||
|
let actionsButton = this.indicator.querySelector('.zen-workspaces-actions');
|
||||||
|
const moveTabToFragment = window.MozXULElement.parseXULToFragment(
|
||||||
|
nsZenWorkspace.moveTabToButtonMarkup
|
||||||
|
);
|
||||||
|
actionsButton.after(moveTabToFragment);
|
||||||
|
actionsButton.setAttribute('hidden', 'true');
|
||||||
|
actionsButton = actionsButton.nextElementSibling;
|
||||||
|
actionsButton.addEventListener('command', (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
this.#openMoveTabsToWorkspacePanel(event.target);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.scrollbox._getScrollableElements = () => {
|
this.scrollbox._getScrollableElements = () => {
|
||||||
const children = [...this.pinnedTabsContainer.children, ...this.tabsContainer.children];
|
const children = [...this.pinnedTabsContainer.children, ...this.tabsContainer.children];
|
||||||
if (Services.prefs.getBoolPref('zen.view.show-newtab-button-top', false)) {
|
if (Services.prefs.getBoolPref('zen.view.show-newtab-button-top', false)) {
|
||||||
@@ -209,7 +231,7 @@ class nsZenWorkspace extends MozXULElement {
|
|||||||
if (newName === '') {
|
if (newName === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let workspaces = (await gZenWorkspaces._workspaces()).workspaces;
|
let workspaces = gZenWorkspaces.getWorkspaces();
|
||||||
let workspaceData = workspaces.find((workspace) => workspace.uuid === this.workspaceUuid);
|
let workspaceData = workspaces.find((workspace) => workspace.uuid === this.workspaceUuid);
|
||||||
workspaceData.name = newName;
|
workspaceData.name = newName;
|
||||||
await gZenWorkspaces.saveWorkspace(workspaceData);
|
await gZenWorkspaces.saveWorkspace(workspaceData);
|
||||||
@@ -256,6 +278,36 @@ class nsZenWorkspace extends MozXULElement {
|
|||||||
this.style.removeProperty('--toolbox-textcolor');
|
this.style.removeProperty('--toolbox-textcolor');
|
||||||
this.style.removeProperty('--zen-primary-color');
|
this.style.removeProperty('--zen-primary-color');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#openMoveTabsToWorkspacePanel(button) {
|
||||||
|
button = button.closest('toolbarbutton');
|
||||||
|
if (!button) return;
|
||||||
|
|
||||||
|
const popup = document.getElementById('zenMoveTabsToSyncedWorkspacePopup');
|
||||||
|
popup.innerHTML = '';
|
||||||
|
|
||||||
|
const workspaces = gZenWorkspaces.getWorkspaces(true);
|
||||||
|
for (const workspace of workspaces) {
|
||||||
|
const item = gZenWorkspaces.generateMenuItemForWorkspace(workspace);
|
||||||
|
item.addEventListener('command', async () => {
|
||||||
|
const { ZenWindowSync } = ChromeUtils.importESModule(
|
||||||
|
'resource:///modules/zen/ZenWindowSync.sys.mjs'
|
||||||
|
);
|
||||||
|
ZenWindowSync.moveTabsToSyncedWorkspace(window, workspace.uuid);
|
||||||
|
});
|
||||||
|
popup.appendChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.setAttribute('open', 'true');
|
||||||
|
popup.addEventListener(
|
||||||
|
'popuphidden',
|
||||||
|
() => {
|
||||||
|
button.removeAttribute('open');
|
||||||
|
},
|
||||||
|
{ once: true }
|
||||||
|
);
|
||||||
|
popup.openPopup(button, 'after_start', 0, 0, true /* isContextMenu */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('zen-workspace', nsZenWorkspace);
|
customElements.define('zen-workspace', nsZenWorkspace);
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class nsZenWorkspaceCreation extends MozXULElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onCreateButtonCommand() {
|
async onCreateButtonCommand() {
|
||||||
const workspace = await gZenWorkspaces.getActiveWorkspace();
|
const workspace = gZenWorkspaces.getActiveWorkspace();
|
||||||
workspace.name = this.inputName.value.trim();
|
workspace.name = this.inputName.value.trim();
|
||||||
workspace.icon = this.inputIcon.image || this.inputIcon.label || undefined;
|
workspace.icon = this.inputIcon.image || this.inputIcon.label || undefined;
|
||||||
workspace.containerTabId = this.currentProfile;
|
workspace.containerTabId = this.currentProfile;
|
||||||
@@ -320,8 +320,8 @@ class nsZenWorkspaceCreation extends MozXULElement {
|
|||||||
this.remove();
|
this.remove();
|
||||||
gZenUIManager.updateTabsToolbar();
|
gZenUIManager.updateTabsToolbar();
|
||||||
|
|
||||||
const workspace = await gZenWorkspaces.getActiveWorkspace();
|
const workspace = gZenWorkspaces.getActiveWorkspace();
|
||||||
await gZenWorkspaces._organizeWorkspaceStripLocations(workspace, true);
|
await gZenWorkspaces._organizeWorkspaceStripLocations(workspace);
|
||||||
await gZenWorkspaces.updateTabsContainers();
|
await gZenWorkspaces.updateTabsContainers();
|
||||||
|
|
||||||
await gZenUIManager.motion.animate(
|
await gZenUIManager.motion.animate(
|
||||||
|
|||||||
@@ -126,13 +126,13 @@ class nsZenWorkspaceIcons extends MozXULElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async #updateIcons() {
|
async #updateIcons() {
|
||||||
const workspaces = await gZenWorkspaces._workspaces();
|
const workspaces = gZenWorkspaces.getWorkspaces();
|
||||||
this.innerHTML = '';
|
this.innerHTML = '';
|
||||||
for (const workspace of workspaces.workspaces) {
|
for (const workspace of workspaces) {
|
||||||
const button = this.#createWorkspaceIcon(workspace);
|
const button = this.#createWorkspaceIcon(workspace);
|
||||||
this.appendChild(button);
|
this.appendChild(button);
|
||||||
}
|
}
|
||||||
if (workspaces.workspaces.length <= 1) {
|
if (workspaces.length <= 1) {
|
||||||
this.setAttribute('dont-show', 'true');
|
this.setAttribute('dont-show', 'true');
|
||||||
} else {
|
} else {
|
||||||
this.removeAttribute('dont-show');
|
this.removeAttribute('dont-show');
|
||||||
@@ -168,6 +168,9 @@ class nsZenWorkspaceIcons extends MozXULElement {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (selected == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buttons[selected].setAttribute('active', true);
|
buttons[selected].setAttribute('active', true);
|
||||||
this.scrollLeft = buttons[selected].offsetLeft - 10;
|
this.scrollLeft = buttons[selected].offsetLeft - 10;
|
||||||
this.setAttribute('selected', selected);
|
this.setAttribute('selected', selected);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -2,437 +2,20 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
window.ZenWorkspacesStorage = {
|
// Integration of workspace-specific bookmarks into Places
|
||||||
|
window.ZenWorkspaceBookmarksStorage = {
|
||||||
lazy: {},
|
lazy: {},
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
ChromeUtils.defineESModuleGetters(this.lazy, {
|
ChromeUtils.defineESModuleGetters(this.lazy, {
|
||||||
PlacesUtils: 'resource://gre/modules/PlacesUtils.sys.mjs',
|
PlacesUtils: 'resource://gre/modules/PlacesUtils.sys.mjs',
|
||||||
Weave: 'resource://services-sync/main.sys.mjs',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!window.gZenWorkspaces) return;
|
if (!window.gZenWorkspaces) return;
|
||||||
await this._ensureTable();
|
await this._ensureTable();
|
||||||
await ZenWorkspaceBookmarksStorage.init();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _ensureTable() {
|
async _ensureTable() {
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
await this.lazy.PlacesUtils.withConnectionWrapper(
|
||||||
'ZenWorkspacesStorage._ensureTable',
|
|
||||||
async (db) => {
|
|
||||||
// Create the main workspaces table if it doesn't exist
|
|
||||||
await db.execute(`
|
|
||||||
CREATE TABLE IF NOT EXISTS zen_workspaces (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
uuid TEXT UNIQUE NOT NULL,
|
|
||||||
name TEXT NOT NULL,
|
|
||||||
icon TEXT,
|
|
||||||
container_id INTEGER,
|
|
||||||
position INTEGER NOT NULL DEFAULT 0,
|
|
||||||
created_at INTEGER NOT NULL,
|
|
||||||
updated_at INTEGER NOT NULL
|
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
// Add new columns if they don't exist
|
|
||||||
// SQLite doesn't have a direct "ADD COLUMN IF NOT EXISTS" syntax,
|
|
||||||
// so we need to check if the columns exist first
|
|
||||||
const columns = await db.execute(`PRAGMA table_info(zen_workspaces)`);
|
|
||||||
const columnNames = columns.map((row) => row.getResultByName('name'));
|
|
||||||
|
|
||||||
// Helper function to add column if it doesn't exist
|
|
||||||
const addColumnIfNotExists = async (columnName, definition) => {
|
|
||||||
if (!columnNames.includes(columnName)) {
|
|
||||||
await db.execute(`ALTER TABLE zen_workspaces ADD COLUMN ${columnName} ${definition}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add each new column if it doesn't exist
|
|
||||||
await addColumnIfNotExists('theme_type', 'TEXT');
|
|
||||||
await addColumnIfNotExists('theme_colors', 'TEXT');
|
|
||||||
await addColumnIfNotExists('theme_opacity', 'REAL');
|
|
||||||
await addColumnIfNotExists('theme_rotation', 'INTEGER');
|
|
||||||
await addColumnIfNotExists('theme_texture', 'REAL');
|
|
||||||
|
|
||||||
// Create an index on the uuid column
|
|
||||||
await db.execute(`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_zen_workspaces_uuid ON zen_workspaces(uuid)
|
|
||||||
`);
|
|
||||||
|
|
||||||
// Create the changes tracking table if it doesn't exist
|
|
||||||
await db.execute(`
|
|
||||||
CREATE TABLE IF NOT EXISTS zen_workspaces_changes (
|
|
||||||
uuid TEXT PRIMARY KEY,
|
|
||||||
timestamp INTEGER NOT NULL
|
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
// Create an index on the uuid column for changes tracking table
|
|
||||||
await db.execute(`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_zen_workspaces_changes_uuid ON zen_workspaces_changes(uuid)
|
|
||||||
`);
|
|
||||||
|
|
||||||
if (!this.lazy.Weave.Service.engineManager.get('workspaces')) {
|
|
||||||
this.lazy.Weave.Service.engineManager.register(ZenWorkspacesEngine);
|
|
||||||
await ZenWorkspacesStorage.migrateWorkspacesFromJSON();
|
|
||||||
}
|
|
||||||
|
|
||||||
gZenWorkspaces._resolveDBInitialized();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async migrateWorkspacesFromJSON() {
|
|
||||||
const oldWorkspacesPath = PathUtils.join(
|
|
||||||
PathUtils.profileDir,
|
|
||||||
'zen-workspaces',
|
|
||||||
'Workspaces.json'
|
|
||||||
);
|
|
||||||
if (await IOUtils.exists(oldWorkspacesPath)) {
|
|
||||||
console.info('ZenWorkspacesStorage: Migrating workspaces from JSON...');
|
|
||||||
const oldWorkspaces = await IOUtils.readJSON(oldWorkspacesPath);
|
|
||||||
if (oldWorkspaces.workspaces) {
|
|
||||||
for (const workspace of oldWorkspaces.workspaces) {
|
|
||||||
await this.saveWorkspace(workspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await IOUtils.remove(oldWorkspacesPath);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private helper method to notify observers with a list of changed UUIDs.
|
|
||||||
* @param {string} event - The observer event name.
|
|
||||||
* @param {Array<string>} uuids - Array of changed workspace UUIDs.
|
|
||||||
*/
|
|
||||||
_notifyWorkspacesChanged(event, uuids) {
|
|
||||||
if (uuids.length === 0) return; // No changes to notify
|
|
||||||
|
|
||||||
// Convert the array of UUIDs to a JSON string
|
|
||||||
const data = JSON.stringify(uuids);
|
|
||||||
|
|
||||||
Services.obs.notifyObservers(null, event, data);
|
|
||||||
},
|
|
||||||
|
|
||||||
async saveWorkspace(workspace, notifyObservers = true) {
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.saveWorkspace',
|
|
||||||
async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
let newPosition;
|
|
||||||
if ('position' in workspace && Number.isFinite(workspace.position)) {
|
|
||||||
newPosition = workspace.position;
|
|
||||||
} else {
|
|
||||||
// Get the maximum position
|
|
||||||
const maxPositionResult = await db.execute(
|
|
||||||
`SELECT MAX("position") as max_position FROM zen_workspaces`
|
|
||||||
);
|
|
||||||
const maxPosition = maxPositionResult[0].getResultByName('max_position') || 0;
|
|
||||||
newPosition = maxPosition + 1000; // Add a large increment to avoid frequent reordering
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert or replace the workspace
|
|
||||||
await db.executeCached(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_workspaces (
|
|
||||||
uuid, name, icon, container_id, created_at, updated_at, "position",
|
|
||||||
theme_type, theme_colors, theme_opacity, theme_rotation, theme_texture
|
|
||||||
) VALUES (
|
|
||||||
:uuid, :name, :icon, :container_id,
|
|
||||||
COALESCE((SELECT created_at FROM zen_workspaces WHERE uuid = :uuid), :now),
|
|
||||||
:now,
|
|
||||||
:position,
|
|
||||||
:theme_type, :theme_colors, :theme_opacity, :theme_rotation, :theme_texture
|
|
||||||
)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: workspace.uuid,
|
|
||||||
name: workspace.name,
|
|
||||||
icon: workspace.icon || null,
|
|
||||||
container_id: workspace.containerTabId || null,
|
|
||||||
now,
|
|
||||||
position: newPosition,
|
|
||||||
theme_type: workspace.theme?.type || null,
|
|
||||||
theme_colors: workspace.theme ? JSON.stringify(workspace.theme.gradientColors) : null,
|
|
||||||
theme_opacity: workspace.theme?.opacity || null,
|
|
||||||
theme_rotation: workspace.theme?.rotation || null,
|
|
||||||
theme_texture: workspace.theme?.texture || null,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the change
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_workspaces_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: workspace.uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(workspace.uuid);
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyWorkspacesChanged('zen-workspace-updated', Array.from(changedUUIDs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async getWorkspaces() {
|
|
||||||
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
|
||||||
const rows = await db.executeCached(`
|
|
||||||
SELECT * FROM zen_workspaces ORDER BY created_at ASC
|
|
||||||
`);
|
|
||||||
return rows.map((row) => ({
|
|
||||||
uuid: row.getResultByName('uuid'),
|
|
||||||
name: row.getResultByName('name'),
|
|
||||||
icon: row.getResultByName('icon'),
|
|
||||||
containerTabId: row.getResultByName('container_id') ?? 0,
|
|
||||||
position: row.getResultByName('position'),
|
|
||||||
theme: row.getResultByName('theme_type')
|
|
||||||
? {
|
|
||||||
type: row.getResultByName('theme_type'),
|
|
||||||
gradientColors: JSON.parse(row.getResultByName('theme_colors')),
|
|
||||||
opacity: row.getResultByName('theme_opacity'),
|
|
||||||
rotation: row.getResultByName('theme_rotation'),
|
|
||||||
texture: row.getResultByName('theme_texture'),
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
async removeWorkspace(uuid, notifyObservers = true) {
|
|
||||||
const changedUUIDs = [uuid];
|
|
||||||
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.removeWorkspace',
|
|
||||||
async (db) => {
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
DELETE FROM zen_workspaces WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{ uuid }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the removal as a change
|
|
||||||
const now = Date.now();
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_workspaces_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyWorkspacesChanged('zen-workspace-removed', changedUUIDs);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async wipeAllWorkspaces() {
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.wipeAllWorkspaces',
|
|
||||||
async (db) => {
|
|
||||||
await db.execute(`DELETE FROM zen_workspaces`);
|
|
||||||
await db.execute(`DELETE FROM zen_workspaces_changes`);
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async markChanged(uuid) {
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.markChanged',
|
|
||||||
async (db) => {
|
|
||||||
const now = Date.now();
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_workspaces_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async saveWorkspaceTheme(uuid, theme, notifyObservers = true) {
|
|
||||||
const changedUUIDs = [uuid];
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper('saveWorkspaceTheme', async (db) => {
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_workspaces
|
|
||||||
SET
|
|
||||||
theme_type = :type,
|
|
||||||
theme_colors = :colors,
|
|
||||||
theme_opacity = :opacity,
|
|
||||||
theme_rotation = :rotation,
|
|
||||||
theme_texture = :texture,
|
|
||||||
updated_at = :now
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
type: theme.type,
|
|
||||||
colors: JSON.stringify(theme.gradientColors),
|
|
||||||
opacity: theme.opacity,
|
|
||||||
rotation: theme.rotation,
|
|
||||||
texture: theme.texture,
|
|
||||||
now: Date.now(),
|
|
||||||
uuid,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.markChanged(uuid);
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notifyObservers) {
|
|
||||||
this._notifyWorkspacesChanged('zen-workspace-updated', changedUUIDs);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async getChangedIDs() {
|
|
||||||
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
|
||||||
const rows = await db.execute(`
|
|
||||||
SELECT uuid, timestamp FROM zen_workspaces_changes
|
|
||||||
`);
|
|
||||||
const changes = {};
|
|
||||||
for (const row of rows) {
|
|
||||||
changes[row.getResultByName('uuid')] = row.getResultByName('timestamp');
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
},
|
|
||||||
|
|
||||||
async clearChangedIDs() {
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.clearChangedIDs',
|
|
||||||
async (db) => {
|
|
||||||
await db.execute(`DELETE FROM zen_workspaces_changes`);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
shouldReorderWorkspaces(before, current, after) {
|
|
||||||
const minGap = 1; // Minimum allowed gap between positions
|
|
||||||
return (
|
|
||||||
(before !== null && current - before < minGap) || (after !== null && after - current < minGap)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async reorderAllWorkspaces(db, changedUUIDs) {
|
|
||||||
const workspaces = await db.execute(`
|
|
||||||
SELECT uuid
|
|
||||||
FROM zen_workspaces
|
|
||||||
ORDER BY "position" ASC
|
|
||||||
`);
|
|
||||||
|
|
||||||
for (let i = 0; i < workspaces.length; i++) {
|
|
||||||
const newPosition = (i + 1) * 1000; // Use large increments
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_workspaces
|
|
||||||
SET "position" = :newPosition
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{ newPosition, uuid: workspaces[i].getResultByName('uuid') }
|
|
||||||
);
|
|
||||||
changedUUIDs.add(workspaces[i].getResultByName('uuid'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async updateLastChangeTimestamp(db) {
|
|
||||||
const now = Date.now();
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO moz_meta (key, value)
|
|
||||||
VALUES ('zen_workspaces_last_change', :now)
|
|
||||||
`,
|
|
||||||
{ now }
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
async getLastChangeTimestamp() {
|
|
||||||
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
|
||||||
const result = await db.executeCached(`
|
|
||||||
SELECT value FROM moz_meta WHERE key = 'zen_workspaces_last_change'
|
|
||||||
`);
|
|
||||||
return result.length ? parseInt(result[0].getResultByName('value'), 10) : 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
async updateWorkspacePositions(workspaces) {
|
|
||||||
const changedUUIDs = new Set();
|
|
||||||
|
|
||||||
await this.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspacesStorage.updateWorkspacePositions',
|
|
||||||
async (db) => {
|
|
||||||
await db.executeTransaction(async () => {
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
for (let i = 0; i < workspaces.length; i++) {
|
|
||||||
const workspace = workspaces[i];
|
|
||||||
const newPosition = (i + 1) * 1000;
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
UPDATE zen_workspaces
|
|
||||||
SET "position" = :newPosition
|
|
||||||
WHERE uuid = :uuid
|
|
||||||
`,
|
|
||||||
{ newPosition, uuid: workspace.uuid }
|
|
||||||
);
|
|
||||||
|
|
||||||
changedUUIDs.add(workspace.uuid);
|
|
||||||
|
|
||||||
// Record the change
|
|
||||||
await db.execute(
|
|
||||||
`
|
|
||||||
INSERT OR REPLACE INTO zen_workspaces_changes (uuid, timestamp)
|
|
||||||
VALUES (:uuid, :timestamp)
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
uuid: workspace.uuid,
|
|
||||||
timestamp: Math.floor(now / 1000),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.updateLastChangeTimestamp(db);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this._notifyWorkspacesChanged('zen-workspace-updated', Array.from(changedUUIDs));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Integration of workspace-specific bookmarks into Places
|
|
||||||
window.ZenWorkspaceBookmarksStorage = {
|
|
||||||
async init() {
|
|
||||||
await this._ensureTable();
|
|
||||||
},
|
|
||||||
|
|
||||||
async _ensureTable() {
|
|
||||||
await ZenWorkspacesStorage.lazy.PlacesUtils.withConnectionWrapper(
|
|
||||||
'ZenWorkspaceBookmarksStorage.init',
|
'ZenWorkspaceBookmarksStorage.init',
|
||||||
async (db) => {
|
async (db) => {
|
||||||
// Create table using GUIDs instead of IDs
|
// Create table using GUIDs instead of IDs
|
||||||
@@ -498,7 +81,7 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
* @returns {Promise<number>} The timestamp of the last change.
|
* @returns {Promise<number>} The timestamp of the last change.
|
||||||
*/
|
*/
|
||||||
async getLastChangeTimestamp() {
|
async getLastChangeTimestamp() {
|
||||||
const db = await ZenWorkspacesStorage.lazy.PlacesUtils.promiseDBConnection();
|
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
||||||
const result = await db.executeCached(`
|
const result = await db.executeCached(`
|
||||||
SELECT value FROM moz_meta WHERE key = 'zen_bookmarks_workspaces_last_change'
|
SELECT value FROM moz_meta WHERE key = 'zen_bookmarks_workspaces_last_change'
|
||||||
`);
|
`);
|
||||||
@@ -506,7 +89,7 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getBookmarkWorkspaces(bookmarkGuid) {
|
async getBookmarkWorkspaces(bookmarkGuid) {
|
||||||
const db = await ZenWorkspacesStorage.lazy.PlacesUtils.promiseDBConnection();
|
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
||||||
|
|
||||||
const rows = await db.execute(
|
const rows = await db.execute(
|
||||||
`
|
`
|
||||||
@@ -531,7 +114,7 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
async getBookmarkGuidsByWorkspace() {
|
async getBookmarkGuidsByWorkspace() {
|
||||||
const db = await ZenWorkspacesStorage.lazy.PlacesUtils.promiseDBConnection();
|
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
||||||
|
|
||||||
const rows = await db.execute(`
|
const rows = await db.execute(`
|
||||||
SELECT workspace_uuid, GROUP_CONCAT(bookmark_guid) as bookmark_guids
|
SELECT workspace_uuid, GROUP_CONCAT(bookmark_guid) as bookmark_guids
|
||||||
@@ -554,7 +137,7 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
* @returns {Promise<Object>} An object mapping bookmark+workspace pairs to their change data.
|
* @returns {Promise<Object>} An object mapping bookmark+workspace pairs to their change data.
|
||||||
*/
|
*/
|
||||||
async getChangedIDs() {
|
async getChangedIDs() {
|
||||||
const db = await ZenWorkspacesStorage.lazy.PlacesUtils.promiseDBConnection();
|
const db = await this.lazy.PlacesUtils.promiseDBConnection();
|
||||||
const rows = await db.execute(`
|
const rows = await db.execute(`
|
||||||
SELECT bookmark_guid, workspace_uuid, change_type, timestamp
|
SELECT bookmark_guid, workspace_uuid, change_type, timestamp
|
||||||
FROM zen_bookmarks_workspaces_changes
|
FROM zen_bookmarks_workspaces_changes
|
||||||
@@ -575,7 +158,7 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
* Clear all recorded changes.
|
* Clear all recorded changes.
|
||||||
*/
|
*/
|
||||||
async clearChangedIDs() {
|
async clearChangedIDs() {
|
||||||
await ZenWorkspacesStorage.lazy.PlacesUtils.withConnectionWrapper(
|
await this.lazy.PlacesUtils.withConnectionWrapper(
|
||||||
'ZenWorkspaceBookmarksStorage.clearChangedIDs',
|
'ZenWorkspaceBookmarksStorage.clearChangedIDs',
|
||||||
async (db) => {
|
async (db) => {
|
||||||
await db.execute(`DELETE FROM zen_bookmarks_workspaces_changes`);
|
await db.execute(`DELETE FROM zen_bookmarks_workspaces_changes`);
|
||||||
@@ -584,4 +167,4 @@ window.ZenWorkspaceBookmarksStorage = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ZenWorkspacesStorage.init();
|
ZenWorkspaceBookmarksStorage.init();
|
||||||
|
|||||||
@@ -1,459 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
var { Tracker, Store, SyncEngine } = ChromeUtils.importESModule(
|
|
||||||
'resource://services-sync/engines.sys.mjs'
|
|
||||||
);
|
|
||||||
var { CryptoWrapper } = ChromeUtils.importESModule('resource://services-sync/record.sys.mjs');
|
|
||||||
var { Utils } = ChromeUtils.importESModule('resource://services-sync/util.sys.mjs');
|
|
||||||
var { SCORE_INCREMENT_XLARGE } = ChromeUtils.importESModule(
|
|
||||||
'resource://services-sync/constants.sys.mjs'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Define ZenWorkspaceRecord
|
|
||||||
function ZenWorkspaceRecord(collection, id) {
|
|
||||||
CryptoWrapper.call(this, collection, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZenWorkspaceRecord.prototype = Object.create(CryptoWrapper.prototype);
|
|
||||||
ZenWorkspaceRecord.prototype.constructor = ZenWorkspaceRecord;
|
|
||||||
|
|
||||||
ZenWorkspaceRecord.prototype._logName = 'Sync.Record.ZenWorkspace';
|
|
||||||
|
|
||||||
Utils.deferGetSet(ZenWorkspaceRecord, 'cleartext', [
|
|
||||||
'name',
|
|
||||||
'icon',
|
|
||||||
'default',
|
|
||||||
'containerTabId',
|
|
||||||
'position',
|
|
||||||
'theme_type',
|
|
||||||
'theme_colors',
|
|
||||||
'theme_opacity',
|
|
||||||
'theme_rotation',
|
|
||||||
'theme_texture',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Define ZenWorkspacesStore
|
|
||||||
function ZenWorkspacesStore(name, engine) {
|
|
||||||
Store.call(this, name, engine);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZenWorkspacesStore.prototype = Object.create(Store.prototype);
|
|
||||||
ZenWorkspacesStore.prototype.constructor = ZenWorkspacesStore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the store by loading the current changeset.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.initialize = async function () {
|
|
||||||
await Store.prototype.initialize.call(this);
|
|
||||||
// Additional initialization if needed
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all workspace IDs from the storage.
|
|
||||||
* @returns {Object} An object mapping workspace UUIDs to true.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.getAllIDs = async function () {
|
|
||||||
try {
|
|
||||||
const workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
|
||||||
const ids = {};
|
|
||||||
for (const workspace of workspaces) {
|
|
||||||
ids[workspace.uuid] = true;
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error fetching all workspace IDs', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles changing the ID of a workspace.
|
|
||||||
* @param {String} oldID - The old UUID.
|
|
||||||
* @param {String} newID - The new UUID.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.changeItemID = async function (oldID, newID) {
|
|
||||||
try {
|
|
||||||
const workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
|
||||||
const workspace = workspaces.find((ws) => ws.uuid === oldID);
|
|
||||||
if (workspace) {
|
|
||||||
workspace.uuid = newID;
|
|
||||||
await ZenWorkspacesStorage.saveWorkspace(workspace, false);
|
|
||||||
// Mark the new ID as changed for sync
|
|
||||||
await ZenWorkspacesStorage.markChanged(newID);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error changing workspace ID from ${oldID} to ${newID}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a workspace exists.
|
|
||||||
* @param {String} id - The UUID of the workspace.
|
|
||||||
* @returns {Boolean} True if the workspace exists, false otherwise.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.itemExists = async function (id) {
|
|
||||||
try {
|
|
||||||
const workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
|
||||||
return workspaces.some((ws) => ws.uuid === id);
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error checking if workspace exists with ID ${id}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a record for a workspace.
|
|
||||||
* @param {String} id - The UUID of the workspace.
|
|
||||||
* @param {String} collection - The collection name.
|
|
||||||
* @returns {ZenWorkspaceRecord} The workspace record.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.createRecord = async function (id, collection) {
|
|
||||||
try {
|
|
||||||
const workspaces = await ZenWorkspacesStorage.getWorkspaces();
|
|
||||||
const workspace = workspaces.find((ws) => ws.uuid === id);
|
|
||||||
const record = new ZenWorkspaceRecord(collection, id);
|
|
||||||
|
|
||||||
if (workspace) {
|
|
||||||
record.name = workspace.name;
|
|
||||||
record.icon = workspace.icon;
|
|
||||||
record.default = workspace.default;
|
|
||||||
record.containerTabId = workspace.containerTabId;
|
|
||||||
record.position = workspace.position;
|
|
||||||
if (workspace.theme) {
|
|
||||||
record.theme_type = workspace.theme.type;
|
|
||||||
record.theme_colors = JSON.stringify(workspace.theme.gradientColors);
|
|
||||||
record.theme_opacity = workspace.theme.opacity;
|
|
||||||
record.theme_rotation = workspace.theme.rotation;
|
|
||||||
record.theme_texture = workspace.theme.texture;
|
|
||||||
}
|
|
||||||
record.deleted = false;
|
|
||||||
} else {
|
|
||||||
record.deleted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return record;
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error creating record for workspace ID ${id}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new workspace.
|
|
||||||
* @param {ZenWorkspaceRecord} record - The workspace record to create.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.create = async function (record) {
|
|
||||||
try {
|
|
||||||
this._validateRecord(record);
|
|
||||||
const workspace = {
|
|
||||||
uuid: record.id,
|
|
||||||
name: record.name,
|
|
||||||
icon: record.icon,
|
|
||||||
default: record.default,
|
|
||||||
containerTabId: record.containerTabId,
|
|
||||||
position: record.position,
|
|
||||||
theme: record.theme_type
|
|
||||||
? {
|
|
||||||
type: record.theme_type,
|
|
||||||
gradientColors: JSON.parse(record.theme_colors),
|
|
||||||
opacity: record.theme_opacity,
|
|
||||||
rotation: record.theme_rotation,
|
|
||||||
texture: record.theme_texture,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
};
|
|
||||||
await ZenWorkspacesStorage.saveWorkspace(workspace, false);
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error creating workspace with ID ${record.id}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates an existing workspace.
|
|
||||||
* @param {ZenWorkspaceRecord} record - The workspace record to update.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.update = async function (record) {
|
|
||||||
try {
|
|
||||||
this._validateRecord(record);
|
|
||||||
await this.create(record); // Reuse create for update
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error updating workspace with ID ${record.id}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a workspace.
|
|
||||||
* @param {ZenWorkspaceRecord} record - The workspace record to remove.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.remove = async function (record) {
|
|
||||||
try {
|
|
||||||
await ZenWorkspacesStorage.removeWorkspace(record.id, false);
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error removing workspace with ID ${record.id}`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wipes all workspaces from the storage.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.wipe = async function () {
|
|
||||||
try {
|
|
||||||
await ZenWorkspacesStorage.wipeAllWorkspaces();
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error wiping all workspaces', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a workspace record.
|
|
||||||
* @param {ZenWorkspaceRecord} record - The workspace record to validate.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype._validateRecord = function (record) {
|
|
||||||
if (!record.id || typeof record.id !== 'string') {
|
|
||||||
throw new Error('Invalid workspace ID');
|
|
||||||
}
|
|
||||||
if (!record.name || typeof record.name !== 'string') {
|
|
||||||
throw new Error(`Invalid workspace name for ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (typeof record.default !== 'boolean') {
|
|
||||||
record.default = false;
|
|
||||||
}
|
|
||||||
if (record.icon != null && typeof record.icon !== 'string') {
|
|
||||||
throw new Error(`Invalid icon for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (record.containerTabId != null && typeof record.containerTabId !== 'number') {
|
|
||||||
throw new Error(`Invalid containerTabId for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (record.position != null && typeof record.position !== 'number') {
|
|
||||||
throw new Error(`Invalid position for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate theme properties if they exist
|
|
||||||
if (record.theme_type) {
|
|
||||||
if (typeof record.theme_type !== 'string') {
|
|
||||||
throw new Error(`Invalid theme_type for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (!record.theme_colors || typeof record.theme_colors !== 'string') {
|
|
||||||
throw new Error(`Invalid theme_colors for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
JSON.parse(record.theme_colors);
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid theme_colors JSON for workspace ID ${record.id}. Error: ${e.message}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (record.theme_opacity != null && typeof record.theme_opacity !== 'number') {
|
|
||||||
throw new Error(`Invalid theme_opacity for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (record.theme_rotation != null && typeof record.theme_rotation !== 'number') {
|
|
||||||
throw new Error(`Invalid theme_rotation for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
if (record.theme_texture != null && typeof record.theme_texture !== 'number') {
|
|
||||||
throw new Error(`Invalid theme_texture for workspace ID ${record.id}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves changed workspace IDs since the last sync.
|
|
||||||
* @returns {Object} An object mapping workspace UUIDs to their change timestamps.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.getChangedIDs = async function () {
|
|
||||||
try {
|
|
||||||
return await ZenWorkspacesStorage.getChangedIDs();
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error retrieving changed IDs from storage', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears all recorded changes after a successful sync.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.clearChangedIDs = async function () {
|
|
||||||
try {
|
|
||||||
await ZenWorkspacesStorage.clearChangedIDs();
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error clearing changed IDs in storage', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks a workspace as changed.
|
|
||||||
* @param {String} uuid - The UUID of the workspace that changed.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.markChanged = async function (uuid) {
|
|
||||||
try {
|
|
||||||
await ZenWorkspacesStorage.markChanged(uuid);
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error marking workspace ${uuid} as changed`, error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalizes the store by ensuring all pending operations are completed.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesStore.prototype.finalize = async function () {
|
|
||||||
await Store.prototype.finalize.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Define ZenWorkspacesTracker
|
|
||||||
function ZenWorkspacesTracker(name, engine) {
|
|
||||||
Tracker.call(this, name, engine);
|
|
||||||
this._ignoreAll = false;
|
|
||||||
|
|
||||||
// Observe profile-before-change to stop the tracker gracefully
|
|
||||||
Services.obs.addObserver(this.asyncObserver, 'profile-before-change');
|
|
||||||
}
|
|
||||||
|
|
||||||
ZenWorkspacesTracker.prototype = Object.create(Tracker.prototype);
|
|
||||||
ZenWorkspacesTracker.prototype.constructor = ZenWorkspacesTracker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves changed workspace IDs by delegating to the store.
|
|
||||||
* @returns {Object} An object mapping workspace UUIDs to their change timestamps.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.getChangedIDs = async function () {
|
|
||||||
try {
|
|
||||||
return await this.engine._store.getChangedIDs();
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error retrieving changed IDs from store', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears all recorded changes after a successful sync.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.clearChangedIDs = async function () {
|
|
||||||
try {
|
|
||||||
await this.engine._store.clearChangedIDs();
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error('Error clearing changed IDs in store', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the tracker starts. Registers observers to listen for workspace changes.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.onStart = function () {
|
|
||||||
if (this._started) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._log.trace('Starting tracker');
|
|
||||||
// Register observers for workspace changes
|
|
||||||
Services.obs.addObserver(this.asyncObserver, 'zen-workspace-added');
|
|
||||||
Services.obs.addObserver(this.asyncObserver, 'zen-workspace-removed');
|
|
||||||
Services.obs.addObserver(this.asyncObserver, 'zen-workspace-updated');
|
|
||||||
this._started = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the tracker stops. Unregisters observers.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.onStop = function () {
|
|
||||||
if (!this._started) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._log.trace('Stopping tracker');
|
|
||||||
// Unregister observers for workspace changes
|
|
||||||
Services.obs.removeObserver(this.asyncObserver, 'zen-workspace-added');
|
|
||||||
Services.obs.removeObserver(this.asyncObserver, 'zen-workspace-removed');
|
|
||||||
Services.obs.removeObserver(this.asyncObserver, 'zen-workspace-updated');
|
|
||||||
this._started = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles observed events and marks workspaces as changed accordingly.
|
|
||||||
* @param {nsISupports} subject - The subject of the notification.
|
|
||||||
* @param {String} topic - The topic of the notification.
|
|
||||||
* @param {String} data - Additional data (JSON stringified array of UUIDs).
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.observe = async function (subject, topic, data) {
|
|
||||||
if (this.ignoreAll) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
switch (topic) {
|
|
||||||
case 'profile-before-change':
|
|
||||||
await this.stop();
|
|
||||||
break;
|
|
||||||
case 'zen-workspace-removed':
|
|
||||||
case 'zen-workspace-updated':
|
|
||||||
case 'zen-workspace-added': {
|
|
||||||
let workspaceIDs;
|
|
||||||
if (data) {
|
|
||||||
try {
|
|
||||||
workspaceIDs = JSON.parse(data);
|
|
||||||
if (!Array.isArray(workspaceIDs)) {
|
|
||||||
throw new Error('Parsed data is not an array');
|
|
||||||
}
|
|
||||||
} catch (parseError) {
|
|
||||||
this._log.error(`Failed to parse workspace UUIDs from data: ${data}`, parseError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._log.error(`No data received for event ${topic}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._log.trace(`Observed ${topic} for UUIDs: ${workspaceIDs.join(', ')}`);
|
|
||||||
|
|
||||||
// Process each UUID
|
|
||||||
for (const workspaceID of workspaceIDs) {
|
|
||||||
if (typeof workspaceID === 'string') {
|
|
||||||
// Inform the store about the change
|
|
||||||
await this.engine._store.markChanged(workspaceID);
|
|
||||||
} else {
|
|
||||||
this._log.warn(`Invalid workspace ID encountered: ${workspaceID}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bump the score once after processing all changes
|
|
||||||
if (workspaceIDs.length > 0) {
|
|
||||||
this.score += SCORE_INCREMENT_XLARGE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this._log.error(`Error handling ${topic} in observe method`, error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalizes the tracker by ensuring all pending operations are completed.
|
|
||||||
*/
|
|
||||||
ZenWorkspacesTracker.prototype.finalize = async function () {
|
|
||||||
await Tracker.prototype.finalize.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Define ZenWorkspacesEngine
|
|
||||||
function ZenWorkspacesEngine(service) {
|
|
||||||
SyncEngine.call(this, 'Workspaces', service);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZenWorkspacesEngine.prototype = Object.create(SyncEngine.prototype);
|
|
||||||
ZenWorkspacesEngine.prototype.constructor = ZenWorkspacesEngine;
|
|
||||||
|
|
||||||
ZenWorkspacesEngine.prototype._storeObj = ZenWorkspacesStore;
|
|
||||||
ZenWorkspacesEngine.prototype._trackerObj = ZenWorkspacesTracker;
|
|
||||||
ZenWorkspacesEngine.prototype._recordObj = ZenWorkspaceRecord;
|
|
||||||
ZenWorkspacesEngine.prototype.version = 2;
|
|
||||||
|
|
||||||
ZenWorkspacesEngine.prototype.syncPriority = 10;
|
|
||||||
ZenWorkspacesEngine.prototype.allowSkippedRecord = false;
|
|
||||||
|
|
||||||
Object.setPrototypeOf(ZenWorkspacesEngine.prototype, SyncEngine.prototype);
|
|
||||||
@@ -33,7 +33,7 @@ zen-workspace-creation {
|
|||||||
width: calc(100% - 10px);
|
width: calc(100% - 10px);
|
||||||
margin: auto;
|
margin: auto;
|
||||||
gap: 3.2rem;
|
gap: 3.2rem;
|
||||||
margin-top: 1.2rem;
|
margin-top: 0.6rem;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
& .zen-workspace-creation-form {
|
& .zen-workspace-creation-form {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
content/browser/zen-components/ZenWorkspaces.mjs (../../zen/workspaces/ZenWorkspaces.mjs)
|
content/browser/zen-components/ZenWorkspaces.mjs (../../zen/workspaces/ZenWorkspaces.mjs)
|
||||||
content/browser/zen-components/ZenWorkspaceCreation.mjs (../../zen/workspaces/ZenWorkspaceCreation.mjs)
|
content/browser/zen-components/ZenWorkspaceCreation.mjs (../../zen/workspaces/ZenWorkspaceCreation.mjs)
|
||||||
content/browser/zen-components/ZenWorkspacesStorage.mjs (../../zen/workspaces/ZenWorkspacesStorage.mjs)
|
content/browser/zen-components/ZenWorkspacesStorage.mjs (../../zen/workspaces/ZenWorkspacesStorage.mjs)
|
||||||
content/browser/zen-components/ZenWorkspacesSync.mjs (../../zen/workspaces/ZenWorkspacesSync.mjs)
|
|
||||||
content/browser/zen-components/ZenGradientGenerator.mjs (../../zen/workspaces/ZenGradientGenerator.mjs)
|
content/browser/zen-components/ZenGradientGenerator.mjs (../../zen/workspaces/ZenGradientGenerator.mjs)
|
||||||
* content/browser/zen-styles/zen-workspaces.css (../../zen/workspaces/zen-workspaces.css)
|
* content/browser/zen-styles/zen-workspaces.css (../../zen/workspaces/zen-workspaces.css)
|
||||||
content/browser/zen-styles/zen-gradient-generator.css (../../zen/workspaces/zen-gradient-generator.css)
|
content/browser/zen-styles/zen-gradient-generator.css (../../zen/workspaces/zen-gradient-generator.css)
|
||||||
@@ -181,7 +181,11 @@
|
|||||||
height: calc(100% - var(--zen-toolbox-padding) * 2);
|
height: calc(100% - var(--zen-toolbox-padding) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:not([zen-private-window]) & {
|
:root[zen-private-window] & {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root:not([zen-unsynced-window]) & {
|
||||||
&:hover,
|
&:hover,
|
||||||
&[open='true'] {
|
&[open='true'] {
|
||||||
&::before {
|
&::before {
|
||||||
@@ -228,15 +232,19 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
|
:root[zen-unsynced-window] & {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.zen-workspaces-actions {
|
.zen-workspaces-actions {
|
||||||
margin-left: auto !important;
|
margin-left: auto !important;
|
||||||
opacity: 0;
|
|
||||||
visibility: collapse;
|
|
||||||
transition: opacity 0.1s;
|
transition: opacity 0.1s;
|
||||||
order: 5;
|
order: 5;
|
||||||
--toolbarbutton-inner-padding: 6px !important;
|
--toolbarbutton-inner-padding: 6px !important;
|
||||||
|
opacity: 0;
|
||||||
|
visibility: collapse;
|
||||||
|
|
||||||
& image {
|
& image {
|
||||||
border-radius: max(calc(var(--border-radius-medium) - 4px), 4px) !important;
|
border-radius: max(calc(var(--border-radius-medium) - 4px), 4px) !important;
|
||||||
@@ -248,9 +256,24 @@
|
|||||||
:root[zen-renaming-tab='true'] & {
|
:root[zen-renaming-tab='true'] & {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root[zen-unsynced-window] & {
|
||||||
|
.toolbarbutton-text {
|
||||||
|
display: flex;
|
||||||
|
font-size: 10px;
|
||||||
|
min-height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbarbutton-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:not([zen-private-window]) &:hover .zen-workspaces-actions,
|
:root[zen-unsynced-window='true']
|
||||||
|
#navigator-toolbox[zen-has-implicit-hover='true']
|
||||||
|
& .zen-workspaces-actions,
|
||||||
|
:root:not([zen-unsynced-window]) &:hover .zen-workspaces-actions,
|
||||||
& .zen-workspaces-actions[open='true'] {
|
& .zen-workspaces-actions[open='true'] {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ export default [
|
|||||||
'gZenWorkspaces',
|
'gZenWorkspaces',
|
||||||
'gZenKeyboardShortcutsManager',
|
'gZenKeyboardShortcutsManager',
|
||||||
'ZenWorkspacesEngine',
|
'ZenWorkspacesEngine',
|
||||||
'ZenWorkspacesStorage',
|
|
||||||
'ZenWorkspaceBookmarksStorage',
|
'ZenWorkspaceBookmarksStorage',
|
||||||
|
|
||||||
'ZEN_KEYSET_ID',
|
'ZEN_KEYSET_ID',
|
||||||
|
|
||||||
'gZenPinnedTabManager',
|
'gZenPinnedTabManager',
|
||||||
'ZenPinnedTabsStorage',
|
|
||||||
|
|
||||||
'gZenEmojiPicker',
|
'gZenEmojiPicker',
|
||||||
'gZenSessionStore',
|
'gZenSessionStore',
|
||||||
|
|||||||
Reference in New Issue
Block a user