feat: Dont make boost manager a service, b=no-bug, c=no-component

This commit is contained in:
Mr. M
2026-03-02 19:27:46 +01:00
parent d459ad932d
commit d0edb6e423
6 changed files with 17 additions and 59 deletions

View File

@@ -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`;

View File

@@ -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,
},
]

View File

@@ -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"

View File

@@ -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;
%}
};

View File

@@ -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<nsZenBoostsBackend> {
static nsCOMPtr<zen::nsZenBoostsBackend> 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;
}

View File

@@ -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<nsZenBoostsBackend>;
static auto GetInstance() -> nsZenBoostsBackend*;
};
} // namespace zen