From 303b6e39ed3dc07265164d34c727db618bf83c01 Mon Sep 17 00:00:00 2001 From: fen4flo <75260616+FlorianButz@users.noreply.github.com> Date: Sun, 20 Sep 2026 22:08:51 +0200 Subject: [PATCH] gh-15438: Performance optimizations and media tab for Library (gh-15483) Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com> Signed-off-by: fen4flo <75260616+FlorianButz@users.noreply.github.com> --- locales/en-US/browser/browser/zen-library.ftl | 22 + prefs/zen/library.yaml | 6 + src/zen/boosts/ZenBoostsManager.sys.mjs | 5 +- src/zen/common/styles/zen-browser-ui.css | 4 +- .../styles/zen-library-media-preview.css | 96 ++++ src/zen/common/styles/zen-library-widget.css | 24 +- .../common/styles/zen-single-components.css | 1 + src/zen/folders/ZenFolders.mjs | 10 + src/zen/glance/ZenGlanceManager.mjs | 35 +- src/zen/glance/zen-glance.css | 6 +- src/zen/library/ZenLibrary.mjs | 218 +++++-- src/zen/library/ZenLibraryDragAndDrop.mjs | 21 +- src/zen/library/ZenLibraryFileTypes.sys.mjs | 110 ++++ src/zen/library/ZenLibraryMediaPreview.mjs | 542 ++++++++++++++++++ src/zen/library/ZenLibraryWidget.sys.mjs | 16 +- src/zen/library/moz.build | 2 + .../sections/ZenLibraryDownloadsSection.mjs | 48 +- .../sections/ZenLibraryMediaSection.mjs | 451 ++++++++++++++- .../sections/ZenLibrarySpacesSection.mjs | 98 +++- src/zen/library/zen-library.css | 237 ++++++-- src/zen/spaces/ZenSpacesSwipe.mjs | 31 +- src/zen/spaces/zen-workspaces.css | 20 +- src/zen/tabs/zen-tabs/vertical-tabs.css | 2 +- 23 files changed, 1809 insertions(+), 196 deletions(-) create mode 100644 src/zen/common/styles/zen-library-media-preview.css create mode 100644 src/zen/library/ZenLibraryFileTypes.sys.mjs create mode 100644 src/zen/library/ZenLibraryMediaPreview.mjs diff --git a/locales/en-US/browser/browser/zen-library.ftl b/locales/en-US/browser/browser/zen-library.ftl index fb3009f35..906055768 100644 --- a/locales/en-US/browser/browser/zen-library.ftl +++ b/locales/en-US/browser/browser/zen-library.ftl @@ -35,6 +35,28 @@ library-history-search-placeholder = .placeholder = Search History… library-history-empty = No history found library-media-empty = No media found +library-media-search-placeholder = + .placeholder = Search Media… +library-media-loading = Looking for media… +library-media-opt-in-title = Your Media in the Library +library-media-opt-in-body = Quickly grab screenshots, images and videos from your computer by showing them in the Zen Library. +library-media-opt-in-button = Show Media +library-media-opt-in-note = Media never leaves your computer and is not viewable by anyone but you. +library-media-filter-title = Filter Media… +library-media-filter-folders = Where to look +library-media-open-in = Open in { $app } +library-media-close = + .title = Close +library-media-previous = + .title = Previous +library-media-next = + .title = Next +library-media-more = + .title = More options +library-media-menu-open = + .label = Open +library-media-menu-copy = + .label = Copy library-history-forget-button = .title = Remove from history library-history-reopen-button = diff --git a/prefs/zen/library.yaml b/prefs/zen/library.yaml index 9f607decc..00dabeb21 100644 --- a/prefs/zen/library.yaml +++ b/prefs/zen/library.yaml @@ -7,3 +7,9 @@ - name: zen.library.last-tab value: "history" + +- name: zen.library.media.enabled + value: false + +- name: zen.library.media.folders + value: "downloads,documents,pictures" diff --git a/src/zen/boosts/ZenBoostsManager.sys.mjs b/src/zen/boosts/ZenBoostsManager.sys.mjs index 2016a34a8..3614d3108 100644 --- a/src/zen/boosts/ZenBoostsManager.sys.mjs +++ b/src/zen/boosts/ZenBoostsManager.sys.mjs @@ -652,7 +652,10 @@ class nsZenBoostsManager { ); const progressListener = { - QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener"]), + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + ]), onLocationChange: webProgress => { if (webProgress.isTopLevel) { editor.close(); diff --git a/src/zen/common/styles/zen-browser-ui.css b/src/zen/common/styles/zen-browser-ui.css index 8504e5483..29fa4b686 100644 --- a/src/zen/common/styles/zen-browser-ui.css +++ b/src/zen/common/styles/zen-browser-ui.css @@ -100,14 +100,14 @@ body, display: flex; opacity: var(--zen-grainy-background-opacity, 0); - :root:not([swipe-gesture="true"]) & { + &:not([swipe-gesture="true"]) { /* note: Keep in sync with kGlobalAnimationDuration */ transition: opacity 0.2s ease-in-out; } } } -:root[swipe-gesture] #tabbrowser-arrowscrollbox { +#tabbrowser-arrowscrollbox[swipe-gesture] { /* See gh-13703 for rationale. */ pointer-events: none; } diff --git a/src/zen/common/styles/zen-library-media-preview.css b/src/zen/common/styles/zen-library-media-preview.css new file mode 100644 index 000000000..0ea53bf8b --- /dev/null +++ b/src/zen/common/styles/zen-library-media-preview.css @@ -0,0 +1,96 @@ +/* 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/. */ + +.zen-library-media-preview { + position: absolute; + inset: 0; + --zen-main-app-child-z-index: 3; + display: flex; + align-items: center; + justify-content: center; +} + +.zen-library-media-preview-backdrop { + position: absolute; + inset: 0; + -moz-window-dragging: drag; + background: light-dark(rgba(255, 255, 255, 0.55), rgba(0, 0, 0, 0.45)); +} + +.zen-library-media-preview-panel { + position: relative; + -moz-window-dragging: no-drag; + display: flex; + flex-direction: column; + width: min(78vw, 1100px); + border-radius: 18px; + overflow: hidden; + background: light-dark(rgb(245, 245, 247), rgb(28, 30, 32)); + box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); +} + +.zen-library-media-preview-header { + --zen-toolbar-button-size: 15px; + + display: flex; + align-items: center; + gap: 8px; + padding: 10px 12px; + flex: none; + color: light-dark(rgb(28, 30, 32), rgb(233, 234, 237)); +} + +.zen-library-media-preview-name { + margin-inline-start: 6px; + font-size: 13px; + font-weight: 600; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.zen-library-media-preview-date { + font-size: 13px; + opacity: 0.6; + margin-inline-end: auto; + white-space: nowrap; +} + +.zen-library-media-preview .toolbarbutton-1 > .toolbarbutton-icon { + box-sizing: border-box; + -moz-context-properties: fill; + fill: var(--toolbarbutton-icon-fill); +} + +.zen-library-media-preview-open { + & > .toolbarbutton-text { + display: block; + margin: 0; + padding: 5px 10px; + border-radius: var(--toolbarbutton-border-radius); + background: color-mix(in srgb, currentColor 12%, transparent); + font-weight: 600; + } + + &:hover > .toolbarbutton-text { + background: color-mix(in srgb, currentColor 20%, transparent); + } +} + +.zen-library-media-preview-stage { + display: flex; + align-items: center; + justify-content: center; + height: min(64vh, 620px); + padding: 16px; + background: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.28)); + border-top: 1px solid light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.07)); +} + +.zen-library-media-preview-media { + max-width: 100%; + max-height: 100%; + border-radius: 8px; + object-fit: contain; +} diff --git a/src/zen/common/styles/zen-library-widget.css b/src/zen/common/styles/zen-library-widget.css index 3b0694850..9ba4e5fec 100644 --- a/src/zen/common/styles/zen-library-widget.css +++ b/src/zen/common/styles/zen-library-widget.css @@ -27,6 +27,7 @@ width: var(--zen-library-sprite-size); height: var(--zen-library-sprite-size); background-image: url("chrome://browser/skin/zen-icons/library/library-sprite.svg"); + scale: 1.08; } @media (prefers-reduced-motion: no-preference) { @@ -87,7 +88,7 @@ } &[downloading] { - transform: scale(calc((var(--zen-library-progress) * 0.2 + 0.81) * 100%)); + transform: scale(calc((var(--zen-library-progress) * 0.2 + 0.8) * 100%)); } } } @@ -123,7 +124,7 @@ background-image: var(--download-image); width: 20px; height: 20px; - border-radius: 8px; + border-radius: var(--border-radius-small); background-size: cover; scale: 2; @@ -140,7 +141,7 @@ --border-color: color-mix(in srgb, var(--zen-primary-color), light-dark(rgba(0,0,0,.8), white) 70%); background-color: color-mix(in srgb, var(--zen-primary-color), light-dark(white, rgba(0,0,0,.5)) 80%); - border: 3px solid var(--border-color); + border: 3px solid transparent; box-shadow: 0 0 6px 2px rgba(0,0,0,.1); color: var(--border-color); width: 25px; @@ -175,11 +176,14 @@ --thickness: 3px; --progress: var(--zen-accent-button-background); - background: conic-gradient( - from -0deg, - var(--progress) calc(var(--value) * 1%), - transparent 0 - ); + background: + conic-gradient( + from 0deg, + var(--progress) calc(var(--value) * 1%), + transparent 0 + ) + border-box, + var(--border-color) border-box; mask: radial-gradient( circle closest-side, @@ -188,6 +192,10 @@ ); } +#zen-sidebar-foot-buttons:is([zen-library-stack-open], [zen-library-stack-closing]) { + z-index: 3; +} + #zen-library-download-list { width: 100%; height: auto; diff --git a/src/zen/common/styles/zen-single-components.css b/src/zen/common/styles/zen-single-components.css index e9b8cec81..c57bfd103 100644 --- a/src/zen/common/styles/zen-single-components.css +++ b/src/zen/common/styles/zen-single-components.css @@ -812,3 +812,4 @@ } %include zen-library-widget.css +%include zen-library-media-preview.css diff --git a/src/zen/folders/ZenFolders.mjs b/src/zen/folders/ZenFolders.mjs index bd8a91044..24ab45dd6 100644 --- a/src/zen/folders/ZenFolders.mjs +++ b/src/zen/folders/ZenFolders.mjs @@ -498,6 +498,16 @@ class nsZenFolders extends nsZenDOMOperatedFeature { await this.animateCollapse(group); } + /** + * Settles a collapsed folder's own height. The library toggles folders + * through copies, so the real one needs telling once the dust settles. + * + * @param {Element} group - A folder + */ + relayoutCollapsedFolder(group) { + this.#queueCollapsedRelayout(group); + } + #queueCollapsedRelayout(group) { if (this.#collapsedRelayoutQueue.size === 0) { requestAnimationFrame(() => this.#flushCollapsedRelayout()); diff --git a/src/zen/glance/ZenGlanceManager.mjs b/src/zen/glance/ZenGlanceManager.mjs index b243bd146..1b3e8e097 100644 --- a/src/zen/glance/ZenGlanceManager.mjs +++ b/src/zen/glance/ZenGlanceManager.mjs @@ -69,22 +69,19 @@ class nsZenGlanceManager extends nsZenDOMOperatedFeature { return this.#detached?.browser ?? null; } - get #detachedHost() { - let host = document.getElementById("zen-glance-detached"); - if (!host) { - host = window.MozXULElement.parseXULToFragment(` -