From d0edb6e42376b1e7e3e25d57c4b0dae9025f2d68 Mon Sep 17 00:00:00 2001 From: "Mr. M" Date: Mon, 2 Mar 2026 19:27:46 +0100 Subject: [PATCH] feat: Dont make boost manager a service, b=no-bug, c=no-component --- src/zen/boosts/ZenBoostStyles.sys.mjs | 2 +- src/zen/boosts/components.conf | 15 --------------- src/zen/boosts/moz.build | 9 --------- src/zen/boosts/nsIZenBoostsBackend.idl | 19 ------------------- src/zen/boosts/nsZenBoostsBackend.cpp | 21 +++++++++++++-------- src/zen/boosts/nsZenBoostsBackend.h | 10 +++------- 6 files changed, 17 insertions(+), 59 deletions(-) delete mode 100644 src/zen/boosts/components.conf delete mode 100644 src/zen/boosts/nsIZenBoostsBackend.idl diff --git a/src/zen/boosts/ZenBoostStyles.sys.mjs b/src/zen/boosts/ZenBoostStyles.sys.mjs index c120c5ba8..bde3a7143 100644 --- a/src/zen/boosts/ZenBoostStyles.sys.mjs +++ b/src/zen/boosts/ZenBoostStyles.sys.mjs @@ -76,7 +76,7 @@ export class nsZenBoostStyles { if (fontCase != "" || fontFamily != "") { style += `/* Text Format */\n`; - style += `body :is(p, h1, h2, h3, h4, h5, a, span, textarea, input) {\n`; + style += `body * {\n`; style += `${fontFamily}\n`; style += `${fontCase}\n`; style += `}\n`; diff --git a/src/zen/boosts/components.conf b/src/zen/boosts/components.conf deleted file mode 100644 index d6b81daa1..000000000 --- a/src/zen/boosts/components.conf +++ /dev/null @@ -1,15 +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/. - -Classes = [ - { - 'cid': '{7d46aa4e-7486-4f77-ab47-81125f1a5723}', - 'interfaces': ['nsIZenBoostsBackend'], - 'contract_ids': ['@mozilla.org/zen/boosts-backend;1'], - 'type': 'zen::nsZenBoostsBackend', - 'headers': ['mozilla/nsZenBoostsBackend.h'], - 'js_name': 'boosts', - 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, - }, -] diff --git a/src/zen/boosts/moz.build b/src/zen/boosts/moz.build index e6cef5a3b..3c496f3ba 100644 --- a/src/zen/boosts/moz.build +++ b/src/zen/boosts/moz.build @@ -16,10 +16,6 @@ FINAL_TARGET_FILES.actors += [ "actors/ZenBoostsParent.sys.mjs", ] -XPIDL_SOURCES += [ - "nsIZenBoostsBackend.idl", -] - EXPORTS.mozilla += [ "nsZenBoostsBackend.h", ] @@ -28,9 +24,4 @@ SOURCES += [ "nsZenBoostsBackend.cpp", ] -XPCOM_MANIFESTS += [ - "components.conf", -] - FINAL_LIBRARY = "xul" -XPIDL_MODULE = "zen_boosts" diff --git a/src/zen/boosts/nsIZenBoostsBackend.idl b/src/zen/boosts/nsIZenBoostsBackend.idl deleted file mode 100644 index 1d30cfd0c..000000000 --- a/src/zen/boosts/nsIZenBoostsBackend.idl +++ /dev/null @@ -1,19 +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/. */ - -#include "nsISupports.idl" - -/** - * @brief Interface for Zen boosts backend. - */ -[scriptable, uuid(7d46aa4e-7486-4f77-ab47-81125f1a5723)] -interface nsIZenBoostsBackend : nsISupports { - %{C++ - /* - * @brief Called when the presshell is entered. See nsDisplayListBuilder::EnterPresShell - * for context. - */ - auto onPresShellEntered(nsPresContext* aPresContext) -> void; - %} -}; diff --git a/src/zen/boosts/nsZenBoostsBackend.cpp b/src/zen/boosts/nsZenBoostsBackend.cpp index 83aaae5e4..b1fdf5327 100644 --- a/src/zen/boosts/nsZenBoostsBackend.cpp +++ b/src/zen/boosts/nsZenBoostsBackend.cpp @@ -233,13 +233,16 @@ inline static void GetZenBoostsDataFromBrowsingContext(ZenBoostData* aData, } // namespace -// Use the macro to inject all of the definitions for nsISupports. -NS_IMPL_ISUPPORTS(nsZenBoostsBackend, nsIZenBoostsBackend) -nsZenBoostsBackend::nsZenBoostsBackend() {}; - -auto nsZenBoostsBackend::GetInstance() -> nsCOMPtr { - static nsCOMPtr zenBoosts( - do_GetService(ZEN_BOOSTS_BACKEND_CONTRACTID)); +auto nsZenBoostsBackend::GetInstance() -> nsZenBoostsBackend* { + static nsZenBoostsBackend* zenBoosts; + if (!XRE_IsContentProcess()) { + // Zen boosts are only supported in content, so if we're in the parent process, + // just return null. + return nullptr; + } + if (!zenBoosts) { + zenBoosts = new nsZenBoostsBackend(); + } return zenBoosts; } @@ -248,7 +251,9 @@ auto nsZenBoostsBackend::onPresShellEntered(mozilla::dom::Document* aDocument) // Note that aDocument can be null when entering anonymous content frames. // We explicitly do this to prevent applying boosts to anonymous content, such // as devtools or screenshots. - auto browsingContext = aDocument ? aDocument->GetBrowsingContext() : nullptr; + mozilla::dom::BrowsingContext* browsingContext = aDocument + ? aDocument->GetBrowsingContext() + : nullptr; if (!browsingContext) { return; } diff --git a/src/zen/boosts/nsZenBoostsBackend.h b/src/zen/boosts/nsZenBoostsBackend.h index a9c1da9bf..f9fce035d 100644 --- a/src/zen/boosts/nsZenBoostsBackend.h +++ b/src/zen/boosts/nsZenBoostsBackend.h @@ -7,7 +7,6 @@ #include "nsColor.h" #include "nsPresContext.h" -#include "nsIZenBoostsBackend.h" #include "mozilla/RefPtr.h" @@ -17,11 +16,9 @@ using ZenBoostData = nscolor; // For now, Zen boosts data is just a color. namespace zen { -class nsZenBoostsBackend final : public nsIZenBoostsBackend { - NS_DECL_ISUPPORTS - +class nsZenBoostsBackend final { public: - explicit nsZenBoostsBackend(); + explicit nsZenBoostsBackend() = default; /** * Indicates whether the current frame being rendered is for anonymous @@ -59,7 +56,6 @@ class nsZenBoostsBackend final : public nsIZenBoostsBackend { return mCurrentBrowsingContext; } - NS_DECL_NSIZENBOOSTSBACKEND private: ~nsZenBoostsBackend() = default; @@ -73,7 +69,7 @@ class nsZenBoostsBackend final : public nsIZenBoostsBackend { * @brief Get the singleton instance of the ZenBoostsBackend. * @return The singleton instance. */ - static auto GetInstance() -> nsCOMPtr; + static auto GetInstance() -> nsZenBoostsBackend*; }; } // namespace zen