diff --git a/src/browser/app/profile/features/mods.inc b/src/browser/app/profile/features/mods.inc index 5e15ce43..cf31b5bb 100644 --- a/src/browser/app/profile/features/mods.inc +++ b/src/browser/app/profile/features/mods.inc @@ -8,11 +8,9 @@ pref('zen.mods.auto-update-days', 20); // In days #ifdef MOZILLA_OFFICIAL pref('zen.mods.auto-update', true); - pref('zen.rice.api.url', 'https://share.zen-browser.app', locked); - pref('zen.injections.match-urls', 'https://zen-browser.app/*,https://share.zen-browser.app/*', locked); + pref('zen.injections.match-urls', 'https://zen-browser.app/*', locked); #else pref('zen.mods.auto-update', false); - pref('zen.rice.api.url', "http://localhost", locked); pref('zen.injections.match-urls', 'http://localhost/*', locked); #endif diff --git a/src/dom/base/Document-cpp.patch b/src/dom/base/Document-cpp.patch index c324fda3..d83aac7c 100644 --- a/src/dom/base/Document-cpp.patch +++ b/src/dom/base/Document-cpp.patch @@ -1,20 +1,24 @@ diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp -index a16bef739fcde0f14ba7e53e0acfa3aa2ee1dd3a..f928c0f1df4e86bd344ab7e57dab112234fb92e8 100644 +index a16bef739fcde0f14ba7e53e0acfa3aa2ee1dd3a..7c4bee2422f76272022f0c793aa52ea02e292bde 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp -@@ -3332,6 +3332,15 @@ void Document::FillStyleSetUserAndUASheets() { +@@ -10,6 +10,7 @@ - ServoStyleSet& styleSet = EnsureStyleSet(); - for (StyleSheet* sheet : *sheetService->UserStyleSheets()) { -+ // If the url starts with "file://" and ends with 'zen-themes.css', then -+ // skip it if the document is not in a chrome docshell. -+ // This is to avoid loading the user chrome stylesheet in the content -+ // process, which is not allowed. -+ auto spec = sheet->GetSheetURI()->GetSpecOrDefault(); -+ if (!IsInChromeDocShell() && StringBeginsWith(spec, "file://"_ns) && -+ StringEndsWith(spec, "zen-themes.css"_ns)) { -+ continue; -+ } + #include "mozilla/dom/Document.h" + #include "mozilla/dom/DocumentInlines.h" ++#include "mozilla/ZenStyleSheetCache.h" + + #include + #include +@@ -3335,6 +3336,11 @@ void Document::FillStyleSetUserAndUASheets() { styleSet.AppendStyleSheet(*sheet); } ++ if (auto sheet = zen::ZenStyleSheetCache::Singleton()->GetModsSheet(); sheet && IsInChromeDocShell()) { ++ // The mods sheet is only used in the chrome docshell. ++ styleSet.AppendStyleSheet(*sheet); ++ } ++ + StyleSheet* sheet = IsInChromeDocShell() ? cache->GetUserChromeSheet() + : cache->GetUserContentSheet(); + if (sheet) { diff --git a/src/layout/base/nsStyleSheetService-h.patch b/src/layout/base/nsStyleSheetService-h.patch deleted file mode 100644 index 904403ad..00000000 --- a/src/layout/base/nsStyleSheetService-h.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/layout/base/nsStyleSheetService.h b/layout/base/nsStyleSheetService.h -index 8c49b338bf8e6830874ace9a08e8c0713167ee58..53a48129b2b6b2adf15e0fe17da14c3b16577966 100644 ---- a/layout/base/nsStyleSheetService.h -+++ b/layout/base/nsStyleSheetService.h -@@ -50,6 +50,8 @@ class nsStyleSheetService final : public nsIStyleSheetService, - - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; - -+ void UpdateZenModStyles(mozilla::StyleSheet* aSheet, nsIURI* aURI, bool aInsert); -+ - static nsStyleSheetService* GetInstance(); - static nsStyleSheetService* gInstance; - diff --git a/src/zen/mods/ZenMods.mjs b/src/zen/mods/ZenMods.mjs index 92fafd59..493b6a44 100644 --- a/src/zen/mods/ZenMods.mjs +++ b/src/zen/mods/ZenMods.mjs @@ -48,9 +48,18 @@ ); } + async #readStylesheet() { + const path = this.modsRootPath; + if (!(await IOUtils.exists(path))) { + return ''; + } + return await IOUtils.readUTF8(this.#styleSheetPath); + } + async #insertStylesheet() { try { - this.#modsBackend.rebuildModsStyles(); + const content = await this.#readStylesheet(); + this.#modsBackend.rebuildModsStyles(content); } catch (e) { console.warn('[ZenMods]: Error rebuilding mods styles:', e); } diff --git a/src/zen/mods/ZenStyleSheetCache.cpp b/src/zen/mods/ZenStyleSheetCache.cpp index fb0bdd31..a6fb1bcc 100644 --- a/src/zen/mods/ZenStyleSheetCache.cpp +++ b/src/zen/mods/ZenStyleSheetCache.cpp @@ -11,29 +11,36 @@ #include "mozilla/css/SheetParsingMode.h" #include "mozilla/GlobalStyleSheetCache.h" +#define GET_MODS_FILE(chromeFile, err) \ + NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(chromeFile)); \ + if (!chromeFile) { \ + return err; \ + } \ + chromeFile->Append(ZEN_MODS_FILENAME); + namespace zen { using namespace mozilla; NS_IMPL_ISUPPORTS(ZenStyleSheetCache, nsISupports) -auto ZenStyleSheetCache::InvalidateModsSheet() -> void { - mModsSheet = nullptr; -} - auto ZenStyleSheetCache::GetModsSheet() -> StyleSheet* { if (mModsSheet) { // If the mods stylesheet is already loaded, return it. return mModsSheet; } nsCOMPtr chromeFile; + GET_MODS_FILE(chromeFile, nullptr); - NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(chromeFile)); - if (!chromeFile) { - // if we don't have a profile yet, that's OK! - return nullptr; + // Create the mods stylesheet if it doesn't exist. + bool exists; + chromeFile->Exists(&exists); + if (!exists) { + nsresult rv = chromeFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644); + if (NS_FAILED(rv)) { + return nullptr; + } } - chromeFile->Append(ZEN_MODS_FILENAME); LoadSheetFile(chromeFile, css::eUserSheetFeatures); return mModsSheet; } @@ -49,7 +56,7 @@ auto ZenStyleSheetCache::LoadSheetFile(nsIFile* aFile, auto loader = new mozilla::css::Loader; auto result = loader->LoadSheetSync(uri, aParsingMode, - css::Loader::UseSystemPrincipal::Yes); + css::Loader::UseSystemPrincipal::Yes); if (MOZ_UNLIKELY(result.isErr())) { return; } @@ -65,6 +72,20 @@ auto ZenStyleSheetCache::Singleton() -> ZenStyleSheetCache* { return gZenModsCache; } +nsresult ZenStyleSheetCache::RebuildModsStylesheets(const nsACString& aContents) { + // Re-parse the mods stylesheet. By doing so, we read + // Once we have the data as a nsACString, we call ReparseSheet from the + // StyleSheet class to re-parse the stylesheet. + auto sheet = GetModsSheet(); + if (!sheet) { + return NS_ERROR_FAILURE; + } + ErrorResult aRv; + sheet->ReparseSheet(aContents, aRv); + return aRv.StealNSResult(); +} + + mozilla::StaticRefPtr ZenStyleSheetCache::gZenModsCache; } // namespace: zen \ No newline at end of file diff --git a/src/zen/mods/ZenStyleSheetCache.h b/src/zen/mods/ZenStyleSheetCache.h index f83d3556..607a65f8 100644 --- a/src/zen/mods/ZenStyleSheetCache.h +++ b/src/zen/mods/ZenStyleSheetCache.h @@ -21,13 +21,6 @@ class ZenStyleSheetCache final : public nsISupports { public: NS_DECL_ISUPPORTS - /** - * @brief Clear up the cache and create a new mods stylesheet. - * This is called when we need to recalculate the mods stylesheets. - * @returns The mods stylesheet. - */ - auto InvalidateModsSheet() -> void; - /** * @brief Get the mods stylesheet. * This is called when we need to get the mods stylesheets. @@ -35,6 +28,15 @@ class ZenStyleSheetCache final : public nsISupports { */ auto GetModsSheet() -> StyleSheet*; + /** + * @brief Rebuild the mods stylesheets. + * This is re-parses the mods stylesheet and applies it to all + * the connected documents. + * @param aContents The contents of the mods stylesheet. + * @returns NS_OK on success, or an error code on failure. + */ + nsresult RebuildModsStylesheets(const nsACString& aContents); + static auto Singleton() -> ZenStyleSheetCache*; private: ZenStyleSheetCache() = default; diff --git a/src/zen/mods/nsIZenModsBackend.idl b/src/zen/mods/nsIZenModsBackend.idl index aadccc23..8a2567fc 100644 --- a/src/zen/mods/nsIZenModsBackend.idl +++ b/src/zen/mods/nsIZenModsBackend.idl @@ -15,17 +15,11 @@ */ [scriptable, uuid(a0ee4792-b186-4497-936d-53a8989fe836)] interface nsIZenModsBackend : nsISupports { - /* - * @brief Remove, clear cache and create a new mods stylesheet. - * This is called when we need to recalculate the mods stylesheets. - * @returns The mods stylesheet. - */ - void invalidateModsSheet(); /** * @brief Unregister and register the mods stylesheet. * This is called when we need to recalculate the mods stylesheets. * @returns void */ - void rebuildModsStyles(); + void rebuildModsStyles(in ACString aContents); }; diff --git a/src/zen/mods/nsZenModsBackend.cpp b/src/zen/mods/nsZenModsBackend.cpp index ce0170db..94e07ba8 100644 --- a/src/zen/mods/nsZenModsBackend.cpp +++ b/src/zen/mods/nsZenModsBackend.cpp @@ -45,61 +45,9 @@ auto nsZenModsBackend::CheckEnabled() -> bool { return mEnabled; } -auto nsZenModsBackend::RebuildModsStyles() -> nsresult { - // Invalidate the mods stylesheet cache. - GetZenStyleSheetCache()->InvalidateModsSheet(); - // Rebuild the mods stylesheets. - auto modsSheet = GetZenStyleSheetCache()->GetModsSheet(); - if (!modsSheet) { - return NS_ERROR_FAILURE; - } - // Get the service from @mozilla.org/content/style-sheet-service;1 - if (auto* sss = nsStyleSheetService::GetInstance()) { - // Register the mods stylesheet. - sss->UpdateZenModStyles(modsSheet, modsSheet->GetSheetURI(), CheckEnabled()); - } +auto nsZenModsBackend::RebuildModsStyles(const nsACString& aContents) -> nsresult { // Notify that the mods stylesheets have been rebuilt. - return NS_OK; -} - -NS_IMETHODIMP -nsZenModsBackend::InvalidateModsSheet() { - if (!mEnabled) { - return NS_ERROR_NOT_AVAILABLE; - } - GetZenStyleSheetCache()->InvalidateModsSheet(); - return NS_OK; + return GetZenStyleSheetCache()->RebuildModsStylesheets(aContents); } } // namespace: zen - -void nsStyleSheetService::UpdateZenModStyles(mozilla::StyleSheet* aSheet, nsIURI* aURI, bool aInsert) { - auto sheetType = nsStyleSheetService::USER_SHEET; - this->UnregisterSheet(aURI, sheetType); - if (!aSheet || !aInsert) { - return; // Nothing to update. - } - mSheets[sheetType].AppendElement(aSheet); - // Hold on to a copy of the registered PresShells. - for (mozilla::PresShell* presShell : mPresShells.Clone()) { - // Only allow on chrome documents. - auto doc = presShell->GetDocument(); - if (doc && !doc->IsInChromeDocShell()) { - continue; - } - presShell->NotifyStyleSheetServiceSheetAdded(aSheet, sheetType); - } - - if (XRE_IsParentProcess()) { - nsTArray children; - mozilla::dom::ContentParent::GetAll(children); - - if (children.IsEmpty()) { - return; - } - - for (uint32_t i = 0; i < children.Length(); i++) { - mozilla::Unused << children[i]->SendLoadAndRegisterSheet(aURI, sheetType); - } - } -} diff --git a/src/zen/workspaces/ZenGradientGenerator.mjs b/src/zen/workspaces/ZenGradientGenerator.mjs index f6751997..21570a62 100644 --- a/src/zen/workspaces/ZenGradientGenerator.mjs +++ b/src/zen/workspaces/ZenGradientGenerator.mjs @@ -840,11 +840,9 @@ const relativeY = pixelY - rect.top; if (!clickedDot && this.dots.length < 1) { - if (this.dots.length === 0) { - this.spawnDot({ x: relativeX, y: relativeY }, true); - } else { - this.spawnDot({ x: relativeX, y: relativeY }); - } + this.spawnDot({ x: relativeX, y: relativeY }, this.dots.length === 0); + // Set brightness to 50% + this.#currentLightness = 50; this.updateCurrentWorkspace(true); } else if (!clickedDot && existingPrimaryDot) { diff --git a/src/zen/workspaces/ZenWorkspaceIcons.mjs b/src/zen/workspaces/ZenWorkspaceIcons.mjs index 1c917ce7..f39d37a2 100644 --- a/src/zen/workspaces/ZenWorkspaceIcons.mjs +++ b/src/zen/workspaces/ZenWorkspaceIcons.mjs @@ -16,6 +16,15 @@ window.addEventListener('ZenWorkspacesUIUpdate', this, true); this.initDragAndDrop(); + this.addEventListener('mouseover', (e) => { + if (this.isReorderMode) { + return; + } + const target = e.target.closest('toolbarbutton[zen-workspace-id]'); + if (target) { + this.scrollLeft = target.offsetLeft - 10; + } + }); } initDragAndDrop() { @@ -118,6 +127,7 @@ } else { this.removeAttribute('dont-show'); } + gZenWorkspaces.onWindowResize(); } on_command(event) { diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index fc1b5171..acac8c51 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -2872,30 +2872,46 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { if (!parent || this._processingResize) { return; } - this._processingResize = true; - // Once we are overflowing, we align the buttons to always stay inside the container, - // meaning we need to remove the overflow attribute to reset the width - parent.removeAttribute('icons-overflow'); - requestAnimationFrame(() => { - const overflow = parent.scrollWidth > parent.clientWidth; - parent.toggleAttribute('icons-overflow', overflow); - // The maximum width a button has when it overflows based on the number of buttons - const numButtons = parent.children.length + 1; // +1 to exclude the active button - const maxWidth = 100 / numButtons; - parent.style.setProperty('--zen-overflowed-workspace-button-width', `${maxWidth}%`); - this._processingResize = false; + if (!gZenPinnedTabManager.expandedSidebarMode) { + for (const icon of parent.children) { + if (icon.tagName === 'toolbarbutton') { + icon.style.width = ''; // Reset to default size when in expanded mode + } + } + parent.removeAttribute('icons-overflow'); + return; + } + const maxButtonSize = 30; // IMPORTANT: This should match the CSS size of the icons + const minButtonSize = 15; + const separation = 3; // Space between icons - // Scroll to the active workspace button if it's not visible - const activeButton = parent.querySelector('.zen-workspace-button.active'); - if (!activeButton) { - return; + // Calculate the total width needed for all icons + const totalWidth = Array.from(parent.children).reduce((width, icon) => { + if (icon.tagName === 'toolbarbutton') { + return width + minButtonSize + separation; } - const parentRect = parent.getBoundingClientRect(); - const activeRect = activeButton.getBoundingClientRect(); - if (activeRect.left < parentRect.left || activeRect.right > parentRect.right) { - parent.scrollLeft = activeButton.offsetLeft; + return width; + }, 0); + + // Check if the total width exceeds the parent's width + if (totalWidth > parent.clientWidth) { + parent.setAttribute('icons-overflow', 'true'); + } else { + parent.removeAttribute('icons-overflow'); + } + + // Set the width of each icon to the maximum size they can fit on + const widthPerButton = Math.max( + Math.floor( + (parent.clientWidth - separation * (parent.children.length - 1)) / parent.children.length + ), + minButtonSize + ); + for (const icon of parent.children) { + if (icon.tagName === 'toolbarbutton') { + icon.style.width = `${Math.min(widthPerButton, maxButtonSize)}px`; } - }); + } } fixTabInsertLocation(tab) { diff --git a/src/zen/workspaces/create-workspace-form.css b/src/zen/workspaces/create-workspace-form.css index cb781c32..32ef37f8 100644 --- a/src/zen/workspaces/create-workspace-form.css +++ b/src/zen/workspaces/create-workspace-form.css @@ -95,6 +95,7 @@ zen-workspace-creation { --input-bgcolor: transparent; padding: 0 !important; width: 100%; + outline: none; } } diff --git a/src/zen/workspaces/overflow-icons.inc.css b/src/zen/workspaces/overflow-icons.inc.css index 930290bd..d100a022 100644 --- a/src/zen/workspaces/overflow-icons.inc.css +++ b/src/zen/workspaces/overflow-icons.inc.css @@ -5,7 +5,7 @@ */ &:not(:hover) { - width: min(var(--zen-overflowed-workspace-button-width), 25px); + width: min(var(--zen-overflowed-workspace-button-width,10px), 25px) !important; min-width: 10px; &::after { @@ -29,3 +29,7 @@ display: none; } } + +&:hover { + width: 20px !important; +} diff --git a/src/zen/workspaces/zen-workspaces.css b/src/zen/workspaces/zen-workspaces.css index 7942d1bf..891f3d36 100644 --- a/src/zen/workspaces/zen-workspaces.css +++ b/src/zen/workspaces/zen-workspaces.css @@ -11,8 +11,8 @@ align-items: center; display: flex; font-size: x-small; - padding: 0 3px; - margin: 0; + margin: 0 3px; + padding: 0; appearance: auto; position: relative; @@ -34,7 +34,7 @@ & toolbarbutton { margin: 0; - width: 30px; + max-width: 30px; height: 30px; display: flex; justify-content: center; @@ -84,9 +84,11 @@ &[icons-overflow] { gap: 0 !important; + justify-content: space-between; & toolbarbutton { margin: 0; + background: transparent; } /* Inlcude separately since ther'es a bug in the diff --git a/surfer.json b/surfer.json index 0e454a11..81316e71 100644 --- a/surfer.json +++ b/surfer.json @@ -19,7 +19,7 @@ "brandShortName": "Zen", "brandFullName": "Zen Browser", "release": { - "displayVersion": "1.14b", + "displayVersion": "1.14.1b", "github": { "repo": "zen-browser/desktop" },