Bug 1432651 p1 - Pass RemotePrintJobChild through to the places where it's needed. r=emilio

Given how nsIPrintSettings is passed around, stored and copied all over the
place, it's very hard to reason about where and when a RemotePrintJobChild is
needed or valid. This patch avoids all that by explicitly passing a
RemotePrintJobChild when it's needed.

Another reason to make this change is because RemotePrintJobChild really does
not belong on nsIPrintSettings. That interface is supposed to represent a
collection of settings for laying out the document that is to be printed.

Differential Revision: https://phabricator.services.mozilla.com/D146380
This commit is contained in:
Jonathan Watt
2022-05-16 08:38:01 +00:00
parent 119d6b5c6f
commit e5a8eb1650
13 changed files with 78 additions and 49 deletions

View File

@@ -272,6 +272,7 @@ using namespace mozilla::dom::ipc;
using mozilla::BasePrincipal;
using mozilla::OriginAttributes;
using mozilla::TimeStamp;
using mozilla::layout::RemotePrintJobChild;
#define FORWARD_TO_INNER(method, args, err_rval) \
PR_BEGIN_MACRO \
@@ -5139,7 +5140,7 @@ void nsGlobalWindowOuter::PrintOuter(ErrorResult& aError) {
});
const bool forPreview = !StaticPrefs::print_always_print_silent();
Print(nullptr, nullptr, nullptr, IsPreview(forPreview),
Print(nullptr, nullptr, nullptr, nullptr, IsPreview(forPreview),
IsForWindowDotPrint::Yes, nullptr, aError);
#endif
}
@@ -5159,9 +5160,9 @@ class MOZ_RAII AutoModalState {
};
Nullable<WindowProxyHolder> nsGlobalWindowOuter::Print(
nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aListener,
nsIDocShell* aDocShellToCloneInto, IsPreview aIsPreview,
IsForWindowDotPrint aForWindowDotPrint,
nsIPrintSettings* aPrintSettings, RemotePrintJobChild* aRemotePrintJob,
nsIWebProgressListener* aListener, nsIDocShell* aDocShellToCloneInto,
IsPreview aIsPreview, IsForWindowDotPrint aForWindowDotPrint,
PrintPreviewResolver&& aPrintPreviewCallback, ErrorResult& aError) {
#ifdef NS_PRINTING
nsCOMPtr<nsIPrintSettingsService> printSettingsService =
@@ -5318,7 +5319,7 @@ Nullable<WindowProxyHolder> nsGlobalWindowOuter::Print(
}
} else {
// Historically we've eaten this error.
webBrowserPrint->Print(ps, aListener);
webBrowserPrint->Print(ps, aRemotePrintJob, aListener);
}
}