Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] dev from zen-browser:dev #82

Merged
merged 4 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n
11 changes: 6 additions & 5 deletions src/browser/base/content/zen-styles/zen-browser-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
}

@media (-moz-windows-accent-color-in-titlebar) {
background-color: var(--toolbox-non-lwt-bgcolor);
background-color: var(--toolbox-bgcolor);
color: var(--toolbox-textcolor);
transition: background-color var(--inactive-window-transition);
&:-moz-window-inactive {
background-color: var(--toolbox-non-lwt-bgcolor-inactive);
color: var(--toolbox-non-lwt-textcolor-inactive);
background-color: var(--toolbox-bgcolor-inactive);
color: var(--toolbox-textcolor-inactive);
}
&::after {
display: none;
Expand All @@ -67,10 +68,10 @@

@media (not (-moz-windows-accent-color-in-titlebar)) and (not (-moz-windows-mica)) {
transition: color var(--inactive-window-transition);
color: var(--toolbox-non-lwt-textcolor-inactive);
&:-moz-window-inactive {
&::after {
backdrop-filter: grayscale(0.8);
background-color: var(--toolbox-bgcolor-inactive);
color: var(--toolbox-textcolor-inactive);
}
}
}
Expand Down
29 changes: 26 additions & 3 deletions src/browser/base/zen-components/ZenKeyboardShortcuts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ class KeyShortcut {

static parseFromSaved(json) {
let rv = [];

for (let key of json) {
rv.push(this.#parseFromJSON(key));
if (this.#shortcutIsValid(key)) {
rv.push(this.#parseFromJSON(key));
} else {
console.warn('[zen CKS]: Invalid shortcut', key['id']);
throw new Error('Invalid shortcut found');
}
}

return rv;
Expand All @@ -330,6 +334,12 @@ class KeyShortcut {
return 'other';
}

static #shortcutIsValid(shortcut) {
// See https://github.com/zen-browser/desktop/issues/4071, some *old* shortcuts dont have
// any of `key`, `keycode`, `l10nId`. This fix also allows us to avoid any future issues
return !(shortcut['key'] == '' && shortcut['keycode'] == '' && shortcut['l10nId'] == null);
}

static #parseFromJSON(json) {
return new KeyShortcut(
json['id'],
Expand Down Expand Up @@ -467,6 +477,10 @@ class KeyShortcut {
return this.#internal;
}

isInvalid() {
return this.#key == '' && this.#keycode == '' && this.#l10nId == null;
}

setModifiers(modifiers) {
if ((!modifiers) instanceof KeyShortcutModifiers) {
throw new Error('Only KeyShortcutModifiers allowed');
Expand Down Expand Up @@ -899,6 +913,15 @@ var gZenKeyboardShortcutsManager = {
return KeyShortcut.parseFromSaved(data);
} catch (e) {
console.error('Zen CKS: Error parsing saved shortcuts. Resetting to defaults...', e);
gNotificationBox.appendNotification(
"zen-shortcuts-corrupted",
{
label: { "l10n-id": "zen-shortcuts-corrupted" },
image: "chrome://browser/skin/notification-icons/persistent-storage-blocked.svg",
priority: gNotificationBox.PRIORITY_WARNING_HIGH,
},
[]
);
return null;
}
};
Expand Down Expand Up @@ -962,7 +985,7 @@ var gZenKeyboardShortcutsManager = {
//}

for (let key of this._currentShortcutList) {
if (key.isEmpty() || key.isInternal()) {
if (key.isEmpty() || key.isInternal() || key.isInvalid()) {
continue;
}
let child = key.toXHTMLElement(browser);
Expand Down
2 changes: 1 addition & 1 deletion src/browser/base/zen-components/ZenThemesCommon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var ZenThemesCommon = {
{
label: { "l10n-id": "zen-themes-corrupted" },
image: "chrome://browser/skin/notification-icons/persistent-storage-blocked.svg",
priority: gNotificationBox.PRIORITY_INFO_MEDIUM,
priority: gNotificationBox.PRIORITY_WARNING_HIGH,
},
[]
);
Expand Down
5 changes: 5 additions & 0 deletions src/browser/base/zen-components/ZenWorkspaces.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {

async _propagateWorkspaceData({ ignoreStrip = false, clearCache = true } = {}) {
await this.foreachWindowAsActive(async (browser) => {
// Do not update the window if workspaces are not enabled in it.
// For example, when the window is in private browsing mode.
if (!browser.ZenWorkspaces.workspaceEnabled) {
return;
}
await browser.ZenWorkspaces.updateWorkspaceIndicator();
let workspaceList = browser.document.getElementById('PanelUI-zen-workspaces-list');
const createWorkspaceElement = (workspace) => {
Expand Down
Loading