diff --git a/src/layout/base/nsStyleSheetService-h.patch b/src/layout/base/nsStyleSheetService-h.patch new file mode 100644 index 00000000..998ea2cf --- /dev/null +++ b/src/layout/base/nsStyleSheetService-h.patch @@ -0,0 +1,13 @@ +diff --git a/layout/base/nsStyleSheetService.h b/layout/base/nsStyleSheetService.h +index 8c49b338bf8e6830874ace9a08e8c0713167ee58..115bf09314970fd2fe79793e9cf8e0c40eb0459b 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 ZenMarkStylesAsChanged(); ++ + static nsStyleSheetService* GetInstance(); + static nsStyleSheetService* gInstance; + diff --git a/src/zen/mods/ZenMods.mjs b/src/zen/mods/ZenMods.mjs index 493b6a44..65e91adf 100644 --- a/src/zen/mods/ZenMods.mjs +++ b/src/zen/mods/ZenMods.mjs @@ -42,10 +42,8 @@ await this.#rebuildModsStylesheet(); } - #getStylesheetURIForMod(mod) { - return Services.io.newFileURI( - new FileUtils.File(PathUtils.join(this.getModFolder(mod.id), 'chrome.css')) - ); + #getStylesheetPathForMod(mod) { + return PathUtils.join(this.getModFolder(mod.id), 'chrome.css'); } async #readStylesheet() { @@ -223,7 +221,7 @@ const mods = []; for (let mod of modList) { - mod._chromeURL = this.#getStylesheetURIForMod(mod).spec; + mod._filePath = this.#getStylesheetPathForMod(mod); mods.push(mod); } @@ -244,7 +242,8 @@ content += `/* Readme: ${mod.readme} */\n`; } - content += `@import url("${mod._chromeURL}");\n`; + const chromeContent = await IOUtils.readUTF8(mod._filePath); + content += chromeContent; } content += this.#kZenStylesheetModFooter; diff --git a/src/zen/mods/ZenStyleSheetCache.cpp b/src/zen/mods/ZenStyleSheetCache.cpp index a6fb1bcc..3ba2b28a 100644 --- a/src/zen/mods/ZenStyleSheetCache.cpp +++ b/src/zen/mods/ZenStyleSheetCache.cpp @@ -8,6 +8,8 @@ #include "nsCOMPtr.h" #include "nsIFile.h" +#include "nsStyleSheetService.h" + #include "mozilla/css/SheetParsingMode.h" #include "mozilla/GlobalStyleSheetCache.h" @@ -82,6 +84,9 @@ nsresult ZenStyleSheetCache::RebuildModsStylesheets(const nsACString& aContents) } ErrorResult aRv; sheet->ReparseSheet(aContents, aRv); + if (auto sss = nsStyleSheetService::GetInstance()) { + sss->ZenMarkStylesAsChanged(); + } return aRv.StealNSResult(); } diff --git a/src/zen/mods/nsZenModsBackend.cpp b/src/zen/mods/nsZenModsBackend.cpp index 94e07ba8..346adb7a 100644 --- a/src/zen/mods/nsZenModsBackend.cpp +++ b/src/zen/mods/nsZenModsBackend.cpp @@ -51,3 +51,14 @@ auto nsZenModsBackend::RebuildModsStyles(const nsACString& aContents) -> nsresul } } // namespace: zen + +auto nsStyleSheetService::ZenMarkStylesAsChanged() -> void { + for (auto& presShell : mPresShells) { + if (presShell) { + if (auto doc = presShell->GetDocument(); doc && doc->IsInChromeDocShell()) { + // Notify the document that styles have changed. + doc->ApplicableStylesChanged(); + } + } + } +}