mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1432651 p2 - Remove nsIPrintSession and all the code that uses it. r=emilio,geckoview-reviewers,m_kato
Lately nsIPrintSession was only used to pass around RemotePrintJobChild objects. Now that we pass those objects explicitly where needed (part 1), this class serves no purpose. Another reason to want to get rid of this class is that having it as a member of nsIPrintSettings made no sense and was confusing. Differential Revision: https://phabricator.services.mozilla.com/D146381
This commit is contained in:
parent
41b151c8c4
commit
247babb515
@ -148,7 +148,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
# include "nsIPrintSession.h"
|
||||
# include "nsIPrintSettings.h"
|
||||
# include "nsIPrintSettingsService.h"
|
||||
# include "nsIWebBrowserPrint.h"
|
||||
@ -1117,9 +1116,9 @@ nsresult BrowserChild::UpdateRemotePrintSettings(
|
||||
// BC tree, and our code above is simple enough and keeps strong refs to
|
||||
// everything.
|
||||
([&]() MOZ_CAN_RUN_SCRIPT_BOUNDARY {
|
||||
cv->SetPrintSettingsForSubdocument(
|
||||
printSettings, static_cast<RemotePrintJobChild*>(
|
||||
aPrintData.remotePrintJobChild()));
|
||||
RefPtr<RemotePrintJobChild> printJob =
|
||||
static_cast<RemotePrintJobChild*>(aPrintData.remotePrintJobChild());
|
||||
cv->SetPrintSettingsForSubdocument(printSettings, printJob);
|
||||
}());
|
||||
} else if (RefPtr<BrowserBridgeChild> remoteChild =
|
||||
BrowserBridgeChild::GetFrom(aBc->GetEmbedderElement())) {
|
||||
@ -2517,13 +2516,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvPrint(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrintSession> printSession =
|
||||
do_CreateInstance("@mozilla.org/gfx/printsession;1", &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
printSettings->SetPrintSession(printSession);
|
||||
printSettingsSvc->DeserializeToPrintSettings(aPrintData, printSettings);
|
||||
{
|
||||
IgnoredErrorResult rv;
|
||||
|
@ -45,7 +45,6 @@
|
||||
// Print Options
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsIPrintSettingsService.h"
|
||||
#include "nsIPrintSession.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsXPCOM.h"
|
||||
|
||||
@ -494,6 +493,11 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
|
||||
if (aWebProgressListener) {
|
||||
printData->mPrintProgressListeners.AppendObject(aWebProgressListener);
|
||||
}
|
||||
if (mRemotePrintJob) {
|
||||
// If we have a RemotePrintJob add it to the print progress listeners,
|
||||
// so it can forward to the parent.
|
||||
printData->mPrintProgressListeners.AppendElement(mRemotePrintJob);
|
||||
}
|
||||
|
||||
// Get the docshell for this documentviewer
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell, &rv));
|
||||
@ -538,26 +542,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
|
||||
|
||||
printData->mPrintSettings->GetShrinkToFit(&printData->mShrinkToFit);
|
||||
|
||||
// Create a print session and let the print settings know about it.
|
||||
// Don't overwrite an existing print session.
|
||||
// The print settings hold an nsWeakPtr to the session so it does not
|
||||
// need to be cleared from the settings at the end of the job.
|
||||
// XXX What lifetime does the printSession need to have?
|
||||
nsCOMPtr<nsIPrintSession> printSession;
|
||||
if (!mIsCreatingPrintPreview) {
|
||||
rv = printData->mPrintSettings->GetPrintSession(
|
||||
getter_AddRefs(printSession));
|
||||
if (NS_FAILED(rv) || !printSession) {
|
||||
printSession = do_CreateInstance("@mozilla.org/gfx/printsession;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
printData->mPrintSettings->SetPrintSession(printSession);
|
||||
} else if (mRemotePrintJob) {
|
||||
// If we have a RemotePrintJob add it to the print progress listeners,
|
||||
// so it can forward to the parent.
|
||||
printData->mPrintProgressListeners.AppendElement(mRemotePrintJob);
|
||||
}
|
||||
}
|
||||
|
||||
bool printingViaParent =
|
||||
XRE_IsContentProcess() && StaticPrefs::print_print_via_parent();
|
||||
nsCOMPtr<nsIDeviceContextSpec> devspec;
|
||||
|
@ -65,13 +65,6 @@ Classes = [
|
||||
'headers': ['/widget/android/nsPrintSettingsServiceAndroid.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
|
||||
'contract_ids': ['@mozilla.org/gfx/printsession;1'],
|
||||
'type': 'nsPrintSession',
|
||||
'headers': ['/widget/nsPrintSession.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'cid': '{d3f69889-e13a-4321-980c-a39332e21f34}',
|
||||
'contract_ids': ['@mozilla.org/gfx/devicecontextspec;1'],
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "nsPrinterListCUPS.h"
|
||||
#include "nsPrintSettingsServiceX.h"
|
||||
#include "nsPrintDialogX.h"
|
||||
#include "nsPrintSession.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
@ -66,7 +65,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterListCUPS)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceX, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsUserIdleServiceX, nsUserIdleServiceX::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init)
|
||||
@ -106,7 +104,6 @@ NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PRINTER_LIST_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
|
||||
@ -137,7 +134,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{&kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor},
|
||||
{&kNS_PRINTER_LIST_CID, false, NULL, nsPrinterListCUPSConstructor,
|
||||
mozilla::Module::MAIN_PROCESS_ONLY},
|
||||
{&kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor},
|
||||
{&kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintSettingsServiceXConstructor},
|
||||
{&kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor,
|
||||
mozilla::Module::MAIN_PROCESS_ONLY},
|
||||
@ -167,7 +163,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
mozilla::Module::MAIN_PROCESS_ONLY},
|
||||
{"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID},
|
||||
{"@mozilla.org/gfx/printerlist;1", &kNS_PRINTER_LIST_CID, mozilla::Module::MAIN_PROCESS_ONLY},
|
||||
{"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
|
||||
{"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
|
||||
{NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID,
|
||||
mozilla::Module::MAIN_PROCESS_ONLY},
|
||||
|
@ -135,13 +135,6 @@ if defined('NS_PRINTING'):
|
||||
'init_method': 'Init',
|
||||
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
|
||||
},
|
||||
{
|
||||
'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
|
||||
'contract_ids': ['@mozilla.org/gfx/printsession;1'],
|
||||
'type': 'nsPrintSession',
|
||||
'headers': ['/widget/nsPrintSession.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}',
|
||||
'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'],
|
||||
|
@ -119,7 +119,6 @@ XPIDL_SOURCES += [
|
||||
"nsIPaperMargin.idl",
|
||||
"nsIPrinter.idl",
|
||||
"nsIPrinterList.idl",
|
||||
"nsIPrintSession.idl",
|
||||
"nsIPrintSettings.idl",
|
||||
"nsIPrintSettingsService.idl",
|
||||
"nsIScreen.idl",
|
||||
@ -271,7 +270,6 @@ if CONFIG["NS_PRINTING"]:
|
||||
"nsPaperMargin.cpp",
|
||||
"nsPrinterBase.cpp",
|
||||
"nsPrinterListBase.cpp",
|
||||
"nsPrintSession.cpp",
|
||||
"nsPrintSettingsService.cpp",
|
||||
]
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsIPrintSession.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "private/pprio.h"
|
||||
|
||||
@ -55,14 +54,6 @@ nsDeviceContextSpecProxy::Init(nsIWidget* aWidget,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIPrintSettings only has a weak reference to nsIPrintSession, so we hold
|
||||
// it to make sure it's available for the lifetime of the print.
|
||||
rv = mPrintSettings->GetPrintSession(getter_AddRefs(mPrintSession));
|
||||
if (NS_FAILED(rv) || !mPrintSession) {
|
||||
NS_WARNING("We can't print via the parent without an nsIPrintSession.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mRemotePrintJob) {
|
||||
NS_WARNING("We can't print via the parent without a RemotePrintJobChild.");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "mozilla/layout/printing/DrawEventRecorder.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsIPrintSession;
|
||||
class nsIUUIDGenerator;
|
||||
|
||||
namespace mozilla {
|
||||
@ -60,7 +59,6 @@ class nsDeviceContextSpecProxy final : public nsIDeviceContextSpec {
|
||||
~nsDeviceContextSpecProxy();
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
nsCOMPtr<nsIPrintSession> mPrintSession;
|
||||
nsCOMPtr<nsIDeviceContextSpec> mRealDeviceContextSpec;
|
||||
RefPtr<RemotePrintJobChild> mRemotePrintJob;
|
||||
RefPtr<mozilla::layout::DrawEventRecorderPRFileDesc> mRecorder;
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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"
|
||||
|
||||
/**
|
||||
* nsIPrintSession
|
||||
*
|
||||
* Stores data pertaining only to a single print job. This
|
||||
* differs from nsIPrintSettings, which stores data which may
|
||||
* be valid across a number of jobs.
|
||||
*
|
||||
* The creation of a component which implements this interface
|
||||
* will begin the session. Likewise, destruction of that object
|
||||
* will end the session.
|
||||
*
|
||||
* @status
|
||||
*/
|
||||
|
||||
%{ C++
|
||||
namespace mozilla {
|
||||
namespace layout {
|
||||
class RemotePrintJobChild;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
[ptr] native RemotePrintJobChildPtr(mozilla::layout::RemotePrintJobChild);
|
||||
|
||||
[uuid(424ae4bb-10ca-4f35-b84e-eab893322df4)]
|
||||
interface nsIPrintSession : nsISupports
|
||||
{
|
||||
/**
|
||||
* The remote print job is used for printing via the parent process.
|
||||
*/
|
||||
[notxpcom, nostdcall] attribute RemotePrintJobChildPtr remotePrintJob;
|
||||
};
|
@ -20,7 +20,6 @@ struct PrintSettingsInitializer;
|
||||
native nsNativeIntMargin(nsIntMargin);
|
||||
[ref] native nsNativeIntMarginRef(nsIntMargin);
|
||||
|
||||
interface nsIPrintSession;
|
||||
interface nsIOutputStream;
|
||||
|
||||
/**
|
||||
@ -213,11 +212,6 @@ interface nsIPrintSettings : nsISupports
|
||||
*/
|
||||
bool equivalentTo(in nsIPrintSettings aPrintSettings);
|
||||
|
||||
/**
|
||||
* Data Members
|
||||
*/
|
||||
[noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */
|
||||
|
||||
/**
|
||||
* The edge measurements define the positioning of the headers
|
||||
* and footers on the page. They're treated as an offset from the edges of
|
||||
|
@ -1,33 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "nsPrintSession.h"
|
||||
|
||||
#include "mozilla/layout/RemotePrintJobChild.h"
|
||||
|
||||
typedef mozilla::layout::RemotePrintJobChild RemotePrintJobChild;
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSession
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPrintSession, nsIPrintSession, nsISupportsWeakReference)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsPrintSession::nsPrintSession() = default;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsPrintSession::~nsPrintSession() = default;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsresult nsPrintSession::Init() { return NS_OK; }
|
||||
|
||||
RemotePrintJobChild* nsPrintSession::GetRemotePrintJob() {
|
||||
return mRemotePrintJob;
|
||||
}
|
||||
|
||||
void nsPrintSession::SetRemotePrintJob(RemotePrintJobChild* aRemotePrintJob) {
|
||||
mRemotePrintJob = aRemotePrintJob;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef nsPrintSession_h__
|
||||
#define nsPrintSession_h__
|
||||
|
||||
#include "nsIPrintSession.h"
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layout {
|
||||
class RemotePrintJobChild;
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSession
|
||||
//*****************************************************************************
|
||||
|
||||
class nsPrintSession : public nsIPrintSession, public nsSupportsWeakReference {
|
||||
virtual ~nsPrintSession();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRINTSESSION
|
||||
|
||||
nsPrintSession();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
private:
|
||||
RefPtr<mozilla::layout::RemotePrintJobChild> mRemotePrintJob;
|
||||
};
|
||||
|
||||
#endif // nsPrintSession_h__
|
@ -9,8 +9,6 @@
|
||||
#include "nsCoord.h"
|
||||
#include "nsPaper.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrintSession.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
@ -84,33 +82,6 @@ nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS) { *this = aPS; }
|
||||
|
||||
nsPrintSettings::~nsPrintSettings() = default;
|
||||
|
||||
NS_IMETHODIMP nsPrintSettings::GetPrintSession(
|
||||
nsIPrintSession** aPrintSession) {
|
||||
NS_ENSURE_ARG_POINTER(aPrintSession);
|
||||
*aPrintSession = nullptr;
|
||||
|
||||
nsCOMPtr<nsIPrintSession> session = do_QueryReferent(mSession);
|
||||
if (!session) return NS_ERROR_NOT_INITIALIZED;
|
||||
*aPrintSession = session;
|
||||
NS_ADDREF(*aPrintSession);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession* aPrintSession) {
|
||||
// Clearing it by passing nullptr is not allowed. That's why we
|
||||
// use a weak ref so that it doesn't have to be cleared.
|
||||
NS_ENSURE_ARG(aPrintSession);
|
||||
|
||||
mSession = do_GetWeakReference(aPrintSession);
|
||||
if (!mSession) {
|
||||
// This may happen if the implementation of this object does
|
||||
// not support weak references - programmer error.
|
||||
NS_ERROR("Could not get a weak reference from aPrintSession");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrintSettings::GetPrintReversed(bool* aPrintReversed) {
|
||||
*aPrintReversed = mPrintReversed;
|
||||
return NS_OK;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsIPrinterList.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsPrintSettingsImpl.h"
|
||||
#include "nsIPrintSession.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
@ -176,13 +175,6 @@ nsPrintSettingsService::SerializeToPrintData(nsIPrintSettings* aSettings,
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsService::DeserializeToPrintSettings(const PrintData& data,
|
||||
nsIPrintSettings* settings) {
|
||||
nsCOMPtr<nsIPrintSession> session;
|
||||
nsresult rv = settings->GetPrintSession(getter_AddRefs(session));
|
||||
if (NS_SUCCEEDED(rv) && session) {
|
||||
session->SetRemotePrintJob(
|
||||
static_cast<RemotePrintJobChild*>(data.remotePrintJobChild()));
|
||||
}
|
||||
|
||||
settings->SetPageRanges(data.pageRanges());
|
||||
|
||||
settings->SetEdgeTop(data.edgeTop());
|
||||
|
@ -310,13 +310,6 @@
|
||||
} \
|
||||
}
|
||||
|
||||
#define NS_PRINTSESSION_CID \
|
||||
{ \
|
||||
0x2f977d53, 0x5485, 0x11d4, { \
|
||||
0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define NS_PRINTDIALOGSERVICE_CID \
|
||||
{ \
|
||||
0x06beec76, 0xa183, 0x4d9f, { \
|
||||
|
@ -211,11 +211,4 @@ if defined('NS_PRINTING'):
|
||||
'headers': ['/widget/windows/nsDeviceContextSpecWin.h'],
|
||||
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
|
||||
},
|
||||
{
|
||||
'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
|
||||
'contract_ids': ['@mozilla.org/gfx/printsession;1'],
|
||||
'type': 'nsPrintSession',
|
||||
'headers': ['/widget/nsPrintSession.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user