mirror of
https://github.com/zen-browser/desktop.git
synced 2026-04-03 06:09:19 +00:00
feat: Dont make boost manager a service, b=no-bug, c=no-component
This commit is contained in:
@@ -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`;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
]
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
%}
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user